Bug 1261561 - Part 2: Add a xpcshell test for TimeScale.getAnimationDimensions(). r=pbro
authorRyo Kato <ryo_kato@hashedhyphen.com>
Tue, 05 Apr 2016 05:58:43 -0700
changeset 316097 21a9c5fb6e0cfd809ea61f452f500869d5b37e7d
parent 316096 6c1e3c4a7f49ae72260ad8826fadbf11d364c488
child 316098 675570b21decc7ff635b4f8ac009bf959ec99c7c
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbro
bugs1261561
milestone48.0a1
Bug 1261561 - Part 2: Add a xpcshell test for TimeScale.getAnimationDimensions(). r=pbro MozReview-Commit-ID: Hhwq0d21Rlw
devtools/client/animationinspector/test/unit/test_timeScale_dimensions.js
devtools/client/animationinspector/test/unit/xpcshell.ini
new file mode 100644
--- /dev/null
+++ b/devtools/client/animationinspector/test/unit/test_timeScale_dimensions.js
@@ -0,0 +1,54 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+   https://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const Cu = Components.utils;
+const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
+const {TimeScale} = require("devtools/client/animationinspector/utils");
+
+const TEST_ENDDELAY_X = [{
+  desc: "Testing positive-endDelay animations",
+  animations: [{
+    previousStartTime: 0,
+    duration: 500,
+    playbackRate: 1,
+    iterationCount: 3,
+    delay: 500,
+    endDelay: 500
+  }],
+  expectedEndDelayX: 80
+}, {
+  desc: "Testing negative-endDelay animations",
+  animations: [{
+    previousStartTime: 0,
+    duration: 500,
+    playbackRate: 1,
+    iterationCount: 9,
+    delay: 500,
+    endDelay: -500
+  }],
+  expectedEndDelayX: 90
+}];
+
+function run_test() {
+  do_print("Test calculating endDelayX");
+
+  // Be independent of possible prior tests
+  TimeScale.reset();
+
+  for (let {desc, animations, expectedEndDelayX} of TEST_ENDDELAY_X) {
+    do_print(`Adding animations: ${desc}`);
+
+    for (let state of animations) {
+      TimeScale.addAnimation(state);
+
+      let {endDelayX} = TimeScale.getAnimationDimensions({state});
+      equal(endDelayX, expectedEndDelayX);
+
+      TimeScale.reset();
+    }
+  }
+}
--- a/devtools/client/animationinspector/test/unit/xpcshell.ini
+++ b/devtools/client/animationinspector/test/unit/xpcshell.ini
@@ -4,8 +4,9 @@ head =
 tail =
 firefox-appdir = browser
 skip-if = toolkit == 'android' || toolkit == 'gonk'
 
 [test_findOptimalTimeInterval.js]
 [test_formatStopwatchTime.js]
 [test_getCssPropertyName.js]
 [test_timeScale.js]
+[test_timeScale_dimensions.js]