зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1020874 - Add optional parameters x and y to Action.long_press(). r=mdas
* Action.long_press() now accepts optional parameters x and y as Action.press() does. * Add test cases in test_single_finger.py and test_single_finger_desktop.py.
This commit is contained in:
Родитель
43ebf8cc06
Коммит
00e1877d13
|
@ -365,15 +365,26 @@ class Actions(object):
|
|||
self.action_chain.append(['release'])
|
||||
return self
|
||||
|
||||
def long_press(self, element, time_in_seconds):
|
||||
def long_press(self, element, time_in_seconds, x=None, y=None):
|
||||
'''
|
||||
Performs a long press gesture on the target element.
|
||||
|
||||
:param element: The element to press.
|
||||
:param time_in_seconds: Time in seconds to wait before releasing the press.
|
||||
:param x: Optional, x-coordinate to tap, relative to the top-left
|
||||
corner of the element.
|
||||
:param y: Optional, y-coordinate to tap, relative to the top-left
|
||||
corner of the element.
|
||||
|
||||
This is equivalent to calling:
|
||||
|
||||
::
|
||||
|
||||
action.press(element, x, y).wait(time_in_seconds).release()
|
||||
|
||||
'''
|
||||
element = element.id
|
||||
self.action_chain.append(['press', element])
|
||||
self.action_chain.append(['press', element, x, y])
|
||||
self.action_chain.append(['wait', time_in_seconds])
|
||||
self.action_chain.append(['release'])
|
||||
return self
|
||||
|
@ -1398,7 +1409,7 @@ class Marionette(object):
|
|||
|
||||
:param highlights: A list of HTMLElement objects to draw a red
|
||||
box around in the returned screenshot.
|
||||
|
||||
|
||||
:param format: if "base64" (the default), returns the screenshot
|
||||
as a base64-string. If "binary", the data is decoded and
|
||||
returned as raw binary.
|
||||
|
|
|
@ -85,6 +85,19 @@ def long_press_action(marionette, wait_for_condition, expected):
|
|||
action.long_press(button, 5).perform()
|
||||
wait_for_condition(lambda m: expected in m.execute_script("return document.getElementById('button1').innerHTML;"))
|
||||
|
||||
def long_press_on_xy_action(marionette, wait_for_condition, expected):
|
||||
testAction = marionette.absolute_url("testAction.html")
|
||||
marionette.navigate(testAction)
|
||||
html = marionette.find_element("tag name", "html")
|
||||
button = marionette.find_element("id", "button1")
|
||||
action = Actions(marionette)
|
||||
|
||||
# Press the center of the button with respect to html.
|
||||
x = button.location['x'] + button.size['width'] / 2.0
|
||||
y = button.location['y'] + button.size['height'] / 2.0
|
||||
action.long_press(html, 5, x, y).perform()
|
||||
wait_for_condition(lambda m: expected in m.execute_script("return document.getElementById('button1').innerHTML;"))
|
||||
|
||||
def single_tap(marionette, wait_for_condition, expected):
|
||||
testAction = marionette.absolute_url("testAction.html")
|
||||
marionette.navigate(testAction)
|
||||
|
|
|
@ -10,7 +10,8 @@ import os
|
|||
import sys
|
||||
sys.path.append(os.path.dirname(__file__))
|
||||
from single_finger_functions import (
|
||||
chain, chain_flick, context_menu, double_tap, long_press_action,
|
||||
chain, chain_flick, context_menu, double_tap,
|
||||
long_press_action, long_press_on_xy_action,
|
||||
move_element, move_element_offset, press_release, single_tap, wait,
|
||||
wait_with_value
|
||||
)
|
||||
|
@ -48,6 +49,9 @@ class testSingleFinger(MarionetteTestCase):
|
|||
def test_long_press_action(self):
|
||||
long_press_action(self.marionette, self.wait_for_condition, "button1-touchstart-contextmenu-touchend")
|
||||
|
||||
def test_long_press_on_xy_action(self):
|
||||
long_press_on_xy_action(self.marionette, self.wait_for_condition, "button1-touchstart-touchend")
|
||||
|
||||
"""
|
||||
#Skipping due to Bug 865334
|
||||
def test_long_press_fail(self):
|
||||
|
@ -86,4 +90,3 @@ class testSingleFinger(MarionetteTestCase):
|
|||
|
||||
def test_double_tap(self):
|
||||
double_tap(self.marionette, self.wait_for_condition, "button1-touchstart-touchend-mousemove-mousedown-mouseup-click-touchstart-touchend-mousemove-mousedown-mouseup-click")
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@ import os
|
|||
import sys
|
||||
sys.path.append(os.path.dirname(__file__))
|
||||
from single_finger_functions import (
|
||||
chain, chain_flick, context_menu, double_tap, long_press_action,
|
||||
chain, chain_flick, context_menu, double_tap,
|
||||
long_press_action, long_press_on_xy_action,
|
||||
move_element, move_element_offset, press_release, single_tap, wait,
|
||||
wait_with_value
|
||||
)
|
||||
|
@ -78,6 +79,9 @@ prefs.setIntPref("ui.click_hold_context_menus.delay", arguments[0]);
|
|||
def test_long_press_action(self):
|
||||
long_press_action(self.marionette, self.wait_for_condition, "button1-mousemove-mousedown-contextmenu-mouseup-click")
|
||||
|
||||
def test_long_press_on_xy_action(self):
|
||||
long_press_on_xy_action(self.marionette, self.wait_for_condition, "button1-mousemove-mousedown-contextmenu-mouseup-click")
|
||||
|
||||
"""
|
||||
//Skipping due to Bug 865334
|
||||
def test_long_press_fail(self):
|
||||
|
|
Загрузка…
Ссылка в новой задаче