| Index: chrome/test/data/webui/test_api.js
|
| diff --git a/chrome/test/data/webui/test_api.js b/chrome/test/data/webui/test_api.js
|
| index 140efe7d4b5d9c1743d9ac1f96e095b6b39ba325..e5556d699435c5fd9f8cf35822c8c9ddd58b1672 100644
|
| --- a/chrome/test/data/webui/test_api.js
|
| +++ b/chrome/test/data/webui/test_api.js
|
| @@ -110,6 +110,30 @@ var testing = {};
|
| testShouldFail: false,
|
|
|
| /**
|
| + * Create a new class to handle |messageNames|, assign it to
|
| + * |this.mockHandler|, register its messages and return it.
|
| + * @return {Mock} Mock handler class assigned to |this.mockHandler|.
|
| + */
|
| + makeAndRegisterMockHandler: function(messageNames) {
|
| + var MockClass = makeMockClass(messageNames);
|
| + this.mockHandler = mock(MockClass);
|
| + registerMockMessageCallbacks(this.mockHandler, MockClass);
|
| + return this.mockHandler;
|
| + },
|
| +
|
| + /**
|
| + * Create a new class to handle |functionNames|, assign it to
|
| + * |this.mockGlobals|, register its global overrides, and return it.
|
| + * @return {Mock} Mock handler class assigned to |this.mockGlobals|.
|
| + */
|
| + makeAndRegisterMockGlobals: function(functionNames) {
|
| + var MockClass = makeMockClass(functionNames);
|
| + this.mockGlobals = mock(MockClass);
|
| + registerMockGlobals(this.mockGlobals, MockClass);
|
| + return this.mockGlobals;
|
| + },
|
| +
|
| + /**
|
| * Override this method to perform initialization during preload (such as
|
| * creating mocks and registering handlers).
|
| * @type {Function}
|
| @@ -388,6 +412,25 @@ var testing = {};
|
| }
|
|
|
| /**
|
| + * Empty function for use in making mocks.
|
| + * @const
|
| + */
|
| + function emptyFunction() {}
|
| +
|
| + /**
|
| + * Make a mock from the supplied |methodNames| array.
|
| + * @param {Array.<string>} methodNames Array of names of methods to mock.
|
| + * @return {Function} Constructor with prototype filled in with methods
|
| + * matching |methodNames|.
|
| + */
|
| + function makeMockClass(methodNames) {
|
| + function MockConstructor() {}
|
| + for(var i = 0; i < methodNames.length; i++)
|
| + MockConstructor.prototype[methodNames[i]] = emptyFunction;
|
| + return MockConstructor;
|
| + }
|
| +
|
| + /**
|
| * Register all methods of {@code mockClass.prototype} as overrides to global
|
| * functions of the same name as the method, using the proxy of the
|
| * |mockObject| to handle the functions.
|
|
|