Bug 1575617 [wpt PR 18596] - Add tick duration argument to testdriver Action, a=testonly
authorLan Wei <lanwei@chromium.org>
Mon, 02 Sep 2019 12:24:33 +0000
changeset 491494 aa867e002896c51373b15de5002ef97e2613440d
parent 491493 5684776f3a133d6bf88bc665242cf4510a49cd37
child 491495 62be6c754dadbaeee6ffc9ec412c3114c552ae86
push id36529
push useraiakab@mozilla.com
push dateTue, 03 Sep 2019 21:56:23 +0000
treeherdermozilla-central@fd891e83a7cd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1575617, 18596, 606367, 1762836, 691186
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1575617 [wpt PR 18596] - Add tick duration argument to testdriver Action, a=testonly Automatic update from web-platform-tests Add tick duration argument to testdriver Action We want to allow the users to define the duration for every tick, so we add an argument to Action class which will be a duration for all ticks. If there is a tick which need a different duration, we can call addTick or pause to pass a different value. Bug: 606367 Change-Id: I7e5d88557f5f4a4c63dbf85985c30881aee9f739 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1762836 Reviewed-by: Navid Zolghadr <nzolghadr@chromium.org> Commit-Queue: Lan Wei <lanwei@chromium.org> Cr-Commit-Position: refs/heads/master@{#691186} -- wpt-commits: c417f6d8f332d8c0f35bb67e9c58c0cfeb4ce291 wpt-pr: 18596
testing/web-platform/tests/resources/testdriver-actions.js
--- a/testing/web-platform/tests/resources/testdriver-actions.js
+++ b/testing/web-platform/tests/resources/testdriver-actions.js
@@ -1,29 +1,32 @@
 (function() {
   let sourceNameIdx = 0;
 
   /**
    * Builder for creating a sequence of actions
+   * The default tick duration is set to 32ms, which is 2 frame time based on
+   * 60Hz display.
    */
-  function Actions() {
+  function Actions(defaultTickDuration=32) {
     this.sourceTypes = new Map([["key", KeySource],
                                 ["pointer", PointerSource],
                                 ["none", GeneralSource]]);
     this.sources = new Map();
     this.sourceOrder = [];
     for (let sourceType of this.sourceTypes.keys()) {
       this.sources.set(sourceType, new Map());
     }
     this.currentSources = new Map();
     for (let sourceType of this.sourceTypes.keys()) {
       this.currentSources.set(sourceType, null);
     }
     this.createSource("none");
     this.tickIdx = 0;
+    this.defaultTickDuration = defaultTickDuration;
   }
 
   Actions.prototype = {
     ButtonType: {
       LEFT: 0,
       MIDDLE: 1,
       RIGHT: 2,
       BACK: 3,
@@ -35,17 +38,17 @@
      * test_driver.action_sequence
      *
      * @returns {Array} Array of WebDriver-compatible actions sequences
      */
     serialize: function() {
       let actions = [];
       for (let [sourceType, sourceName] of this.sourceOrder) {
         let source = this.sources.get(sourceType).get(sourceName);
-        let serialized = source.serialize(this.tickIdx + 1);
+        let serialized = source.serialize(this.tickIdx + 1, this.defaultTickDuration);
         if (serialized) {
           serialized.id = sourceName;
           actions.push(serialized);
         }
       }
       return actions;
     },
 
@@ -273,27 +276,24 @@
     },
   };
 
   function GeneralSource() {
     this.actions = new Map();
   }
 
   GeneralSource.prototype = {
-    serialize: function(tickCount) {
-      if (!this.actions.size) {
-        return undefined;
-      }
+    serialize: function(tickCount, defaultTickDuration) {
       let actions = [];
       let data = {"type": "none", "actions": actions};
       for (let i=0; i<tickCount; i++) {
         if (this.actions.has(i)) {
           actions.push(this.actions.get(i));
         } else {
-          actions.push({"type": "pause"});
+          actions.push({"type": "pause", duration: defaultTickDuration});
         }
       }
       return data;
     },
 
     addPause: function(actions, duration) {
       let tick = actions.tickIdx;
       if (this.actions.has(tick)) {