Bug 1092888 - Part 5: Add a parameter to toggle context menu when calling long_press. r=mdas

This commit is contained in:
Morris Tseng 2014-11-16 18:52:00 +01:00
parent 00b6c7e47f
commit 23a9b24a2e
3 changed files with 17 additions and 7 deletions

View File

@ -7,6 +7,7 @@ from by import By
from marionette import Actions
from marionette_test import MarionetteTestCase
from selection import SelectionManager
from gestures import long_press_without_contextmenu
class SelectionCaretsTest(MarionetteTestCase):
@ -48,7 +49,7 @@ class SelectionCaretsTest(MarionetteTestCase):
# Long press the caret position. Selection carets should appear, and the
# first word will be selected. On Windows, those spaces after the word
# will also be selected.
self.actions.long_press(el, self._long_press_time, x, y).perform()
long_press_without_contextmenu(self.marionette, el, self._long_press_time, x, y)
def _test_long_press_to_select_a_word(self, el, assertFunc):
sel = SelectionManager(el)

View File

@ -7,6 +7,7 @@ from by import By
from marionette import Actions
from marionette_test import MarionetteTestCase
from selection import SelectionManager
from gestures import long_press_without_contextmenu
class SelectionCaretsMultipleRangeTest(MarionetteTestCase):
@ -36,10 +37,6 @@ class SelectionCaretsMultipleRangeTest(MarionetteTestCase):
self._sel6 = self.marionette.find_element(By.ID, 'sel6')
self._nonsel1 = self.marionette.find_element(By.ID, 'nonsel1')
def _long_press_without_contextmenu(self, el, x, y):
return self.actions.press(el, x, y).move_by_offset(0, 0).\
wait(self._long_press_time).release()
def _long_press_to_select_word(self, el, wordOrdinal):
sel = SelectionManager(el)
original_content = sel.content
@ -61,7 +58,7 @@ class SelectionCaretsMultipleRangeTest(MarionetteTestCase):
# Long press the caret position. Selection carets should appear, and the
# word will be selected. On Windows, those spaces after the word
# will also be selected.
self._long_press_without_contextmenu(el, x, y).perform()
long_press_without_contextmenu(self.marionette, el, self._long_press_time, x, y)
def _to_unix_line_ending(self, s):
"""Changes all Windows/Mac line endings in s to UNIX line endings."""
@ -74,7 +71,7 @@ class SelectionCaretsMultipleRangeTest(MarionetteTestCase):
self.openTestHtml(enabled=True)
halfY = self._nonsel1.size['height'] / 2
self._long_press_without_contextmenu(self._nonsel1, 0, halfY).perform()
long_press_without_contextmenu(self.marionette, self._nonsel1, self._long_press_time, 0, halfY)
sel = SelectionManager(self._nonsel1)
range_count = sel.range_count()
self.assertEqual(range_count, 0)

View File

@ -69,3 +69,15 @@ def pinch(marionette_session, element, x1, y1, x2, y2, x3, y3, x4, y4, duration=
action1.release()
action2.release()
multiAction.add(action1).add(action2).perform()
#element: The element to press.
#time_in_seconds: Time in seconds to wait before releasing the press.
#x: Optional, x-coordinate to tap, relative to the top-left corner of the element.
#y: Optional, y-coordinate to tap, relative to the top-leftcorner of the element.
def long_press_without_contextmenu(marionette_session, element, time_in_seconds, x=None, y=None):
action = Actions(marionette_session)
action.press(element, x, y)
action.move_by_offset(0, 0)
action.wait(time_in_seconds)
action.release()
action.perform()