зеркало из https://github.com/mozilla/gecko-dev.git
Bug 858563 - Add 'long_press' to Action chains, r=mdas
This commit is contained in:
Родитель
7d4feba80c
Коммит
4c7c9058f1
|
@ -139,6 +139,13 @@ class Actions(object):
|
|||
self.action_chain.append(['cancel'])
|
||||
return self
|
||||
|
||||
def long_press(self, element, time_in_seconds):
|
||||
element = element.id
|
||||
self.action_chain.append(['press', element])
|
||||
self.action_chain.append(['wait', time_in_seconds])
|
||||
self.action_chain.append(['release'])
|
||||
return self
|
||||
|
||||
def perform(self):
|
||||
self.current_id = self.marionette._send_message('actionChain', 'value', chain=self.action_chain, nextId=self.current_id)
|
||||
self.action_chain = []
|
||||
|
|
|
@ -33,11 +33,6 @@ class MarionetteTouchMixin(object):
|
|||
self.check_element(element)
|
||||
self.execute_script("%s.dbltap(arguments[0]);" % self.library_name, [element])
|
||||
|
||||
def long_press(self, element, holdtime=2000):
|
||||
self.check_element(element)
|
||||
#I'm adding holdtime, since we have support for this, and we don't have chaining yet
|
||||
self.execute_script("%s.hold.apply(this, arguments);" % self.library_name, [element, holdtime, 0, 0, 0, 0, 0])
|
||||
|
||||
def flick(self, element, x1, y1, x2, y2, duration=200):
|
||||
self.check_element(element)
|
||||
# there's 'flick' which is pixels per second, but I'd rather have the library support it than piece it together here.
|
||||
|
|
|
@ -13,7 +13,7 @@ class testSingleFinger(MarionetteTestCase):
|
|||
self.marionette.navigate(testTouch)
|
||||
button = self.marionette.find_element("id", "mozLinkCopy")
|
||||
action = Actions(self.marionette)
|
||||
action.press(button).wait(5).release()
|
||||
action.press(button).wait(0.2).release()
|
||||
action.perform()
|
||||
time.sleep(15)
|
||||
self.assertEqual("End", self.marionette.execute_script("return document.getElementById('mozLinkCopy').innerHTML;"))
|
||||
|
@ -120,7 +120,24 @@ class testSingleFinger(MarionetteTestCase):
|
|||
self.assertEqual("Context", self.marionette.execute_script("return document.getElementById('mozLinkCopy').innerHTML;"))
|
||||
action.release().perform()
|
||||
time.sleep(10)
|
||||
self.assertEqual("End", self.marionette.execute_script("return document.getElementById('mozLinkCopy').innerHTML;"))
|
||||
self.assertEqual("ContextEnd", self.marionette.execute_script("return document.getElementById('mozLinkCopy').innerHTML;"))
|
||||
|
||||
def test_long_press_action(self):
|
||||
testTouch = self.marionette.absolute_url("testAction.html")
|
||||
self.marionette.navigate(testTouch)
|
||||
button = self.marionette.find_element("id", "mozLinkCopy")
|
||||
action = Actions(self.marionette)
|
||||
action.long_press(button, 5).perform()
|
||||
time.sleep(10)
|
||||
self.assertEqual("ContextEnd", self.marionette.execute_script("return document.getElementById('mozLinkCopy').innerHTML;"))
|
||||
|
||||
def test_long_press_fail(self):
|
||||
testTouch = self.marionette.absolute_url("testAction.html")
|
||||
self.marionette.navigate(testTouch)
|
||||
button = self.marionette.find_element("id", "mozLinkCopy")
|
||||
action = Actions(self.marionette)
|
||||
action.press(button).long_press(button, 5)
|
||||
self.assertRaises(MarionetteException, action.perform)
|
||||
|
||||
def test_wrong_value(self):
|
||||
testTouch = self.marionette.absolute_url("testAction.html")
|
||||
|
|
|
@ -182,9 +182,12 @@
|
|||
|
||||
function changeClickText(strId) {
|
||||
var second = document.getElementById(strId);
|
||||
if (second.innerHTML == "Start" || second.innerHTML == "Context") {
|
||||
if (second.innerHTML == "Start") {
|
||||
second.innerHTML = "End";
|
||||
}
|
||||
else if (second.innerHTML == "Context") {
|
||||
second.innerHTML = "ContextEnd";
|
||||
}
|
||||
else {
|
||||
second.innerHTML = "Error";
|
||||
}
|
||||
|
|
|
@ -1085,6 +1085,13 @@ function actions(finger, touchId, command_id, i){
|
|||
i++;
|
||||
switch(command) {
|
||||
case 'press':
|
||||
if (lastTouch != null) {
|
||||
touch = lastTouch;
|
||||
emitTouchEvent('touchcancel', touch);
|
||||
lastTouch = null;
|
||||
sendError("Invalid Command: long_press cannot follow an active touch event", 500, null, command_id);
|
||||
return;
|
||||
}
|
||||
el = elementManager.getKnownElement(pack[1], curWindow);
|
||||
corx = pack[2];
|
||||
cory = pack[3];
|
||||
|
|
Загрузка…
Ссылка в новой задаче