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

Side by Side Diff: chrome/test/data/webui/test_api.js

Issue 7237030: Added options browser_tests using the generator and js handler framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/settings/options/, moved .cc into options dir, addressed JS readability. Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Library providing basic test framework functionality. 5 // Library providing basic test framework functionality.
6 6
7 (function() { 7 (function() {
8 // Asserts. 8 // Asserts.
9 // Use the following assertions to verify a condition within a test. 9 // Use the following assertions to verify a condition within a test.
10 // If assertion fails, the C++ backend will be immediately notified. 10 // If assertion fails, the C++ backend will be immediately notified.
(...skipping 25 matching lines...) Expand all
36 } 36 }
37 37
38 function assertTrue(test, message) { 38 function assertTrue(test, message) {
39 assertBool(test, true, message); 39 assertBool(test, true, message);
40 } 40 }
41 41
42 function assertFalse(test, message) { 42 function assertFalse(test, message) {
43 assertBool(test, false, message); 43 assertBool(test, false, message);
44 } 44 }
45 45
46 function assertEqualsArray(expected, actual, message) {
47 if (expected.length != actual.length)
48 throw new Error('Test Error. Actual length: ' + actual.length +
Mike Mammarella 2011/07/07 23:48:08 For multiline bodies use {}. I don't personally ca
Sheridan Rawlins 2011/07/08 00:02:05 Done.
49 '\nExpected length: ' + expected.length + '\n' +
50 message);
51 for(var i in expected) {
James Hawkins 2011/07/08 00:03:33 Don't use for (var i in blah).
James Hawkins 2011/07/08 00:03:33 Space after 'for'.
Sheridan Rawlins 2011/07/08 22:45:49 Done.
Sheridan Rawlins 2011/07/08 22:45:49 Function not used. Deleted.
52 if (expected.length != actual.length)
53 throw new Error('Test Error. Actual: ' + actual + '\nExpected: ' +
54 expected + '\n' + message);
55 }
56 }
57
46 function assertEquals(expected, actual, message) { 58 function assertEquals(expected, actual, message) {
47 if (expected != actual) { 59 if (expected != actual) {
48 throw new Error('Test Error. Actual: ' + actual + '\nExpected: ' + 60 throw new Error('Test Error. Actual: ' + actual + '\nExpected: ' +
49 expected + '\n' + message); 61 expected + '\n' + message);
50 } 62 }
51 if (typeof expected != typeof actual) { 63 if (typeof expected != typeof actual) {
52 throw new Error('Test Error' + 64 throw new Error('Test Error' +
53 ' (type mismatch)\nActual Type: ' + typeof actual + 65 ' (type mismatch)\nActual Type: ' + typeof actual +
54 '\nExpected Type:' + typeof expected + '\n' + message); 66 '\nExpected Type:' + typeof expected + '\n' + message);
55 } 67 }
(...skipping 27 matching lines...) Expand all
83 console.log('Running test ' + currentTest.name); 95 console.log('Running test ' + currentTest.name);
84 createExpect(currentTest).apply(null, testArguments); 96 createExpect(currentTest).apply(null, testArguments);
85 97
86 if (errors.length) { 98 if (errors.length) {
87 return [false, errors.join('\n')]; 99 return [false, errors.join('\n')];
88 } 100 }
89 101
90 return [true]; 102 return [true];
91 } 103 }
92 104
93 function preloadJavascriptLibraries(overload_chrome_send) { 105 function preloadJavascriptLibraries(overload_chrome_send) {
Mike Mammarella 2011/07/07 23:48:08 Looks like this variable and old_chrome should hav
Sheridan Rawlins 2011/07/08 00:02:05 Done.
94 if (overload_chrome_send) 106 if (overload_chrome_send)
95 chrome = { 'send': send }; 107 chrome = {
108 '__proto__': old_chrome,
109 'send': send,
110 };
96 } 111 }
97 112
98 // Exports. 113 // Exports.
99 window.assertTrue = assertTrue; 114 window.assertTrue = assertTrue;
100 window.assertFalse = assertFalse; 115 window.assertFalse = assertFalse;
101 window.assertEquals = assertEquals; 116 window.assertEquals = assertEquals;
117 window.assertEqualsArray = assertEqualsArray;
102 window.assertNotReached = assertNotReached; 118 window.assertNotReached = assertNotReached;
103 window.expectTrue = createExpect(assertTrue); 119 window.expectTrue = createExpect(assertTrue);
104 window.expectFalse = createExpect(assertFalse); 120 window.expectFalse = createExpect(assertFalse);
105 window.expectEquals = createExpect(assertEquals); 121 window.expectEquals = createExpect(assertEquals);
106 window.expectNotReached = createExpect(assertNotReached); 122 window.expectNotReached = createExpect(assertNotReached);
107 window.registerMessageCallback = registerMessageCallback; 123 window.registerMessageCallback = registerMessageCallback;
108 window.runTest = runTest; 124 window.runTest = runTest;
109 window.preloadJavascriptLibraries = preloadJavascriptLibraries; 125 window.preloadJavascriptLibraries = preloadJavascriptLibraries;
110 })(); 126 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698