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

Side by Side Diff: chrome/test/data/webui/print_preview.js

Issue 7817013: PrintPreview: Added code to identify the printer default duplex value. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed dpapad@ comments. Created 9 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler.cc ('k') | printing/print_job_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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,
71 }); 72 });
72 })); 73 }));
73 var savedArgs = new SaveMockArguments(); 74 var savedArgs = new SaveMockArguments();
74 mockHandler.stubs().getPreview(savedArgs.match(NOT_NULL)). 75 mockHandler.stubs().getPreview(savedArgs.match(NOT_NULL)).
75 will(callFunctionWithSavedArgs(savedArgs, function(args) { 76 will(callFunctionWithSavedArgs(savedArgs, function(args) {
76 updatePrintPreview(1, JSON.parse(args[0]).requestID); 77 updatePrintPreview(1, JSON.parse(args[0]).requestID);
77 })); 78 }));
78 79
79 mockHandler.stubs().getPrinters(). 80 mockHandler.stubs().getPrinters().
80 will(callFunction(function() { 81 will(callFunction(function() {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 292
292 // Test that disabled settings hide the disabled sections. 293 // Test that disabled settings hide the disabled sections.
293 TEST_F('PrintPreviewWebUITest', 'TestSectionsDisabled', function() { 294 TEST_F('PrintPreviewWebUITest', 'TestSectionsDisabled', function() {
294 this.mockHandler.expects(once()).getPrinterCapabilities('FooDevice'). 295 this.mockHandler.expects(once()).getPrinterCapabilities('FooDevice').
295 will(callFunction(function() { 296 will(callFunction(function() {
296 updateWithPrinterCapabilities({ 297 updateWithPrinterCapabilities({
297 disableColorOption: true, 298 disableColorOption: true,
298 setColorAsDefault: true, 299 setColorAsDefault: true,
299 disableCopiesOption: true, 300 disableCopiesOption: true,
300 disableLandscapeOption: true, 301 disableLandscapeOption: true,
302 printerDefaultDuplexValue: copiesSettings.SIMPLEX,
301 }); 303 });
302 })); 304 }));
303 305
304 updateControlsWithSelectedPrinterCapabilities(); 306 updateControlsWithSelectedPrinterCapabilities();
305 307
306 checkSectionVisible(layoutSettings.layoutOption_, false); 308 checkSectionVisible(layoutSettings.layoutOption_, false);
307 checkSectionVisible(colorSettings.colorOption_, false); 309 checkSectionVisible(colorSettings.colorOption_, false);
308 checkSectionVisible(copiesSettings.copiesOption_, false); 310 checkSectionVisible(copiesSettings.copiesOption_, false);
309 }); 311 });
310 312
311 // Test that the color settings are set according to the printer capabilities. 313 // Test that the color settings are set according to the printer capabilities.
312 TEST_F('PrintPreviewWebUITest', 'TestColorSettings', function() { 314 TEST_F('PrintPreviewWebUITest', 'TestColorSettings', function() {
313 this.mockHandler.expects(once()).getPrinterCapabilities('FooDevice'). 315 this.mockHandler.expects(once()).getPrinterCapabilities('FooDevice').
314 will(callFunction(function() { 316 will(callFunction(function() {
315 updateWithPrinterCapabilities({ 317 updateWithPrinterCapabilities({
316 disableColorOption: false, 318 disableColorOption: false,
317 setColorAsDefault: true, 319 setColorAsDefault: true,
318 disableCopiesOption: false, 320 disableCopiesOption: false,
319 disableLandscapeOption: false, 321 disableLandscapeOption: false,
322 printerDefaultDuplexValue: copiesSettings.SIMPLEX,
320 }); 323 });
321 })); 324 }));
322 325
323 updateControlsWithSelectedPrinterCapabilities(); 326 updateControlsWithSelectedPrinterCapabilities();
324 expectTrue(colorSettings.colorRadioButton.checked); 327 expectTrue(colorSettings.colorRadioButton.checked);
325 expectFalse(colorSettings.bwRadioButton.checked); 328 expectFalse(colorSettings.bwRadioButton.checked);
326 329
327 this.mockHandler.expects(once()).getPrinterCapabilities('FooDevice'). 330 this.mockHandler.expects(once()).getPrinterCapabilities('FooDevice').
328 will(callFunction(function() { 331 will(callFunction(function() {
329 updateWithPrinterCapabilities({ 332 updateWithPrinterCapabilities({
330 disableColorOption: false, 333 disableColorOption: false,
331 setColorAsDefault: false, 334 setColorAsDefault: false,
332 disableCopiesOption: false, 335 disableCopiesOption: false,
333 disableLandscapeOption: false, 336 disableLandscapeOption: false,
337 printerDefaultDuplexValue: copiesSettings.SIMPLEX,
334 }); 338 });
335 })); 339 }));
336 340
337 updateControlsWithSelectedPrinterCapabilities(); 341 updateControlsWithSelectedPrinterCapabilities();
338 expectFalse(colorSettings.colorRadioButton.checked); 342 expectFalse(colorSettings.colorRadioButton.checked);
339 expectTrue(colorSettings.bwRadioButton.checked); 343 expectTrue(colorSettings.bwRadioButton.checked);
340 }); 344 });
341 345
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
342 // Test that changing the selected printer updates the preview. 396 // Test that changing the selected printer updates the preview.
343 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { 397 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() {
344 var savedArgs = new SaveMockArguments(); 398 var savedArgs = new SaveMockArguments();
345 this.mockHandler.expects(once()).getPreview(savedArgs.match(ANYTHING)). 399 this.mockHandler.expects(once()).getPreview(savedArgs.match(ANYTHING)).
346 will(callFunctionWithSavedArgs(savedArgs, function(args) { 400 will(callFunctionWithSavedArgs(savedArgs, function(args) {
347 updatePrintPreview(2, JSON.parse(args[0]).requestID); 401 updatePrintPreview(2, JSON.parse(args[0]).requestID);
348 })); 402 }));
349 403
350 this.mockGlobals.expects(once()).updateWithPrinterCapabilities( 404 this.mockGlobals.expects(once()).updateWithPrinterCapabilities(
351 savedArgs.match(ANYTHING)). 405 savedArgs.match(ANYTHING)).
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 446
393 // Test that error message is displayed when plugin doesn't exist. 447 // Test that error message is displayed when plugin doesn't exist.
394 TEST_F('PrintPreviewNoPDFWebUITest', 'TestErrorMessage', function() { 448 TEST_F('PrintPreviewNoPDFWebUITest', 'TestErrorMessage', function() {
395 var errorButton = $('error-button'); 449 var errorButton = $('error-button');
396 assertNotEquals(null, errorButton); 450 assertNotEquals(null, errorButton);
397 expectFalse(errorButton.disabled); 451 expectFalse(errorButton.disabled);
398 var errorText = $('error-text'); 452 var errorText = $('error-text');
399 assertNotEquals(null, errorText); 453 assertNotEquals(null, errorText);
400 expectFalse(errorText.classList.contains('hidden')); 454 expectFalse(errorText.classList.contains('hidden'));
401 }); 455 });
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler.cc ('k') | printing/print_job_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698