Commit 0b58324a authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Add pause action for key and pointer source types

In Webdriver spec, it has an example:
https://www.w3.org/TR/webdriver/#example-11
that the source has a pause action, which means that the
source does not have any action at this tick. Currently we only have
a pause action for none source type, we should have the pause action
for the key and pointer types as well as per web driver spec:
https://www.w3.org/TR/webdriver/#dfn-pause

For example:
let actions = new test_driver.Actions()
      .addPointer("touchPointer1", "touch")
      .addPointer("touchPointer2", "touch")
      .pointerMove(10, 0, {origin: test1, sourceName: "touchPointer2"})
      .pointerMove(0, 0, {origin: test1, sourceName: "touchPointer1"})
      .pointerDown({sourceName: "touchPointer1"})
      .pointerDown({sourceName: "touchPointer2"})
      .pause(0, "pointer", {sourceName: "touchPointer1"})
      .pointerMove(0, 10, {origin: test1, sourceName: "touchPointer2"})
      .pointerUp({sourceName: "touchPointer1"})
      .pointerUp({sourceName: "touchPointer2"});


Bug: 1020674
Change-Id: Iacd2811a91bc26d273cd9589a96e0a377941d79c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900650Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Reviewed-by: default avatarLan Wei <lanwei@chromium.org>
Commit-Queue: Lan Wei <lanwei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714370}
parent 7679d0e0
...@@ -195,10 +195,16 @@ ...@@ -195,10 +195,16 @@
* Add a pause to the current tick * Add a pause to the current tick
* *
* @param {Number?} duration - Minimum length of the tick in ms. * @param {Number?} duration - Minimum length of the tick in ms.
* @param {String} sourceType - source type
* @param {String?} sourceName - Named key or pointer source to use or null for the default
* key or pointer source
* @returns {Actions} * @returns {Actions}
*/ */
pause: function(duration) { pause: function(duration=0, sourceType="none", {sourceName=null}={}) {
this.getSource("none").addPause(this, duration); if (sourceType=="none")
this.getSource("none").addPause(this, duration);
else
this.getSource(sourceType, sourceName).addPause(this, duration);
return this; return this;
}, },
...@@ -339,6 +345,14 @@ ...@@ -339,6 +345,14 @@
} }
this.actions.set(tick, {type: "keyUp", value: key}); this.actions.set(tick, {type: "keyUp", value: key});
}, },
addPause: function(actions, duration) {
let tick = actions.tickIdx;
if (this.actions.has(tick)) {
tick = actions.addTick().tickIdx;
}
this.actions.set(tick, {type: "pause", duration: duration});
},
}; };
function PointerSource(parameters={pointerType: "mouse"}) { function PointerSource(parameters={pointerType: "mouse"}) {
...@@ -393,6 +407,14 @@ ...@@ -393,6 +407,14 @@
this.actions.get(tick).duration = duration; this.actions.get(tick).duration = duration;
} }
}, },
addPause: function(actions, duration) {
let tick = actions.tickIdx;
if (this.actions.has(tick)) {
tick = actions.addTick().tickIdx;
}
this.actions.set(tick, {type: "pause", duration: duration});
},
}; };
test_driver.Actions = Actions; test_driver.Actions = Actions;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment