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 c674612aa18b5f7b96884af4c430fd3a48970948..3b1a6ae3afb62877ee7e068c8bac409b2ff72ceb 100644 |
--- a/chrome/test/data/webui/print_preview.js |
+++ b/chrome/test/data/webui/print_preview.js |
@@ -13,7 +13,7 @@ PrintPreviewWebUITest.prototype = { |
__proto__: testing.Test.prototype, |
/** |
- * Browse to the sample page, cause print preview & call PreLoad(). |
+ * Browse to the sample page, cause print preview & call preLoad(). |
* @type {string} |
* @override |
**/ |
@@ -25,13 +25,14 @@ PrintPreviewWebUITest.prototype = { |
* @type {Function} |
* @override |
**/ |
- PreLoad: function() { |
+ preLoad: function() { |
// TODO(scr) remove this after tests pass consistently. |
- console.info('PreLoad'); |
+ 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() {} |
@@ -69,9 +70,10 @@ PrintPreviewWebUITest.prototype = { |
disableCopiesOption: true, |
}); |
})); |
- mockHandler.stubs().getPreview(NOT_NULL). |
- will(callFunction(function() { |
- updatePrintPreview('title', true, 1, 1); |
+ var savedArgs = new SaveMockArguments(); |
+ mockHandler.stubs().getPreview(savedArgs.match(NOT_NULL)). |
+ will(callFunctionWithSavedArgs(savedArgs, function(options) { |
+ updatePrintPreview('title', true, 1, JSON.parse(options).requestID); |
})); |
mockHandler.stubs().getPrinters(). |
@@ -90,6 +92,25 @@ 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); |
+ 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 |
@@ -317,16 +338,19 @@ TEST_F('PrintPreviewWebUITest', 'TestColorSettings', function() { |
}); |
// Test that changing the selected printer updates the preview. |
-TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', |
- function() { |
- var matchAnythingSave = new SaveArgumentsMatcher(ANYTHING); |
- |
- this.mockHandler.expects(once()).getPreview(matchAnythingSave). |
- will(callFunction(function() { |
+TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { |
+ var savedArgs = new SaveMockArguments(); |
+ this.mockHandler.expects(once()).getPreview(savedArgs.match(ANYTHING)). |
+ will(callFunctionWithSavedArgs(savedArgs, function(options) { |
updatePrintPreview('title', true, 2, |
- matchAnythingSave.argument.requestID); |
+ JSON.parse(options).requestID); |
})); |
+ this.mockGlobals.expects(once()).updateWithPrinterCapabilities( |
+ savedArgs.match(ANYTHING)). |
+ will(callGlobalWithSavedArgs( |
+ savedArgs, 'updateWithPrinterCapabilities')); |
+ |
var printerList = $('printer-list'); |
assertNotEquals(null, printerList, 'printerList'); |
assertGE(printerList.options.length, printerListMinLength); |