OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
6 * @fileoverview Library providing basic test framework functionality. | 6 * @fileoverview Library providing basic test framework functionality. |
7 */ | 7 */ |
8 | 8 |
9 /** | 9 /** |
10 * Namespace for |Test|. | 10 * Namespace for |Test|. |
(...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1593 * callback once the mocked function is called. | 1593 * callback once the mocked function is called. |
1594 * @param {number} callbackParameter Index of the callback parameter in | 1594 * @param {number} callbackParameter Index of the callback parameter in |
1595 * |savedArgs|. | 1595 * |savedArgs|. |
1596 * @param {...Object} var_args Arguments to pass to the callback. | 1596 * @param {...Object} var_args Arguments to pass to the callback. |
1597 * @return {CallFunctionAction} Action for use in will(). | 1597 * @return {CallFunctionAction} Action for use in will(). |
1598 */ | 1598 */ |
1599 function invokeCallback(savedArgs, callbackParameter, var_args) { | 1599 function invokeCallback(savedArgs, callbackParameter, var_args) { |
1600 var callbackArguments = Array.prototype.slice.call(arguments, 2); | 1600 var callbackArguments = Array.prototype.slice.call(arguments, 2); |
1601 return callFunction(function() { | 1601 return callFunction(function() { |
1602 savedArgs.arguments[callbackParameter].apply(null, callbackArguments); | 1602 savedArgs.arguments[callbackParameter].apply(null, callbackArguments); |
| 1603 |
| 1604 // Mock4JS does not clear the saved args after invocation. |
| 1605 // To allow reuse of the same SaveMockArguments for multiple |
| 1606 // invocations with similar arguments, clear them here. |
| 1607 savedArgs.arguments.splice(0, savedArgs.arguments.length); |
1603 }); | 1608 }); |
1604 } | 1609 } |
1605 | 1610 |
1606 /** | 1611 /** |
1607 * Mock4JS matcher object that matches the actual agrument and the expected | 1612 * Mock4JS matcher object that matches the actual agrument and the expected |
1608 * value iff their JSON represenations are same. | 1613 * value iff their JSON represenations are same. |
1609 * @param {Object} expectedValue Expected value. | 1614 * @param {Object} expectedValue Expected value. |
1610 * @constructor | 1615 * @constructor |
1611 */ | 1616 */ |
1612 function MatchJSON(expectedValue) { | 1617 function MatchJSON(expectedValue) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1686 exports.TEST = TEST; | 1691 exports.TEST = TEST; |
1687 exports.TEST_F = TEST_F; | 1692 exports.TEST_F = TEST_F; |
1688 exports.RUNTIME_TEST_F = TEST_F; | 1693 exports.RUNTIME_TEST_F = TEST_F; |
1689 exports.GEN = GEN; | 1694 exports.GEN = GEN; |
1690 exports.GEN_INCLUDE = GEN_INCLUDE; | 1695 exports.GEN_INCLUDE = GEN_INCLUDE; |
1691 exports.WhenTestDone = WhenTestDone; | 1696 exports.WhenTestDone = WhenTestDone; |
1692 | 1697 |
1693 // Import the Mock4JS helpers. | 1698 // Import the Mock4JS helpers. |
1694 Mock4JS.addMockSupport(exports); | 1699 Mock4JS.addMockSupport(exports); |
1695 })(this); | 1700 })(this); |
OLD | NEW |