Move Webstore URL concepts to //extensions and out
[chromium-blink-merge.git] / chrome / test / data / webui / mock4js_browsertest.js
blob1fd0cfe883cac76c8715d6e0edf9c80114f7cff6
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.
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
12 /**
13 * Test fixture for Mock4JS testing.
14 * @constructor
15 * @extends {testing.Test}
17 function Mock4JSWebUITest() {}
19 Mock4JSWebUITest.prototype = {
20 __proto__: testing.Test.prototype,
22 /** @inheritDoc */
23 browsePreload: DUMMY_URL,
25 /** @inheritDoc */
26 setUp: function() {
27 function MockHandler() {}
28 MockHandler.prototype = {
29 callMe: function() {},
31 this.mockHandler = mock(MockHandler);
35 TEST_F('Mock4JSWebUITest', 'CalledExpectPasses', function() {
36 this.mockHandler.expects(once()).callMe();
37 this.mockHandler.proxy().callMe();
38 });
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 });
47 /**
48 * Test fixture for Mock4JS testing which is expected to fail.
49 * @constructor
50 * @extends {Mock4JSWebUITest}
52 function Mock4JSWebUITestFails() {}
54 Mock4JSWebUITestFails.prototype = {
55 __proto__: Mock4JSWebUITest.prototype,
57 /** @inheritDoc */
58 testShouldFail: true,
61 TEST_F('Mock4JSWebUITestFails', 'NotCalledExpectFails', function() {
62 this.mockHandler.expects(once()).callMe();
63 });
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 });
72 TEST_F('Mock4JSWebUITestFails', 'CalledOnceExpectTwiceFails', function() {
73 this.mockHandler.expects(exactly(2)).callMe();
74 var proxy = this.mockHandler.proxy();
75 proxy.callMe();
76 });