dom/smil/test/db_smilAnimateMotion.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=2 sw=2 sts=2 et: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 /* testcase data for <animateMotion> */
     9 // Fake motion 'attribute', to satisfy testing code that expects an attribute.
    10 var gMotionAttr = new AdditiveAttribute(SMILUtil.getMotionFakeAttributeName(),
    11                                         "XML", "rect");
    13 // CTM-summary-definitions, for re-use by multiple testcase bundles below.
    14 var _reusedCTMLists = {
    15   pacedBasic:     { ctm0:   [100, 200, 0],
    16                     ctm1_6: [105, 205, 0],
    17                     ctm1_3: [110, 210, 0],
    18                     ctm2_3: [120, 220, 0],
    19                     ctm1:   [130, 210, 0]
    20   },
    21   pacedR60:       { ctm0:   [100, 200, Math.PI/3],
    22                     ctm1_6: [105, 205, Math.PI/3],
    23                     ctm1_3: [110, 210, Math.PI/3],
    24                     ctm2_3: [120, 220, Math.PI/3],
    25                     ctm1:   [130, 210, Math.PI/3]
    26   },
    27   pacedRAuto:     { ctm0:   [100, 200, Math.PI/4],
    28                     ctm1_6: [105, 205, Math.PI/4],
    29                     ctm1_3: [110, 210, Math.PI/4],
    30                     ctm2_3: [120, 220, -Math.PI/4],
    31                     ctm1:   [130, 210, -Math.PI/4]
    32   },
    33   pacedRAutoReverse : { ctm0:   [100, 200, 5*Math.PI/4],
    34                         ctm1_6: [105, 205, 5*Math.PI/4],
    35                         ctm1_3: [110, 210, 5*Math.PI/4],
    36                         ctm2_3: [120, 220, 3*Math.PI/4],
    37                         ctm1:   [130, 210, 3*Math.PI/4]
    38   },
    40   discreteBasic : { ctm0:   [100, 200, 0],
    41                     ctm1_6: [100, 200, 0],
    42                     ctm1_3: [120, 220, 0],
    43                     ctm2_3: [130, 210, 0],
    44                     ctm1:   [130, 210, 0]
    45   },
    46   discreteRAuto : { ctm0:   [100, 200, Math.PI/4],
    47                     ctm1_6: [100, 200, Math.PI/4],
    48                     ctm1_3: [120, 220, -Math.PI/4],
    49                     ctm2_3: [130, 210, -Math.PI/4],
    50                     ctm1:   [130, 210, -Math.PI/4]
    51   },
    52   justMoveBasic : { ctm0:   [40, 80, 0],
    53                     ctm1_6: [40, 80, 0],
    54                     ctm1_3: [40, 80, 0],
    55                     ctm2_3: [40, 80, 0],
    56                     ctm1:   [40, 80, 0]
    57   },
    58   justMoveR60 :   { ctm0:   [40, 80, Math.PI/3],
    59                     ctm1_6: [40, 80, Math.PI/3],
    60                     ctm1_3: [40, 80, Math.PI/3],
    61                     ctm2_3: [40, 80, Math.PI/3],
    62                     ctm1:   [40, 80, Math.PI/3]
    63   },
    64   justMoveRAuto : { ctm0:   [40, 80, Math.atan(2)],
    65                     ctm1_6: [40, 80, Math.atan(2)],
    66                     ctm1_3: [40, 80, Math.atan(2)],
    67                     ctm2_3: [40, 80, Math.atan(2)],
    68                     ctm1:   [40, 80, Math.atan(2)]
    69   },
    70   justMoveRAutoReverse : { ctm0:   [40, 80, Math.PI + Math.atan(2)],
    71                            ctm1_6: [40, 80, Math.PI + Math.atan(2)],
    72                            ctm1_3: [40, 80, Math.PI + Math.atan(2)],
    73                            ctm2_3: [40, 80, Math.PI + Math.atan(2)],
    74                            ctm1:   [40, 80, Math.PI + Math.atan(2)]
    75   },
    76   nullMoveBasic : { ctm0:   [0, 0, 0],
    77                     ctm1_6: [0, 0, 0],
    78                     ctm1_3: [0, 0, 0],
    79                     ctm2_3: [0, 0, 0],
    80                     ctm1:   [0, 0, 0]
    81   },
    82   nullMoveRAutoReverse : { ctm0:   [0, 0, Math.PI],
    83                            ctm1_6: [0, 0, Math.PI],
    84                            ctm1_3: [0, 0, Math.PI],
    85                            ctm2_3: [0, 0, Math.PI],
    86                            ctm1:   [0, 0, Math.PI]
    87   },
    88 };
    90 var gMotionBundles =
    91 [
    92   // Bundle to test basic functionality (using default calcMode='paced')
    93   new TestcaseBundle(gMotionAttr, [
    94     // Basic paced-mode (default) test, with values/mpath/path
    95     new AnimMotionTestcase({ "values": "100, 200; 120, 220; 130, 210" },
    96                            _reusedCTMLists.pacedBasic),
    97     new AnimMotionTestcase({ "path":  "M100 200 L120 220 L130 210" },
    98                            _reusedCTMLists.pacedBasic),
    99     new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210" },
   100                            _reusedCTMLists.pacedBasic),
   102     // ..and now with rotate=constant value in degrees
   103     new AnimMotionTestcase({ "values": "100,200; 120,220; 130, 210",
   104                              "rotate": "60" },
   105                            _reusedCTMLists.pacedR60),
   106     new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210",
   107                              "rotate": "60" },
   108                            _reusedCTMLists.pacedR60),
   109     new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210",
   110                              "rotate": "60" },
   111                            _reusedCTMLists.pacedR60),
   113     // ..and now with rotate=constant value in radians
   114     new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210",
   115                              "rotate": "1.0471975512rad" }, // pi/3
   116                            _reusedCTMLists.pacedR60),
   118     // ..and now with rotate=auto
   119     new AnimMotionTestcase({ "values": "100,200; 120,220; 130, 210",
   120                              "rotate": "auto" },
   121                            _reusedCTMLists.pacedRAuto),
   122     new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210",
   123                              "rotate": "auto" },
   124                            _reusedCTMLists.pacedRAuto),
   125     new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210",
   126                              "rotate": "auto" },
   127                            _reusedCTMLists.pacedRAuto),
   129     // ..and now with rotate=auto-reverse
   130     new AnimMotionTestcase({ "values": "100,200; 120,220; 130, 210",
   131                              "rotate": "auto-reverse" },
   132                            _reusedCTMLists.pacedRAutoReverse),
   133     new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210",
   134                              "rotate": "auto-reverse" },
   135                            _reusedCTMLists.pacedRAutoReverse),
   136     new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210",
   137                              "rotate": "auto-reverse" },
   138                            _reusedCTMLists.pacedRAutoReverse),
   140   ]),
   142   // Bundle to test calcMode='discrete'
   143   new TestcaseBundle(gMotionAttr, [
   144     new AnimMotionTestcase({ "values": "100, 200; 120, 220; 130, 210",
   145                              "calcMode": "discrete" },
   146                            _reusedCTMLists.discreteBasic),
   147     new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210",
   148                              "calcMode": "discrete" },
   149                            _reusedCTMLists.discreteBasic),
   150     new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210",
   151                              "calcMode": "discrete" },
   152                            _reusedCTMLists.discreteBasic),
   153     // ..and now with rotate=auto
   154     new AnimMotionTestcase({ "values": "100, 200; 120, 220; 130, 210",
   155                              "calcMode": "discrete",
   156                              "rotate": "auto" },
   157                            _reusedCTMLists.discreteRAuto),
   158     new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210",
   159                              "calcMode": "discrete",
   160                              "rotate": "auto" },
   161                            _reusedCTMLists.discreteRAuto),
   162     new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210",
   163                              "calcMode": "discrete",
   164                              "rotate": "auto" },
   165                            _reusedCTMLists.discreteRAuto),
   166   ]),
   168   // Bundle to test relative units ('em')
   169   new TestcaseBundle(gMotionAttr, [
   170     // First with unitless values from->by...
   171     new AnimMotionTestcase({ "from": "10, 10",
   172                              "by":   "30, 60" },
   173                            { ctm0:   [10, 10, 0],
   174                              ctm1_6: [15, 20, 0],
   175                              ctm1_3: [20, 30, 0],
   176                              ctm2_3: [30, 50, 0],
   177                              ctm1:   [40, 70, 0]
   178                            }),
   179     // ... then add 'em' units (with 1em=10px) on half the values
   180     new AnimMotionTestcase({ "from": "1em, 10",
   181                              "by":   "30, 6em" },
   182                            { ctm0:   [10, 10, 0],
   183                              ctm1_6: [15, 20, 0],
   184                              ctm1_3: [20, 30, 0],
   185                              ctm2_3: [30, 50, 0],
   186                              ctm1:   [40, 70, 0]
   187                            }),
   188   ]),
   190   // Bundle to test a path with just a "move" command and nothing else
   191   new TestcaseBundle(gMotionAttr, [
   192     new AnimMotionTestcase({ "values": "40, 80" },
   193                            _reusedCTMLists.justMoveBasic),
   194     new AnimMotionTestcase({ "path":  "M40 80" },
   195                            _reusedCTMLists.justMoveBasic),
   196     new AnimMotionTestcase({ "mpath": "m40 80" },
   197                            _reusedCTMLists.justMoveBasic),
   198   ]),
   199   // ... and now with a fixed rotate-angle
   200   new TestcaseBundle(gMotionAttr, [
   201     new AnimMotionTestcase({ "values": "40, 80",
   202                              "rotate": "60" },
   203                            _reusedCTMLists.justMoveR60),
   204     new AnimMotionTestcase({ "path":  "M40 80",
   205                              "rotate": "60" },
   206                            _reusedCTMLists.justMoveR60),
   207     new AnimMotionTestcase({ "mpath": "m40 80",
   208                              "rotate": "60" },
   209                            _reusedCTMLists.justMoveR60),
   210   ]),
   211   // ... and now with 'auto' (should use the move itself as
   212   // our tangent angle, I think)
   213   new TestcaseBundle(gMotionAttr, [
   214     new AnimMotionTestcase({ "values": "40, 80",
   215                              "rotate": "auto" },
   216                            _reusedCTMLists.justMoveRAuto),
   217     new AnimMotionTestcase({ "path":  "M40 80",
   218                              "rotate": "auto" },
   219                            _reusedCTMLists.justMoveRAuto),
   220     new AnimMotionTestcase({ "mpath": "m40 80",
   221                              "rotate": "auto" },
   222                            _reusedCTMLists.justMoveRAuto),
   223   ]),
   224   // ... and now with 'auto-reverse'
   225   new TestcaseBundle(gMotionAttr, [
   226     new AnimMotionTestcase({ "values": "40, 80",
   227                              "rotate": "auto-reverse" },
   228                            _reusedCTMLists.justMoveRAutoReverse),
   229     new AnimMotionTestcase({ "path":  "M40 80",
   230                              "rotate": "auto-reverse" },
   231                            _reusedCTMLists.justMoveRAutoReverse),
   232     new AnimMotionTestcase({ "mpath": "m40 80",
   233                              "rotate": "auto-reverse" },
   234                            _reusedCTMLists.justMoveRAutoReverse),
   235   ]),
   236   // ... and now with a null move to make sure 'auto'/'auto-reverse' don't
   237   // blow up
   238   new TestcaseBundle(gMotionAttr, [
   239     new AnimMotionTestcase({ "values": "0, 0",
   240                              "rotate": "auto" },
   241                            _reusedCTMLists.nullMoveBasic),
   242   ]),
   243   new TestcaseBundle(gMotionAttr, [
   244     new AnimMotionTestcase({ "values": "0, 0",
   245                              "rotate": "auto-reverse" },
   246                            _reusedCTMLists.nullMoveRAutoReverse),
   247   ]),
   248 ];
   250 // XXXdholbert Add more tests:
   251 //  - keyPoints/keyTimes
   252 //  - paths with curves
   253 //  - Control path with from/by/to

mercurial