OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Tests that an observation matches the expected value. | 6 * Tests that an observation matches the expected value. |
7 * @param {Object} expected The expected value. | 7 * @param {Object} expected The expected value. |
8 * @param {Object} observed The actual value. | 8 * @param {Object} observed The actual value. |
9 * @param {string=} opt_message Optional message to include with a test | 9 * @param {string=} opt_message Optional message to include with a test |
10 * failure. | 10 * failure. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 f(); | 66 f(); |
67 } catch(err) { | 67 } catch(err) { |
68 triggeredError = true; | 68 triggeredError = true; |
69 } | 69 } |
70 if (!triggeredError) | 70 if (!triggeredError) |
71 throw new Error('Assertion Failed: throw expected.'); | 71 throw new Error('Assertion Failed: throw expected.'); |
72 } | 72 } |
73 | 73 |
74 /** | 74 /** |
75 * Verifies that the contents of the expected and observed arrays match. | 75 * Verifies that the contents of the expected and observed arrays match. |
76 * @param {Array} expected The expected result. | 76 * @param {!Array} expected The expected result. |
77 * @param {Array} observed The actual result. | 77 * @param {!Array} observed The actual result. |
78 */ | 78 */ |
79 function assertArrayEquals(expected, observed) { | 79 function assertArrayEquals(expected, observed) { |
80 var v1 = Array.prototype.slice.call(expected); | 80 var v1 = Array.prototype.slice.call(expected); |
81 var v2 = Array.prototype.slice.call(observed); | 81 var v2 = Array.prototype.slice.call(observed); |
82 var equal = v1.length == v2.length; | 82 var equal = v1.length == v2.length; |
83 if (equal) { | 83 if (equal) { |
84 for (var i = 0; i < v1.length; i++) { | 84 for (var i = 0; i < v1.length; i++) { |
85 if (v1[i] !== v2[i]) { | 85 if (v1[i] !== v2[i]) { |
86 equal = false; | 86 equal = false; |
87 break; | 87 break; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 * @param {boolean} success Indicates if the test completed successfully. | 131 * @param {boolean} success Indicates if the test completed successfully. |
132 */ | 132 */ |
133 function endTests(success) { | 133 function endTests(success) { |
134 domAutomationController.setAutomationId(1); | 134 domAutomationController.setAutomationId(1); |
135 domAutomationController.send(success ? 'SUCCESS' : 'FAILURE'); | 135 domAutomationController.send(success ? 'SUCCESS' : 'FAILURE'); |
136 } | 136 } |
137 | 137 |
138 window.onerror = function() { | 138 window.onerror = function() { |
139 endTests(false); | 139 endTests(false); |
140 }; | 140 }; |
OLD | NEW |