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

Unified Diff: chrome/test/data/webui/print_preview.js

Issue 8503003: Seed test for SyncUI: sign in successfully with mocks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made some utility methods to make mockHandler and mockGlobals generation simpler. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/print_preview.js
diff --git a/chrome/test/data/webui/print_preview.js b/chrome/test/data/webui/print_preview.js
index 7b0ce330c4717589cae655fa646111bbf0e43070..c9d7af3ff759c618a15e7851efccccdeb64b54e1 100644
--- a/chrome/test/data/webui/print_preview.js
+++ b/chrome/test/data/webui/print_preview.js
@@ -29,35 +29,26 @@ PrintPreviewWebUITest.prototype = {
// TODO(scr) remove this after tests pass consistently.
console.info('preLoad');
- /**
- * Create a handler class with empty methods to allow mocking to register
- * expectations and for registration of handlers with chrome.send.
- * @constructor
- */
- function MockPrintPreviewHandler() {}
-
- MockPrintPreviewHandler.prototype = {
- getDefaultPrinter: function() {},
- getPrinters: function() {},
- getPreview: function(settings, draft_page_count, modifiable) {},
- print: function(settings) {},
- getPrinterCapabilities: function(printerName) {},
- showSystemDialog: function() {},
- morePrinters: function() {},
- signIn: function() {},
- addCloudPrinter: function() {},
- manageCloudPrinters: function() {},
- manageLocalPrinters: function() {},
- closePrintPreviewTab: function() {},
- hidePreview: function() {},
- cancelPendingPrintRequest: function() {},
- saveLastPrinter: function(name, cloud_print_data) {},
- };
-
- // Create the actual mock and register stubs for methods expected to be
- // called before tests run. Specific expectations can be made in the
- // tests themselves.
- var mockHandler = this.mockHandler = mock(MockPrintPreviewHandler);
+ this.makeAndRegisterMockHandler(['getDefaultPrinter',
+ 'getPrinters',
+ 'getPreview',
+ 'print',
+ 'getPrinterCapabilities',
+ 'showSystemDialog',
+ 'morePrinters',
+ 'signIn',
+ 'addCloudPrinter',
+ 'manageCloudPrinters',
+ 'manageLocalPrinters',
+ 'closePrintPreviewTab',
+ 'hidePreview',
+ 'cancelPendingPrintRequest',
+ 'saveLastPrinter',
+ ]);
+
+ // Register stubs for methods expected to be called before tests
+ // run. Specific expectations can be made in the tests themselves.
+ var mockHandler = this.mockHandler;
mockHandler.stubs().getDefaultPrinter().
will(callFunction(function() {
setDefaultPrinter('FooDevice');
@@ -89,28 +80,13 @@ PrintPreviewWebUITest.prototype = {
]);
}));
- // Register mock as a handler of the chrome.send messages.
- registerMockMessageCallbacks(mockHandler, MockPrintPreviewHandler);
-
- /**
- * Create a class to hold global functions to watch for.
- * @constructor
- */
- function MockGlobals() {}
-
- MockGlobals.prototype = {
- updateWithPrinterCapabilities: function(settingInfo) {},
- };
-
- var mockGlobals = this.mockGlobals = mock(MockGlobals);
+ this.makeAndRegisterMockGlobals(['updateWithPrinterCapabilities']);
+ var mockGlobals = this.mockGlobals;
mockGlobals.stubs().updateWithPrinterCapabilities(
savedArgs.match(ANYTHING)).
will(callGlobalWithSavedArgs(
savedArgs, 'updateWithPrinterCapabilities'));
- // Register globals to mock out for us.
- registerMockGlobals(mockGlobals, MockGlobals);
-
// Override checkCompatiblePluginExists to return a value consistent with
// the state being tested and stub out the pdf viewer if it doesn't exist,
// such as on non-official builds. When the plugin exists, use the real

Powered by Google App Engine
This is Rietveld 408576698