| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../http/tests/inspector/resources/inspector-test.js"></script> |
| <script> |
| function test() { |
| let suite = InspectorTest.createSyncSuite("WI.Geometry"); |
| |
| suite.addTestCase({ |
| name: "WI.CubicBezier", |
| test(resolve, reject) { |
| let testPass = (inputString, expectedString) => { |
| expectedString ||= inputString; |
| InspectorTest.expectEqual(WI.CubicBezier.fromString(inputString).toString(), expectedString, `Should parse '${inputString}' as '${expectedString}'.`); |
| }; |
| |
| testPass("cubic-bezier(1, 2, 3, 4)"); |
| testPass("cubic-bezier(0.1, 0.2, 0.3, 0.4)"); |
| testPass("cubic-bezier(0.25, 0.1, 0.25, 1)", "ease"); |
| testPass("cubic-bezier(0.42, 0, 1, 1)", "ease-in"); |
| testPass("cubic-bezier(0, 0, 0.58, 1)", "ease-out"); |
| testPass("cubic-bezier(0.42, 0, 0.58, 1)", "ease-in-out"); |
| testPass("cubic-bezier(0, 0, 1, 1)", "linear"); |
| testPass("ease"); |
| testPass("ease-in"); |
| testPass("ease-out"); |
| testPass("ease-in-out"); |
| testPass("linear"); |
| |
| let testFail = (inputString) => { |
| InspectorTest.expectNull(WI.CubicBezier.fromString(inputString), `Should not parse invalid '${inputString}'.`); |
| }; |
| |
| testFail("cubic-bezier()"); |
| testFail("cubic-bezier(0)"); |
| testFail("cubic-bezier(0, 1)"); |
| testFail("cubic-bezier(0, 1, 2)"); |
| testFail("cubic-bezier(\"test\")"); |
| testFail("cubic-bezier(0, \"test\")"); |
| testFail("cubic-bezier(0, 1, \"test\")"); |
| testFail("cubic-bezier(0, 1, 2, \"test\")"); |
| } |
| }); |
| |
| suite.addTestCase({ |
| name: "WI.Spring", |
| test(resolve, reject) { |
| let testPass = (inputString, expectedString) => { |
| expectedString ||= inputString; |
| InspectorTest.expectEqual(WI.Spring.fromString(inputString).toString(), expectedString, `Should parse '${inputString}' as '${expectedString}'.`); |
| }; |
| |
| testPass("spring(1 2 3 4)"); |
| testPass("spring(0.1 0.2 0.3 0.4)", "spring(1 1 0.3 0.4)"); |
| |
| let testFail = (inputString) => { |
| InspectorTest.expectNull(WI.Spring.fromString(inputString), `Should not parse invalid '${inputString}'.`); |
| }; |
| |
| testFail("spring()"); |
| testFail("spring(0)"); |
| testFail("spring(0 1)"); |
| testFail("spring(0 1 2)"); |
| testFail("spring(\"test\")"); |
| testFail("spring(0 \"test\")"); |
| testFail("spring(0 1 \"test\")"); |
| testFail("spring(0 1 2 \"test\")"); |
| } |
| }); |
| |
| suite.addTestCase({ |
| name: "WI.StepFunction", |
| test(resolve, reject) { |
| let testPass = (inputString, expectedString) => { |
| expectedString ||= inputString; |
| InspectorTest.expectEqual(WI.StepsFunction.fromString(inputString).toString(), expectedString, `Should parse '${inputString}' as '${expectedString}'.`); |
| }; |
| |
| testPass("steps(1)", "step-end"); |
| testPass("steps(2, jump-start)"); |
| testPass("steps(3, jump-end)"); |
| testPass("steps(4, jump-none)"); |
| testPass("steps(5, jump-both)"); |
| testPass("steps(6, end)"); |
| testPass("steps(7, start)"); |
| testPass("step-start"); |
| testPass("step-end"); |
| |
| let testFail = (inputString) => { |
| InspectorTest.expectNull(WI.StepsFunction.fromString(inputString), `Should not parse invalid '${inputString}'.`); |
| }; |
| |
| testFail("steps()"); |
| testFail("steps(0)"); |
| testFail("steps(0, 1)"); |
| testFail("steps(0, 1, 2)"); |
| testFail("steps(\"test\")"); |
| testFail("steps(0, \"test\")"); |
| testFail("steps(0, 1, \"test\")"); |
| } |
| }); |
| |
| suite.runTestCasesAndFinish(); |
| } |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <p>Tests for WI.Geometry classes.</p> |
| </body> |
| </html> |