mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 13:25:37 +00:00
Bug 1085558 - test_single_finger*.py tests should output the actual value if assertion fails, r=jgriffin
This commit is contained in:
parent
e57f853968
commit
7c13a60188
@ -1,4 +1,12 @@
|
||||
from marionette import Actions
|
||||
from errors import TimeoutException
|
||||
|
||||
def wait_for_condition_else_raise(marionette, wait_for_condition, expected, script):
|
||||
try:
|
||||
wait_for_condition(lambda m: expected in m.execute_script(script))
|
||||
except TimeoutException as e:
|
||||
raise TimeoutException(e.msg + " got %s instead of %s" % (marionette.execute_script(script), expected))
|
||||
|
||||
def press_release(marionette, times, wait_for_condition, expected):
|
||||
testAction = marionette.absolute_url("testAction.html")
|
||||
marionette.navigate(testAction)
|
||||
@ -10,7 +18,7 @@ def press_release(marionette, times, wait_for_condition, expected):
|
||||
action.wait(0.1)
|
||||
action.press(button).release()
|
||||
action.perform()
|
||||
wait_for_condition(lambda m: expected in m.execute_script("return document.getElementById('button1').innerHTML;"))
|
||||
wait_for_condition_else_raise(marionette, wait_for_condition, expected, "return document.getElementById('button1').innerHTML;")
|
||||
|
||||
def move_element(marionette, wait_for_condition, expected1, expected2):
|
||||
testAction = marionette.absolute_url("testAction.html")
|
||||
@ -20,8 +28,8 @@ def move_element(marionette, wait_for_condition, expected1, expected2):
|
||||
action = Actions(marionette)
|
||||
action.press(ele).move(drop).release()
|
||||
action.perform()
|
||||
wait_for_condition(lambda m: expected1 in m.execute_script("return document.getElementById('button1').innerHTML;"))
|
||||
wait_for_condition(lambda m: expected2 in m.execute_script("return document.getElementById('button2').innerHTML;"))
|
||||
wait_for_condition_else_raise(marionette, wait_for_condition, expected1, "return document.getElementById('button1').innerHTML;")
|
||||
wait_for_condition_else_raise(marionette, wait_for_condition, expected2, "return document.getElementById('button2').innerHTML;")
|
||||
|
||||
def move_element_offset(marionette, wait_for_condition, expected1, expected2):
|
||||
testAction = marionette.absolute_url("testAction.html")
|
||||
@ -30,8 +38,8 @@ def move_element_offset(marionette, wait_for_condition, expected1, expected2):
|
||||
action = Actions(marionette)
|
||||
action.press(ele).move_by_offset(0,150).move_by_offset(0, 150).release()
|
||||
action.perform()
|
||||
wait_for_condition(lambda m: expected1 in m.execute_script("return document.getElementById('button1').innerHTML;"))
|
||||
wait_for_condition(lambda m: expected2 in m.execute_script("return document.getElementById('button2').innerHTML;"))
|
||||
wait_for_condition_else_raise(marionette, wait_for_condition, expected1, "return document.getElementById('button1').innerHTML;")
|
||||
wait_for_condition_else_raise(marionette, wait_for_condition, expected2, "return document.getElementById('button2').innerHTML;")
|
||||
|
||||
def chain(marionette, wait_for_condition, expected1, expected2):
|
||||
testAction = marionette.absolute_url("testAction.html")
|
||||
@ -41,9 +49,9 @@ def chain(marionette, wait_for_condition, expected1, expected2):
|
||||
button1 = marionette.find_element("id", "button1")
|
||||
action.press(button1).perform()
|
||||
button2 = marionette.find_element("id", "delayed")
|
||||
wait_for_condition(lambda m: expected1 in m.execute_script("return document.getElementById('button1').innerHTML;"))
|
||||
wait_for_condition_else_raise(marionette, wait_for_condition, expected1, "return document.getElementById('button1').innerHTML;")
|
||||
action.move(button2).release().perform()
|
||||
wait_for_condition(lambda m: expected2 in m.execute_script("return document.getElementById('delayed').innerHTML;"))
|
||||
wait_for_condition_else_raise(marionette, wait_for_condition, expected2, "return document.getElementById('delayed').innerHTML;")
|
||||
|
||||
def chain_flick(marionette, wait_for_condition, expected1, expected2):
|
||||
testAction = marionette.absolute_url("testAction.html")
|
||||
@ -51,8 +59,8 @@ def chain_flick(marionette, wait_for_condition, expected1, expected2):
|
||||
button = marionette.find_element("id", "button1")
|
||||
action = Actions(marionette)
|
||||
action.flick(button, 0, 0, 0, 200).perform()
|
||||
wait_for_condition(lambda m: expected1 in m.execute_script("return document.getElementById('button1').innerHTML;"))
|
||||
wait_for_condition(lambda m: expected2 in m.execute_script("return document.getElementById('buttonFlick').innerHTML;"))
|
||||
wait_for_condition_else_raise(marionette, wait_for_condition, expected1,"return document.getElementById('button1').innerHTML;")
|
||||
wait_for_condition_else_raise(marionette, wait_for_condition, expected2,"return document.getElementById('buttonFlick').innerHTML;")
|
||||
|
||||
|
||||
def wait(marionette, wait_for_condition, expected):
|
||||
@ -61,7 +69,7 @@ def wait(marionette, wait_for_condition, expected):
|
||||
action = Actions(marionette)
|
||||
button = marionette.find_element("id", "button1")
|
||||
action.press(button).wait().release().perform()
|
||||
wait_for_condition(lambda m: expected in m.execute_script("return document.getElementById('button1').innerHTML;"))
|
||||
wait_for_condition_else_raise(marionette, wait_for_condition, expected, "return document.getElementById('button1').innerHTML;")
|
||||
|
||||
def wait_with_value(marionette, wait_for_condition, expected):
|
||||
testAction = marionette.absolute_url("testAction.html")
|
||||
@ -70,7 +78,7 @@ def wait_with_value(marionette, wait_for_condition, expected):
|
||||
action = Actions(marionette)
|
||||
action.press(button).wait(0.01).release()
|
||||
action.perform()
|
||||
wait_for_condition(lambda m: expected in m.execute_script("return document.getElementById('button1').innerHTML;"))
|
||||
wait_for_condition_else_raise(marionette, wait_for_condition, expected, "return document.getElementById('button1').innerHTML;")
|
||||
|
||||
def context_menu(marionette, wait_for_condition, expected1, expected2):
|
||||
testAction = marionette.absolute_url("testAction.html")
|
||||
@ -78,9 +86,9 @@ def context_menu(marionette, wait_for_condition, expected1, expected2):
|
||||
button = marionette.find_element("id", "button1")
|
||||
action = Actions(marionette)
|
||||
action.press(button).wait(5).perform()
|
||||
wait_for_condition(lambda m: expected1 in m.execute_script("return document.getElementById('button1').innerHTML;"))
|
||||
wait_for_condition_else_raise(marionette, wait_for_condition, expected1, "return document.getElementById('button1').innerHTML;")
|
||||
action.release().perform()
|
||||
wait_for_condition(lambda m: expected2 in m.execute_script("return document.getElementById('button1').innerHTML;"))
|
||||
wait_for_condition_else_raise(marionette, wait_for_condition, expected2, "return document.getElementById('button1').innerHTML;")
|
||||
|
||||
def long_press_action(marionette, wait_for_condition, expected):
|
||||
testAction = marionette.absolute_url("testAction.html")
|
||||
@ -88,7 +96,7 @@ def long_press_action(marionette, wait_for_condition, expected):
|
||||
button = marionette.find_element("id", "button1")
|
||||
action = Actions(marionette)
|
||||
action.long_press(button, 5).perform()
|
||||
wait_for_condition(lambda m: expected in m.execute_script("return document.getElementById('button1').innerHTML;"))
|
||||
wait_for_condition_else_raise(marionette, wait_for_condition, expected, "return document.getElementById('button1').innerHTML;")
|
||||
|
||||
def long_press_on_xy_action(marionette, wait_for_condition, expected):
|
||||
testAction = marionette.absolute_url("testAction.html")
|
||||
@ -101,7 +109,7 @@ def long_press_on_xy_action(marionette, wait_for_condition, expected):
|
||||
x = button.rect['x'] + button.rect['width'] / 2.0
|
||||
y = button.rect['y'] + button.rect['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;"))
|
||||
wait_for_condition_else_raise(marionette, wait_for_condition, expected, "return document.getElementById('button1').innerHTML;")
|
||||
|
||||
def single_tap(marionette, wait_for_condition, expected):
|
||||
testAction = marionette.absolute_url("testAction.html")
|
||||
@ -109,7 +117,7 @@ def single_tap(marionette, wait_for_condition, expected):
|
||||
button = marionette.find_element("id", "button1")
|
||||
action = Actions(marionette)
|
||||
action.tap(button).perform()
|
||||
wait_for_condition(lambda m: expected in m.execute_script("return document.getElementById('button1').innerHTML;"))
|
||||
wait_for_condition_else_raise(marionette, wait_for_condition, expected, "return document.getElementById('button1').innerHTML;")
|
||||
|
||||
def double_tap(marionette, wait_for_condition, expected):
|
||||
testAction = marionette.absolute_url("testAction.html")
|
||||
@ -117,4 +125,4 @@ def double_tap(marionette, wait_for_condition, expected):
|
||||
button = marionette.find_element("id", "button1")
|
||||
action = Actions(marionette)
|
||||
action.double_tap(button).perform()
|
||||
wait_for_condition(lambda m: expected in m.execute_script("return document.getElementById('button1').innerHTML;"))
|
||||
wait_for_condition_else_raise(marionette, wait_for_condition, expected, "return document.getElementById('button1').innerHTML;")
|
||||
|
Loading…
Reference in New Issue
Block a user