testing/marionette/harness/marionette/tests/unit/test_multi_finger.py
author Andreas Tolfsen <ato@mozilla.com>
Sat, 06 Feb 2016 17:34:10 +0000
changeset 285593 29caf02c0eb04ae7703b6dc18a6949ab74fae102
parent 274360 testing/marionette/client/marionette/tests/unit/test_multi_finger.py@238dd6c3aef79b5aa530312c6b6762099e7d7eed
child 289018 31c47d3ac2bb7c199abadbbfa09f786411fd3faa
permissions -rw-r--r--
Bug 1246407 - Rename parent directories for Marionette client and test harness; r=automatedtester This change moves testing/marionette/client to testing/marionette/harness, and testing/marionette/driver to testing/marionette/client. This parent directory name change reflects the true purpose of these Python packages. MozReview-Commit-ID: B0KrGzDTLlQ

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from marionette import MarionetteTestCase
from marionette_driver.marionette import MultiActions, Actions

class testMultiFinger(MarionetteTestCase):
    def test_move_element(self):
      testAction = self.marionette.absolute_url("testAction.html")
      self.marionette.navigate(testAction)
      start = self.marionette.find_element("id", "button1")
      drop = self.marionette.find_element("id", "button2")
      ele = self.marionette.find_element("id", "button3")
      multi_action = MultiActions(self.marionette)
      action1 = Actions(self.marionette)
      action2 = Actions(self.marionette)
      action1.press(start).move(drop).wait(3).release()
      action2.press(ele).wait().release()
      multi_action.add(action1).add(action2).perform()
      expected = "button1-touchstart"
      self.wait_for_condition(lambda m: m.execute_script("return document.getElementById('button1').innerHTML;") == expected)
      self.assertEqual("button2-touchmove-touchend", self.marionette.execute_script("return document.getElementById('button2').innerHTML;"))
      self.assertTrue("button3-touchstart-touchend" in self.marionette.execute_script("return document.getElementById('button3').innerHTML;"))

    def test_move_offset_element(self):
      testAction = self.marionette.absolute_url("testAction.html")
      self.marionette.navigate(testAction)
      start = self.marionette.find_element("id", "button1")
      ele = self.marionette.find_element("id", "button3")
      multi_action = MultiActions(self.marionette)
      action1 = Actions(self.marionette)
      action2 = Actions(self.marionette)
      action1.press(start).move_by_offset(0,300).wait().release()
      action2.press(ele).wait(5).release()
      multi_action.add(action1).add(action2).perform()
      expected = "button1-touchstart"
      self.wait_for_condition(lambda m: m.execute_script("return document.getElementById('button1').innerHTML;") == expected)
      self.assertEqual("button2-touchmove-touchend", self.marionette.execute_script("return document.getElementById('button2').innerHTML;"))
      self.assertTrue("button3-touchstart-touchend" in self.marionette.execute_script("return document.getElementById('button3').innerHTML;"))

    def test_three_fingers(self):
      testAction = self.marionette.absolute_url("testAction.html")
      self.marionette.navigate(testAction)
      start_one = self.marionette.find_element("id", "button1")
      start_two = self.marionette.find_element("id", "button2")
      element1 = self.marionette.find_element("id", "button3")
      element2 = self.marionette.find_element("id", "button4")
      multi_action = MultiActions(self.marionette)
      action1 = Actions(self.marionette)
      action2 = Actions(self.marionette)
      action3 = Actions(self.marionette)
      action1.press(start_one).move_by_offset(0,300).release()
      action2.press(element1).wait().wait(5).release()
      action3.press(element2).wait().wait().release()
      multi_action.add(action1).add(action2).add(action3).perform()
      expected = "button1-touchstart"
      self.wait_for_condition(lambda m: m.execute_script("return document.getElementById('button1').innerHTML;") == expected)
      self.assertEqual("button2-touchmove-touchend", self.marionette.execute_script("return document.getElementById('button2').innerHTML;"))
      button3_text = self.marionette.execute_script("return document.getElementById('button3').innerHTML;")
      button4_text = self.marionette.execute_script("return document.getElementById('button4').innerHTML;")
      self.assertTrue("button3-touchstart-touchend" in button3_text)
      self.assertTrue("button4-touchstart-touchend" in button4_text)
      self.assertTrue(int(button3_text.rsplit("-")[-1]) >= 5000)
      self.assertTrue(int(button4_text.rsplit("-")[-1]) >= 5000)