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

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

Issue 8515016: WebUI test framework: fix Mock4JS verification, allow chrome.send passthrough. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 9 years, 1 month 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/test/data/webui/chrome_send_browsertest.js ('k') | chrome/test/data/webui/test_api.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview Tests for Mock4JS to ensure that expectations pass or fail as
7 * expected using the test framework.
8 * @author scr@chromium.org (Sheridan Rawlins)
9 * @see test_api.js
10 */
11
12 /**
13 * Test fixture for Mock4JS testing.
14 * @constructor
15 * @extends {testing.Test}
16 */
17 function Mock4JSWebUITest() {}
18
19 Mock4JSWebUITest.prototype = {
20 __proto__: testing.Test.prototype,
21
22 /** @inheritDoc */
23 browsePreload: DUMMY_URL,
24
25 /** @inheritDoc */
26 setUp: function() {
27 function MockHandler() {}
28 MockHandler.prototype = {
29 callMe: function() {},
30 };
31 this.mockHandler = mock(MockHandler);
32 },
33 };
34
35 TEST_F('Mock4JSWebUITest', 'CalledExpectPasses', function() {
36 this.mockHandler.expects(once()).callMe();
37 this.mockHandler.proxy().callMe();
38 });
39
40 TEST_F('Mock4JSWebUITest', 'CalledTwiceExpectTwice', function() {
41 this.mockHandler.expects(exactly(2)).callMe();
42 var proxy = this.mockHandler.proxy();
43 proxy.callMe();
44 proxy.callMe();
45 });
46
47 /**
48 * Test fixture for Mock4JS testing which is expected to fail.
49 * @constructor
50 * @extends {Mock4JSWebUITest}
51 */
52 function Mock4JSWebUITestFails() {}
53
54 Mock4JSWebUITestFails.prototype = {
55 __proto__: Mock4JSWebUITest.prototype,
56
57 /** @inheritDoc */
58 testShouldFail: true,
59 };
60
61 TEST_F('Mock4JSWebUITestFails', 'NotCalledExpectFails', function() {
62 this.mockHandler.expects(once()).callMe();
63 });
64
65 TEST_F('Mock4JSWebUITestFails', 'CalledTwiceExpectOnceFails', function() {
66 this.mockHandler.expects(once()).callMe();
67 var proxy = this.mockHandler.proxy();
68 proxy.callMe();
69 proxy.callMe();
70 });
71
72 TEST_F('Mock4JSWebUITestFails', 'CalledOnceExpectTwiceFails', function() {
73 this.mockHandler.expects(exactly(2)).callMe();
74 var proxy = this.mockHandler.proxy();
75 proxy.callMe();
76 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/chrome_send_browsertest.js ('k') | chrome/test/data/webui/test_api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698