Bug 962645 - Support wait between press->release action chain. r=mdas, a=test-only
authorTing-Yu Lin <tlin@mozilla.com>
Thu, 12 Jun 2014 02:34:00 -0400
changeset 208310 42f48cdb1833cb120a5ec194141a920e983c1f09
parent 208309 b1ee18fd4e5048e9c74cd1c82d6df0d6309388f5
child 208311 5255d6bba70da18420c2903c12998f93670e7472
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmdas, test-only
bugs962645
milestone32.0a2
Bug 962645 - Support wait between press->release action chain. r=mdas, a=test-only wait() before press() should not raise "MarionetteException: Element has not been pressed."
testing/marionette/client/marionette/tests/unit/single_finger_functions.py
testing/marionette/client/marionette/tests/unit/test_single_finger.py
testing/marionette/client/marionette/tests/unit/test_single_finger_desktop.py
testing/marionette/marionette-listener.js
--- a/testing/marionette/client/marionette/tests/unit/single_finger_functions.py
+++ b/testing/marionette/client/marionette/tests/unit/single_finger_functions.py
@@ -1,15 +1,20 @@
 from marionette import Actions
-def press_release(marionette, wait_for_condition, expected):
+def press_release(marionette, times, wait_for_condition, expected):
     testAction = marionette.absolute_url("testAction.html")
     marionette.navigate(testAction)
     action = Actions(marionette)
     button = marionette.find_element("id", "button1")
-    action.press(button).release().perform()
+    action.press(button).release()
+    # Insert wait between each press and release chain.
+    for _ in range(times-1):
+        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;"))
 
 def move_element(marionette, wait_for_condition, expected1, expected2):
     testAction = marionette.absolute_url("testAction.html")
     marionette.navigate(testAction)
     ele = marionette.find_element("id", "button1")
     drop = marionette.find_element("id", "button2")
     action = Actions(marionette)
--- a/testing/marionette/client/marionette/tests/unit/test_single_finger.py
+++ b/testing/marionette/client/marionette/tests/unit/test_single_finger.py
@@ -13,17 +13,20 @@ from single_finger_functions import (
         chain, chain_flick, context_menu, double_tap, long_press_action,
         move_element, move_element_offset, press_release, single_tap, wait,
         wait_with_value
         )
 
 
 class testSingleFinger(MarionetteTestCase):
     def test_press_release(self):
-        press_release(self.marionette, self.wait_for_condition, "button1-touchstart-touchend-mousemove-mousedown-mouseup-click")
+        press_release(self.marionette, 1, self.wait_for_condition, "button1-touchstart-touchend-mousemove-mousedown-mouseup-click")
+
+    def test_press_release_twice(self):
+        press_release(self.marionette, 2, self.wait_for_condition, "button1-touchstart-touchend-mousemove-mousedown-mouseup-click-touchstart-touchend-mousemove-mousedown-mouseup-click")
 
     def test_move_element(self):
         move_element(self.marionette, self.wait_for_condition, "button1-touchstart", "button2-touchmove-touchend")
 
     """
     #Skipping due to Bug 874914
     def test_move_by_offset(self):
         move_element_offset(self.marionette, self.wait_for_condition, "button1-touchstart", "button2-touchmove-touchend")
--- a/testing/marionette/client/marionette/tests/unit/test_single_finger_desktop.py
+++ b/testing/marionette/client/marionette/tests/unit/test_single_finger_desktop.py
@@ -53,17 +53,20 @@ prefs.setBoolPref("ui.click_hold_context
 let prefs = Components.classes["@mozilla.org/preferences-service;1"]
                               .getService(Components.interfaces.nsIPrefBranch);
 prefs.setIntPref("ui.click_hold_context_menus.delay", arguments[0]);
 """, [self.wait_time])
         self.marionette.set_context("content")
         super(MarionetteTestCase, self).tearDown()
 
     def test_press_release(self):
-        press_release(self.marionette, self.wait_for_condition, "button1-mousemove-mousedown-mouseup-click")
+        press_release(self.marionette, 1, self.wait_for_condition, "button1-mousemove-mousedown-mouseup-click")
+
+    def test_press_release_twice(self):
+        press_release(self.marionette, 2, self.wait_for_condition, "button1-mousemove-mousedown-mouseup-click-mousemove-mousedown-mouseup-click")
 
     def test_move_element(self):
         move_element(self.marionette, self.wait_for_condition, "button1-mousemove-mousedown", "button2-mousemove-mouseup")
 
     def test_move_by_offset(self):
         move_element_offset(self.marionette, self.wait_for_condition, "button1-mousemove-mousedown", "button2-mousemove-mouseup")
 
     def test_wait(self):
--- a/testing/marionette/marionette-listener.js
+++ b/testing/marionette/marionette-listener.js
@@ -961,17 +961,17 @@ function actions(chain, touchId, command
     sendResponse({value: touchId}, command_id);
     return;
   }
   let pack = chain[i];
   let command = pack[0];
   let el;
   let c;
   i++;
-  if (command != 'press') {
+  if (command != 'press' && command != 'wait') {
     //if mouseEventsOnly, then touchIds isn't used
     if (!(touchId in touchIds) && !mouseEventsOnly) {
       sendError("Element has not been pressed", 500, null, command_id);
       return;
     }
   }
   switch(command) {
     case 'press':