Closed Bug 1020874 Opened 10 years ago Closed 10 years ago

Add optional parameters x and y to Action.long_press()

Categories

(Remote Protocol :: Marionette, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla33

People

(Reporter: TYLin, Assigned: TYLin)

Details

(Keywords: pi-marionette-userinput)

Attachments

(1 file, 1 obsolete file)

We should allow long_press() to accept coordinate x, y as press() does.
Comment on attachment 8434840 [details] [diff] [review]
Add option parameters x and y to Action.long_press()

Review of attachment 8434840 [details] [diff] [review]:
-----------------------------------------------------------------

Cool! Will you please add a small test for this in testing/marionette/client/marionette/tests/unit/test_single_finger.py and testing/marionette/client/marionette/tests/unit/test_single_finger_desktop.py, please? Thanks!
(In reply to Malini Das [:mdas] from comment #2)
> Cool! Will you please add a small test for this in
> testing/marionette/client/marionette/tests/unit/test_single_finger.py and
> testing/marionette/client/marionette/tests/unit/test_single_finger_desktop.
> py, please? Thanks!

The tests in test_single_finger.py and test_single_finger_desktop.py are all clicking on some buttons. 
Is it sufficient to test long_press() on a button at (x, y), say (1, 1), and see if the button is long pressed?
(In reply to Ting-Yu Lin [:TYLin] from comment #3)
> The tests in test_single_finger.py and test_single_finger_desktop.py are all
> clicking on some buttons. 
> Is it sufficient to test long_press() on a button at (x, y), say (1, 1), and
> see if the button is long pressed?

Not quite, we have no guarantee that (1,1) is being taken into account, since the default behaviour (touching the center of the element) and tapping at (1,1) is indistinguishable, so if we break coordinate-based longPress, we wouldn't know it.

A good test for this is to tap an element which is at a particular point, and is not near the center of the element you are tapping. To do this, I would add a button on the test page which is at (0, 30) for example, and add a 'touchstart' and 'contextmenu' listener on it. To dispatch the long press, you would use the 'body' element as the target, with (0,30) as the offset. Since 'body' is the parent of this new element, the touch event will propagate to the button, so your listeners should be fired.

These tests use testAction.html (https://mxr.mozilla.org/mozilla-central/source/testing/marionette/client/marionette/www/testAction.html?raw=1) as their test page, so what you can do is something like:

body = marionette.find_element("tag name", "body")
button = marionette.find_element("id", "myNewButton")
actions.long_press(body, 5, button.location['x'], button.location['y'])
Hi Malini, 

Thanks for the clear explanation. I'll see what I can do.
Comment on attachment 8434840 [details] [diff] [review]
Add option parameters x and y to Action.long_press()

Review of attachment 8434840 [details] [diff] [review]:
-----------------------------------------------------------------

clearing flag
Attachment #8434840 - Flags: review?(mdas)
Add test cases in test_single_finger.py and test_single_finger_desktop.py.

Try (Mnw, Gu): https://tbpl.mozilla.org/?tree=Try&rev=77a0f5cdb2d4
Try (Mn): https://tbpl.mozilla.org/?tree=Try&rev=8397ecb4e3dc
Attachment #8434840 - Attachment is obsolete: true
Attachment #8436413 - Flags: review?(mdas)
Comment on attachment 8436413 [details] [diff] [review]
Add optional parameters x and y to Action.long_press() (v2)

Review of attachment 8436413 [details] [diff] [review]:
-----------------------------------------------------------------

this looks perfect, thanks for doing this!
Attachment #8436413 - Flags: review?(mdas) → review+
It's good to see this reviewed and merged in the morning.
https://hg.mozilla.org/mozilla-central/rev/ca3b94cfe665
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: