Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: bower_components/web-animations-js/tutorial/tutorial-testing.js

Issue 786953007: npm_modules: Fork bower_components into Polymer 0.4.0 and 0.5.0 versions (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 "use strict";
17
18 (function() {
19 var pass;
20 var completedTests;
21 var allDone;
22 var numTests;
23
24 // Call to initialize the testing environment.
25 function setupTutorialTests() {
26 setState("Manual");
27 var timeOfAnimation = document.createElement('div');
28 timeOfAnimation.id = "animViewerText";
29 timeOfAnimation.innerHTML = "Current animation time: 0.00";
30 document.body.appendChild(timeOfAnimation);
31 numTests = 0;
32 completedTests = 0;
33 allDone = false;
34 pass = true;
35 }
36
37 // This function mimics the async_test function in testharness.js so that
38 // extra-asserts.js will run as intended for a tutorial.
39 function async_test(func, name, properties) {
40 numTests++;
41 step = function(func) {
42 func();
43 if (!pass) {
44 parent.TryItDisplay.fail();
45 allDone = true;
46 };
47 };
48
49 done = function() {
50 completedTests++;
51 if (completedTests == numTests && !allDone) {
52 allDone = true;
53 parent.TryItDisplay.pass();
54 };
55 };
56 return this;
57 }
58
59 function assert_equals(actual, expected, description) {
60 pass = (actual == expected);
61 }
62
63 function assert_approx_equals(actual, expected, epsilon, description) {
64 var lowerBound = expected - (epsilon / 2) < actual;
65 var upperBound = expected + (epsilon / 2) > actual;
66 pass = (lowerBound && upperBound);
67 }
68
69 // This function is required to do nothing for tutorial testing,
70 // but extra-asserts calls it and thus without this function,
71 // extra-asserts.js will cause the page to crash.
72 function add_completion_callback(anything) {
73 }
74
75 ///////////////////////////////////////////////////////////////////////////////
76 // Exposing functions to be accessed externally //
77 ///////////////////////////////////////////////////////////////////////////////
78
79 window.setupTutorialTests = setupTutorialTests;
80 window.async_test = async_test;
81 window.assert_approx_equals = assert_approx_equals;
82 window.assert_equals = assert_equals;
83 window.add_completion_callback = add_completion_callback;
84 })();
OLDNEW
« no previous file with comments | « bower_components/web-animations-js/tutorial/tutorial-style.css ('k') | bower_components/web-animations-js/web-animations.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698