OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 * Test fixture for print preview WebUI testing. | 6 * Test fixture for print preview WebUI testing. |
7 * @extends {testing.Test} | 7 * @extends {testing.Test} |
8 * @constructor | 8 * @constructor |
9 */ | 9 */ |
10 function PrintPreviewWebUITest() {} | 10 function PrintPreviewWebUITest() {} |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 mockHandler.stubs().getDefaultPrinter(). | 61 mockHandler.stubs().getDefaultPrinter(). |
62 will(callFunction(function() { | 62 will(callFunction(function() { |
63 setDefaultPrinter('FooDevice'); | 63 setDefaultPrinter('FooDevice'); |
64 })); | 64 })); |
65 mockHandler.stubs().getPrinterCapabilities(NOT_NULL). | 65 mockHandler.stubs().getPrinterCapabilities(NOT_NULL). |
66 will(callFunction(function() { | 66 will(callFunction(function() { |
67 updateWithPrinterCapabilities({ | 67 updateWithPrinterCapabilities({ |
68 disableColorOption: true, | 68 disableColorOption: true, |
69 setColorAsDefault: true, | 69 setColorAsDefault: true, |
70 disableCopiesOption: true, | 70 disableCopiesOption: true, |
71 printerDefaultDuplexValue: copiesSettings.SIMPLEX, | |
72 }); | 71 }); |
73 })); | 72 })); |
74 var savedArgs = new SaveMockArguments(); | 73 var savedArgs = new SaveMockArguments(); |
75 mockHandler.stubs().getPreview(savedArgs.match(NOT_NULL)). | 74 mockHandler.stubs().getPreview(savedArgs.match(NOT_NULL)). |
76 will(callFunctionWithSavedArgs(savedArgs, function(args) { | 75 will(callFunctionWithSavedArgs(savedArgs, function(args) { |
77 updatePrintPreview(1, JSON.parse(args[0]).requestID); | 76 updatePrintPreview(1, JSON.parse(args[0]).requestID); |
78 })); | 77 })); |
79 | 78 |
80 mockHandler.stubs().getPrinters(). | 79 mockHandler.stubs().getPrinters(). |
81 will(callFunction(function() { | 80 will(callFunction(function() { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 291 |
293 // Test that disabled settings hide the disabled sections. | 292 // Test that disabled settings hide the disabled sections. |
294 TEST_F('PrintPreviewWebUITest', 'TestSectionsDisabled', function() { | 293 TEST_F('PrintPreviewWebUITest', 'TestSectionsDisabled', function() { |
295 this.mockHandler.expects(once()).getPrinterCapabilities('FooDevice'). | 294 this.mockHandler.expects(once()).getPrinterCapabilities('FooDevice'). |
296 will(callFunction(function() { | 295 will(callFunction(function() { |
297 updateWithPrinterCapabilities({ | 296 updateWithPrinterCapabilities({ |
298 disableColorOption: true, | 297 disableColorOption: true, |
299 setColorAsDefault: true, | 298 setColorAsDefault: true, |
300 disableCopiesOption: true, | 299 disableCopiesOption: true, |
301 disableLandscapeOption: true, | 300 disableLandscapeOption: true, |
302 printerDefaultDuplexValue: copiesSettings.SIMPLEX, | |
303 }); | 301 }); |
304 })); | 302 })); |
305 | 303 |
306 updateControlsWithSelectedPrinterCapabilities(); | 304 updateControlsWithSelectedPrinterCapabilities(); |
307 | 305 |
308 checkSectionVisible(layoutSettings.layoutOption_, false); | 306 checkSectionVisible(layoutSettings.layoutOption_, false); |
309 checkSectionVisible(colorSettings.colorOption_, false); | 307 checkSectionVisible(colorSettings.colorOption_, false); |
310 checkSectionVisible(copiesSettings.copiesOption_, false); | 308 checkSectionVisible(copiesSettings.copiesOption_, false); |
311 }); | 309 }); |
312 | 310 |
313 // Test that the color settings are set according to the printer capabilities. | 311 // Test that the color settings are set according to the printer capabilities. |
314 TEST_F('PrintPreviewWebUITest', 'TestColorSettings', function() { | 312 TEST_F('PrintPreviewWebUITest', 'TestColorSettings', function() { |
315 this.mockHandler.expects(once()).getPrinterCapabilities('FooDevice'). | 313 this.mockHandler.expects(once()).getPrinterCapabilities('FooDevice'). |
316 will(callFunction(function() { | 314 will(callFunction(function() { |
317 updateWithPrinterCapabilities({ | 315 updateWithPrinterCapabilities({ |
318 disableColorOption: false, | 316 disableColorOption: false, |
319 setColorAsDefault: true, | 317 setColorAsDefault: true, |
320 disableCopiesOption: false, | 318 disableCopiesOption: false, |
321 disableLandscapeOption: false, | 319 disableLandscapeOption: false, |
322 printerDefaultDuplexValue: copiesSettings.SIMPLEX, | |
323 }); | 320 }); |
324 })); | 321 })); |
325 | 322 |
326 updateControlsWithSelectedPrinterCapabilities(); | 323 updateControlsWithSelectedPrinterCapabilities(); |
327 expectTrue(colorSettings.colorRadioButton.checked); | 324 expectTrue(colorSettings.colorRadioButton.checked); |
328 expectFalse(colorSettings.bwRadioButton.checked); | 325 expectFalse(colorSettings.bwRadioButton.checked); |
329 | 326 |
330 this.mockHandler.expects(once()).getPrinterCapabilities('FooDevice'). | 327 this.mockHandler.expects(once()).getPrinterCapabilities('FooDevice'). |
331 will(callFunction(function() { | 328 will(callFunction(function() { |
332 updateWithPrinterCapabilities({ | 329 updateWithPrinterCapabilities({ |
333 disableColorOption: false, | 330 disableColorOption: false, |
334 setColorAsDefault: false, | 331 setColorAsDefault: false, |
335 disableCopiesOption: false, | 332 disableCopiesOption: false, |
336 disableLandscapeOption: false, | 333 disableLandscapeOption: false, |
337 printerDefaultDuplexValue: copiesSettings.SIMPLEX, | |
338 }); | 334 }); |
339 })); | 335 })); |
340 | 336 |
341 updateControlsWithSelectedPrinterCapabilities(); | 337 updateControlsWithSelectedPrinterCapabilities(); |
342 expectFalse(colorSettings.colorRadioButton.checked); | 338 expectFalse(colorSettings.colorRadioButton.checked); |
343 expectTrue(colorSettings.bwRadioButton.checked); | 339 expectTrue(colorSettings.bwRadioButton.checked); |
344 }); | 340 }); |
345 | 341 |
346 // Test to verify that duplex settings are set according to the printer | |
347 // capabilities. | |
348 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettings', function() { | |
349 this.mockHandler.expects(once()).getPrinterCapabilities('FooDevice'). | |
350 will(callFunction(function() { | |
351 updateWithPrinterCapabilities({ | |
352 disableColorOption: false, | |
353 setColorAsDefault: false, | |
354 disableCopiesOption: false, | |
355 disableLandscapeOption: false, | |
356 printerDefaultDuplexValue: copiesSettings.SIMPLEX, | |
357 }); | |
358 })); | |
359 updateControlsWithSelectedPrinterCapabilities(); | |
360 expectEquals(copiesSettings.duplexMode, copiesSettings.SIMPLEX); | |
361 expectEquals(copiesSettings.twoSidedOption_.hidden, false); | |
362 | |
363 // If the printer default duplex value is UNKNOWN_DUPLEX_MODE, hide the | |
364 // two sided option. | |
365 this.mockHandler.expects(once()).getPrinterCapabilities('FooDevice'). | |
366 will(callFunction(function() { | |
367 updateWithPrinterCapabilities({ | |
368 disableColorOption: false, | |
369 setColorAsDefault: false, | |
370 disableCopiesOption: false, | |
371 disableLandscapeOption: false, | |
372 printerDefaultDuplexValue: copiesSettings.UNKNOWN_DUPLEX_MODE, | |
373 }); | |
374 })); | |
375 updateControlsWithSelectedPrinterCapabilities(); | |
376 expectEquals(copiesSettings.duplexMode, copiesSettings.UNKNOWN_DUPLEX_MODE); | |
377 expectEquals(copiesSettings.twoSidedOption_.hidden, true); | |
378 | |
379 this.mockHandler.expects(once()).getPrinterCapabilities('FooDevice'). | |
380 will(callFunction(function() { | |
381 updateWithPrinterCapabilities({ | |
382 disableColorOption: false, | |
383 setColorAsDefault: false, | |
384 disableCopiesOption: false, | |
385 disableLandscapeOption: false, | |
386 printerDefaultDuplexValue: copiesSettings.SIMPLEX, | |
387 }); | |
388 })); | |
389 updateControlsWithSelectedPrinterCapabilities(); | |
390 expectEquals(copiesSettings.twoSidedOption_.hidden, false); | |
391 expectEquals(copiesSettings.duplexMode, copiesSettings.SIMPLEX); | |
392 copiesSettings.twoSidedCheckbox.checked = true; | |
393 expectEquals(copiesSettings.duplexMode, copiesSettings.LONG_EDGE); | |
394 }); | |
395 | |
396 // Test that changing the selected printer updates the preview. | 342 // Test that changing the selected printer updates the preview. |
397 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { | 343 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { |
398 var savedArgs = new SaveMockArguments(); | 344 var savedArgs = new SaveMockArguments(); |
399 this.mockHandler.expects(once()).getPreview(savedArgs.match(ANYTHING)). | 345 this.mockHandler.expects(once()).getPreview(savedArgs.match(ANYTHING)). |
400 will(callFunctionWithSavedArgs(savedArgs, function(args) { | 346 will(callFunctionWithSavedArgs(savedArgs, function(args) { |
401 updatePrintPreview(2, JSON.parse(args[0]).requestID); | 347 updatePrintPreview(2, JSON.parse(args[0]).requestID); |
402 })); | 348 })); |
403 | 349 |
404 this.mockGlobals.expects(once()).updateWithPrinterCapabilities( | 350 this.mockGlobals.expects(once()).updateWithPrinterCapabilities( |
405 savedArgs.match(ANYTHING)). | 351 savedArgs.match(ANYTHING)). |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 | 392 |
447 // Test that error message is displayed when plugin doesn't exist. | 393 // Test that error message is displayed when plugin doesn't exist. |
448 TEST_F('PrintPreviewNoPDFWebUITest', 'TestErrorMessage', function() { | 394 TEST_F('PrintPreviewNoPDFWebUITest', 'TestErrorMessage', function() { |
449 var errorButton = $('error-button'); | 395 var errorButton = $('error-button'); |
450 assertNotEquals(null, errorButton); | 396 assertNotEquals(null, errorButton); |
451 expectFalse(errorButton.disabled); | 397 expectFalse(errorButton.disabled); |
452 var errorText = $('error-text'); | 398 var errorText = $('error-text'); |
453 assertNotEquals(null, errorText); | 399 assertNotEquals(null, errorText); |
454 expectFalse(errorText.classList.contains('hidden')); | 400 expectFalse(errorText.classList.contains('hidden')); |
455 }); | 401 }); |
OLD | NEW |