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.
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)
13 * Test fixture for Mock4JS testing.
15 * @extends {testing.Test}
17 function Mock4JSWebUITest() {}
19 Mock4JSWebUITest.prototype = {
20 __proto__: testing.Test.prototype,
23 browsePreload: DUMMY_URL,
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();
40 TEST_F('Mock4JSWebUITest', 'CalledTwiceExpectTwice', function() {
41 this.mockHandler.expects(exactly(2)).callMe();
42 var proxy = this.mockHandler.proxy();
48 * Test fixture for Mock4JS testing which is expected to fail.
50 * @extends {Mock4JSWebUITest}
52 function Mock4JSWebUITestFails() {}
54 Mock4JSWebUITestFails.prototype = {
55 __proto__: Mock4JSWebUITest.prototype,
61 TEST_F('Mock4JSWebUITestFails', 'NotCalledExpectFails', function() {
62 this.mockHandler.expects(once()).callMe();
65 TEST_F('Mock4JSWebUITestFails', 'CalledTwiceExpectOnceFails', function() {
66 this.mockHandler.expects(once()).callMe();
67 var proxy = this.mockHandler.proxy();
72 TEST_F('Mock4JSWebUITestFails', 'CalledOnceExpectTwiceFails', function() {
73 this.mockHandler.expects(exactly(2)).callMe();
74 var proxy = this.mockHandler.proxy();