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

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

Issue 2911203003: Print Preview: Migrate JS tests to use Mocha, part 3. (Closed)
Patch Set: Cleanup Created 3 years, 6 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
« no previous file with comments | « no previous file | chrome/test/data/webui/print_preview/print_preview_tests.js » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 var ROOT_PATH = '../../../../../'; 5 var ROOT_PATH = '../../../../../';
6 6
7 /** 7 /**
8 * Test fixture for print preview WebUI testing. 8 * Test fixture for print preview WebUI testing.
9 * @constructor 9 * @constructor
10 * @extends {testing.Test} 10 * @extends {testing.Test}
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 288 }
289 }; 289 };
290 } 290 }
291 291
292 function isPrintAsImageEnabled() { 292 function isPrintAsImageEnabled() {
293 // Should be enabled by default on non Windows/Mac 293 // Should be enabled by default on non Windows/Mac
294 return (!cr.isWindows && !cr.isMac && 294 return (!cr.isWindows && !cr.isMac &&
295 loadTimeData.getBoolean('printPdfAsImageEnabled')); 295 loadTimeData.getBoolean('printPdfAsImageEnabled'));
296 } 296 }
297 297
298
299 // Page layout has zero top and bottom margins. Hide header and footer option.
300 TEST_F('PrintPreviewWebUITest',
301 'ZeroTopAndBottomMarginsHideHeaderFooter',
302 function() {
303 this.setInitialSettings();
304 this.nativeLayer_.whenCalled('getInitialSettings').then(
305 function() {
306 this.setLocalDestinations();
307 this.setCapabilities(getCddTemplate("FooDevice"));
308
309 var otherOptions = $('other-options-settings');
310 var headerFooter =
311 otherOptions.querySelector('#header-footer-container');
312
313 // Check that options are collapsed (section is visible, because duplex
314 // is available).
315 checkSectionVisible(otherOptions, true);
316 checkElementDisplayed(headerFooter, false);
317
318 this.expandMoreSettings();
319
320 checkElementDisplayed(headerFooter, true);
321
322 this.printPreview_.printTicketStore_.marginsType.updateValue(
323 print_preview.ticket_items.MarginsTypeValue.CUSTOM);
324 this.printPreview_.printTicketStore_.customMargins.updateValue(
325 new print_preview.Margins(0, 36, 0, 36));
326
327 checkElementDisplayed(headerFooter, false);
328
329 this.waitForAnimationToEnd('more-settings');
330 }.bind(this));
331 });
332
333 // Page layout has zero top and half-inch bottom margin. Show header and footer
334 // option.
335 TEST_F('PrintPreviewWebUITest',
336 'ZeroTopAndNonZeroBottomMarginShowHeaderFooter',
337 function() {
338 this.setInitialSettings();
339 this.nativeLayer_.whenCalled('getInitialSettings').then(
340 function() {
341 this.setLocalDestinations();
342 this.setCapabilities(getCddTemplate("FooDevice"));
343
344 var otherOptions = $('other-options-settings');
345 var headerFooter =
346 otherOptions.querySelector('#header-footer-container');
347
348 // Check that options are collapsed (section is visible, because duplex
349 // is available).
350 checkSectionVisible(otherOptions, true);
351 checkElementDisplayed(headerFooter, false);
352
353 this.expandMoreSettings();
354
355 checkElementDisplayed(headerFooter, true);
356
357 this.printPreview_.printTicketStore_.marginsType.updateValue(
358 print_preview.ticket_items.MarginsTypeValue.CUSTOM);
359 this.printPreview_.printTicketStore_.customMargins.updateValue(
360 new print_preview.Margins(0, 36, 36, 36));
361
362 checkElementDisplayed(headerFooter, true);
363
364 this.waitForAnimationToEnd('more-settings');
365 }.bind(this));
366 });
367
368 // Check header footer availability with small (label) page size.
369 TEST_F('PrintPreviewWebUITest', 'SmallPaperSizeHeaderFooter', function() {
370 this.setInitialSettings();
371 this.nativeLayer_.whenCalled('getInitialSettings').then(
372 function() {
373 this.setLocalDestinations();
374 var device = getCddTemplate("FooDevice");
375 device.capabilities.printer.media_size = {
376 "option": [
377 {"name": "SmallLabel", "width_microns": 38100,
378 "height_microns": 12700, "is_default": false},
379 {"name": "BigLabel", "width_microns": 50800,
380 "height_microns": 76200, "is_default": true}
381 ]
382 };
383 this.setCapabilities(device);
384
385 var otherOptions = $('other-options-settings');
386 var headerFooter =
387 otherOptions.querySelector('#header-footer-container');
388
389 // Check that options are collapsed (section is visible, because duplex
390 // is available).
391 checkSectionVisible(otherOptions, true);
392 checkElementDisplayed(headerFooter, false);
393
394 this.expandMoreSettings();
395
396 // Big label should have header/footer
397 checkElementDisplayed(headerFooter, true);
398
399 // Small label should not
400 this.printPreview_.printTicketStore_.mediaSize.updateValue(
401 device.capabilities.printer.media_size.option[0]);
402 checkElementDisplayed(headerFooter, false);
403
404 // Oriented in landscape, there should be enough space for
405 // header/footer.
406 this.printPreview_.printTicketStore_.landscape.updateValue(true);
407 checkElementDisplayed(headerFooter, true);
408
409 this.waitForAnimationToEnd('more-settings');
410 }.bind(this));
411 });
412
413 // Test that the color settings, one option, standard monochrome.
414 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsMonochrome', function() {
415 this.setInitialSettings();
416 this.nativeLayer_.whenCalled('getInitialSettings').then(
417 function() {
418 this.setLocalDestinations();
419
420 // Only one option, standard monochrome.
421 var device = getCddTemplate("FooDevice");
422 device.capabilities.printer.color = {
423 "option": [
424 {"is_default": true, "type": "STANDARD_MONOCHROME"}
425 ]
426 };
427 this.setCapabilities(device);
428
429 checkSectionVisible($('color-settings'), false);
430
431 this.waitForAnimationToEnd('more-settings');
432 }.bind(this));
433 });
434
435 // Test that the color settings, one option, custom monochrome.
436 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomMonochrome',
437 function() {
438 this.setInitialSettings();
439 this.nativeLayer_.whenCalled('getInitialSettings').then(
440 function() {
441 this.setLocalDestinations();
442
443 // Only one option, standard monochrome.
444 var device = getCddTemplate("FooDevice");
445 device.capabilities.printer.color = {
446 "option": [
447 {"is_default": true, "type": "CUSTOM_MONOCHROME",
448 "vendor_id": "42"}
449 ]
450 };
451 this.setCapabilities(device);
452
453 checkSectionVisible($('color-settings'), false);
454
455 this.waitForAnimationToEnd('more-settings');
456 }.bind(this));
457 });
458
459 // Test that the color settings, one option, standard color.
460 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsColor', function() {
461 this.setInitialSettings();
462 this.nativeLayer_.whenCalled('getInitialSettings').then(
463 function() {
464 this.setLocalDestinations();
465
466 var device = getCddTemplate("FooDevice");
467 device.capabilities.printer.color = {
468 "option": [
469 {"is_default": true, "type": "STANDARD_COLOR"}
470 ]
471 };
472 this.setCapabilities(device);
473
474 checkSectionVisible($('color-settings'), false);
475
476 this.waitForAnimationToEnd('more-settings');
477 }.bind(this));
478 });
479
480 // Test that the color settings, one option, custom color.
481 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomColor', function() {
482 this.setInitialSettings();
483 this.nativeLayer_.whenCalled('getInitialSettings').then(
484 function() {
485 this.setLocalDestinations();
486
487 var device = getCddTemplate("FooDevice");
488 device.capabilities.printer.color = {
489 "option": [
490 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "42"}
491 ]
492 };
493 this.setCapabilities(device);
494
495 checkSectionVisible($('color-settings'), false);
496
497 this.waitForAnimationToEnd('more-settings');
498 }.bind(this));
499 });
500
501 // Test that the color settings, two options, both standard, defaults to color.
502 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsBothStandardDefaultColor',
503 function() {
504 this.setInitialSettings();
505 this.nativeLayer_.whenCalled('getInitialSettings').then(
506 function() {
507 this.setLocalDestinations();
508
509 var device = getCddTemplate("FooDevice");
510 device.capabilities.printer.color = {
511 "option": [
512 {"type": "STANDARD_MONOCHROME"},
513 {"is_default": true, "type": "STANDARD_COLOR"}
514 ]
515 };
516 this.setCapabilities(device);
517
518 checkSectionVisible($('color-settings'), true);
519 expectEquals(
520 'color',
521 $('color-settings').querySelector('.color-settings-select').value);
522
523 this.waitForAnimationToEnd('more-settings');
524 }.bind(this));
525 });
526
527 // Test that the color settings, two options, both standard, defaults to
528 // monochrome.
529 TEST_F('PrintPreviewWebUITest',
530 'TestColorSettingsBothStandardDefaultMonochrome', function() {
531 this.setInitialSettings();
532 this.nativeLayer_.whenCalled('getInitialSettings').then(
533 function() {
534 this.setLocalDestinations();
535
536 var device = getCddTemplate("FooDevice");
537 device.capabilities.printer.color = {
538 "option": [
539 {"is_default": true, "type": "STANDARD_MONOCHROME"},
540 {"type": "STANDARD_COLOR"}
541 ]
542 };
543 this.setCapabilities(device);
544
545 checkSectionVisible($('color-settings'), true);
546 expectEquals(
547 'bw',
548 $('color-settings').querySelector('.color-settings-select').value);
549
550 this.waitForAnimationToEnd('more-settings');
551 }.bind(this));
552 });
553
554 // Test that the color settings, two options, both custom, defaults to color.
555 TEST_F('PrintPreviewWebUITest',
556 'TestColorSettingsBothCustomDefaultColor', function() {
557 this.setInitialSettings();
558 this.nativeLayer_.whenCalled('getInitialSettings').then(
559 function() {
560 this.setLocalDestinations();
561
562 var device = getCddTemplate("FooDevice");
563 device.capabilities.printer.color = {
564 "option": [
565 {"type": "CUSTOM_MONOCHROME", "vendor_id": "42"},
566 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "43"}
567 ]
568 };
569 this.setCapabilities(device);
570
571 checkSectionVisible($('color-settings'), true);
572 expectEquals(
573 'color',
574 $('color-settings').querySelector('.color-settings-select').value);
575
576 this.waitForAnimationToEnd('more-settings');
577 }.bind(this));
578 });
579
580 // Test to verify that duplex settings are set according to the printer 298 // Test to verify that duplex settings are set according to the printer
581 // capabilities. 299 // capabilities.
582 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() { 300 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() {
583 this.setInitialSettings(); 301 this.setInitialSettings();
584 this.nativeLayer_.whenCalled('getInitialSettings').then( 302 this.nativeLayer_.whenCalled('getInitialSettings').then(
585 function() { 303 function() {
586 this.setLocalDestinations(); 304 this.setLocalDestinations();
587 this.setCapabilities(getCddTemplate("FooDevice")); 305 this.setCapabilities(getCddTemplate("FooDevice"));
588 306
589 var otherOptions = $('other-options-settings'); 307 var otherOptions = $('other-options-settings');
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 expectFalse(this.generateDraft()); 727 expectFalse(this.generateDraft());
1010 728
1011 // Change the margin type - need to regenerate again. 729 // Change the margin type - need to regenerate again.
1012 this.printPreview_.printTicketStore_.marginsType.updateValue( 730 this.printPreview_.printTicketStore_.marginsType.updateValue(
1013 print_preview.ticket_items.MarginsTypeValue.NO_MARGINS); 731 print_preview.ticket_items.MarginsTypeValue.NO_MARGINS);
1014 expectTrue(this.generateDraft()); 732 expectTrue(this.generateDraft());
1015 733
1016 testDone(); 734 testDone();
1017 }.bind(this)); 735 }.bind(this));
1018 }); 736 });
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/webui/print_preview/print_preview_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698