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

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

Issue 7576024: Provide ability for WebUIBrowserTests to run asynchronous tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments, fixed chrome.send passthrough, fixed assertion tests to use runTestFunction. Created 9 years, 4 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
« no previous file with comments | « chrome/browser/ui/webui/web_ui_test_handler.cc ('k') | chrome/test/data/webui/async.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 function WebUIAssertionsTest() {} 5 function WebUIAssertionsTest() {}
6 6
7 WebUIAssertionsTest.prototype = { 7 WebUIAssertionsTest.prototype = {
8 __proto__: testing.Test.prototype, 8 __proto__: testing.Test.prototype,
9 browsePreload: 'chrome://DummyURL', 9 browsePreload: 'chrome://DummyURL',
10 typedefCppFixture: null, 10 typedefCppFixture: null,
11 }; 11 };
12 12
13 GEN('#include "chrome/test/data//webui/assertions-inl.h"'); 13 GEN('#include "chrome/test/data//webui/assertions-inl.h"');
14 GEN(''); 14 GEN('');
15 GEN('WebUIAssertionsTest::WebUIAssertionsTest() {}'); 15 GEN('WebUIAssertionsTest::WebUIAssertionsTest() {}');
16 GEN('WebUIAssertionsTest::~WebUIAssertionsTest() {}'); 16 GEN('WebUIAssertionsTest::~WebUIAssertionsTest() {}');
17 GEN('MockWebUIProvider::MockWebUIProvider() {}'); 17 GEN('MockWebUIProvider::MockWebUIProvider() {}');
18 GEN('MockWebUIProvider::~MockWebUIProvider() {}'); 18 GEN('MockWebUIProvider::~MockWebUIProvider() {}');
19 19
20 function testTwoExpects() { 20 function testTwoExpects() {
21 expectTrue(false); 21 expectTrue(false);
22 expectTrue(0); 22 expectTrue(0);
23 } 23 }
24 24
25 TEST_F('WebUIAssertionsTest', 'testTwoExpects', function() { 25 TEST_F('WebUIAssertionsTest', 'testTwoExpects', function() {
26 var result = runTest(testTwoExpects, []); 26 var result = runTestFunction('testTwoExpects', testTwoExpects, []);
27 resetTestState();
27 28
28 expectFalse(result[0]); 29 expectFalse(result[0]);
29 expectTrue(!!result[1].match(/expectTrue\(false\): false/)); 30 expectTrue(!!result[1].match(/expectTrue\(false\): false/));
30 expectTrue(!!result[1].match(/expectTrue\(0\): 0/)); 31 expectTrue(!!result[1].match(/expectTrue\(0\): 0/));
31 }); 32 });
32 33
33 function twoExpects() { 34 function twoExpects() {
34 expectTrue(false, 'message1'); 35 expectTrue(false, 'message1');
35 expectTrue(false, 'message2'); 36 expectTrue(false, 'message2');
36 } 37 }
37 38
38 function testCallTestTwice() { 39 function testCallTestTwice() {
39 twoExpects(); 40 twoExpects();
40 twoExpects(); 41 twoExpects();
41 } 42 }
42 43
43 TEST_F('WebUIAssertionsTest', 'testCallTestTwice', function() { 44 TEST_F('WebUIAssertionsTest', 'testCallTestTwice', function() {
44 var result = runTest(testCallTestTwice, []); 45 var result = runTestFunction('testCallTestTwice', testCallTestTwice, []);
46 resetTestState();
47
45 expectFalse(result[0]); 48 expectFalse(result[0]);
46 expectEquals(2, result[1].match( 49 expectEquals(2, result[1].match(
47 /expectTrue\(false, 'message1'\): message1: false/g).length); 50 /expectTrue\(false, 'message1'\): message1: false/g).length);
48 expectEquals(2, result[1].match( 51 expectEquals(2, result[1].match(
49 /expectTrue\(false, 'message2'\): message2: false/g).length); 52 /expectTrue\(false, 'message2'\): message2: false/g).length);
50 }); 53 });
51 54
52 function testConstructMessage() { 55 function testConstructMessage() {
53 var message = 1 + ' ' + 2; 56 var message = 1 + ' ' + 2;
54 assertTrue(false, message); 57 assertTrue(false, message);
55 } 58 }
56 59
57 TEST_F('WebUIAssertionsTest', 'testConstructedMessage', function() { 60 TEST_F('WebUIAssertionsTest', 'testConstructedMessage', function() {
58 var result = runTest(testConstructMessage, []); 61 var result = runTestFunction(
62 'testConstructMessage', testConstructMessage, []);
63 resetTestState();
64
59 expectEquals( 65 expectEquals(
60 1, result[1].match(/assertTrue\(false, message\): 1 2: false/g).length); 66 1, result[1].match(/assertTrue\(false, message\): 1 2: false/g).length);
61 }); 67 });
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/web_ui_test_handler.cc ('k') | chrome/test/data/webui/async.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698