Closed Bug 1207502 Opened 10 years ago Closed 9 years ago

Need APIs to simulate native hardware events in test cases of try server

Categories

(Testing :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: chunmin, Assigned: chunmin)

References

Details

Attachments

(1 file)

Problem : How to simulate native hardware events in test cases of try server Requirement: The produced events must be dispatched from chrome process first. Luckily, we can do this by executing the command:"sendevent [device] [type] [code] [value]" via adb shell[1]. It can simulate several kinds of hardware events, such as physical keyboard events, sensors events, touch events,...etc. However, it's better to write a set of APIs to do that because one action might need many commands(e.g., example below). Use case ----------------------------------------------------------------- In smart feature phone project, we need to write tests for simulating the physical keydown/keypress/keyup events. Example: Simulate physical hardware keydown/keypress/keyup in marionette ----------------------------------------------------------------- import mozdevice dm = mozdevice.DeviceManagerADB() '''simulate to press b by adb shell''' dm.shellCheckOutput(['sendevent', 'dev/input/event0','1', '48', '1']) dm.shellCheckOutput(['sendevent', 'dev/input/event0','0', '0', '0']) dm.shellCheckOutput(['sendevent', 'dev/input/event0','1', '48', '0']) dm.shellCheckOutput(['sendevent', 'dev/input/event0','0', '0', '0']) The above code will produce keydown and then keyup. The keypress event will be produced by gecko itself[2]. [1] https://groups.google.com/d/msg/tasker/LJhmfxT2mj8/y92jivjmZNIJ [2] https://dxr.mozilla.org/mozilla-central/source/widget/gonk/nsAppShell.cpp#347
Blocks: 1110030
Hi, William, I was wondering if you could share your opinions on this patch. I'll be grateful if you could help me to enable this feature.
Assignee: nobody → cchang
Attachment #8670600 - Flags: feedback?(wlachance)
Comment on attachment 8670600 [details] [diff] [review] [WIP] Simulate hardware event via ADB Review of attachment 8670600 [details] [diff] [review]: ----------------------------------------------------------------- Hi Chun-Min, I wouldn't put this code in mozbase/mozdevice, which is intended only for code which is generically useful across test harnesses (see the docs here: http://mozbase.readthedocs.org/en/latest/). If you're just trying to do one thing, let's just put this code there. We can potentially move it to mozbase later if it proves to be generically useful. Really, I'm probably the wrong person to ask about this stuff, as I'm not actively involved in B2G/FirefoxOS these days. From what I understand, they've moved heavily away from using python/mozbase for B2G testing to an architecture based on Node.JS. You might want to do the same. I'm happy to help with Orangutan / sendevent specific-issues and with the python stuff if it's relevant, but I think a better idea might be to send a message to the FirefoxOS development mailing list (https://lists.mozilla.org/listinfo/dev-fxos), describe what you're trying to do, and see if anyone has advice. This has the nice side benefit of giving your project more visibility. :) ::: testing/mozbase/mozdevice/mozdevice/deviceEventInputer.py @@ +297,5 @@ > +# ================================================== > +class InputDevices: > + > + def __init__(self): > + self.dmADB = DeviceManagerADB() It would be preferable to use the newer ADBDevice interface here. It's more reliable and better maintained at this point. http://mozbase.readthedocs.org/en/latest/mozdevice.html#adbcommand
Attachment #8670600 - Flags: feedback?(wlachance)
(In reply to William Lachance (:wlach) from comment #3) > Comment on attachment 8670600 [details] [diff] [review] > [WIP] Simulate hardware event via ADB > > Review of attachment 8670600 [details] [diff] [review]: > ----------------------------------------------------------------- > > Hi Chun-Min, Hi, William, Thank you for your kind feedback. > I wouldn't put this code in mozbase/mozdevice, which is intended only for > code which is generically useful across test harnesses (see the docs here: > http://mozbase.readthedocs.org/en/latest/). If you're just trying to do one > thing, let's just put this code there. We can potentially move it to mozbase > later if it proves to be generically useful. Yes, I know the mozbase/mozdevice should be generically useful across test harnesses. Many native hardware events can be simulated via ADB besides keyboard events. The KeyboardEvents is just one case. > Really, I'm probably the wrong person to ask about this stuff, as I'm not > actively involved in B2G/FirefoxOS these days. From what I understand, > they've moved heavily away from using python/mozbase for B2G testing to an > architecture based on Node.JS. You might want to do the same. I'm happy to > help with Orangutan / sendevent specific-issues and with the python stuff if > it's relevant, but I think a better idea might be to send a message to the > FirefoxOS development mailing list > (https://lists.mozilla.org/listinfo/dev-fxos), describe what you're trying > to do, and see if anyone has advice. This has the nice side benefit of > giving your project more visibility. :) You're right. However, AFAIK, the node.js version of marionette can't run on real devices now. I hope my test can run on emulator and real devices with physical keyboard(or keypad) both. I agree your point. Maybe I should put this code in my test case now and send a message to dev-fxos to discuss this issue. > ::: testing/mozbase/mozdevice/mozdevice/deviceEventInputer.py > @@ +297,5 @@ > > +# ================================================== > > +class InputDevices: > > + > > + def __init__(self): > > + self.dmADB = DeviceManagerADB() > > It would be preferable to use the newer ADBDevice interface here. It's more > reliable and better maintained at this point. > > http://mozbase.readthedocs.org/en/latest/mozdevice.html#adbcommand OK, I'll change it. Again, thank you for your attention to this matter.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: