| OLD | NEW |
| 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 GEN('#include "base/feature_list.h"'); | 5 GEN('#include "base/feature_list.h"'); |
| 6 GEN('#include "chrome/common/chrome_features.h"'); | 6 GEN('#include "chrome/common/chrome_features.h"'); |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Test fixture for print preview WebUI testing. | 9 * Test fixture for print preview WebUI testing. |
| 10 * @constructor | 10 * @constructor |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 /** @override */ | 52 /** @override */ |
| 53 runAccessibilityChecks: true, | 53 runAccessibilityChecks: true, |
| 54 | 54 |
| 55 /** @override */ | 55 /** @override */ |
| 56 accessibilityIssuesAreErrors: true, | 56 accessibilityIssuesAreErrors: true, |
| 57 | 57 |
| 58 /** @override */ | 58 /** @override */ |
| 59 isAsync: true, | 59 isAsync: true, |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * @override | |
| 63 */ | |
| 64 testGenPreamble: function() { | |
| 65 // Enable print as image for tests on non Windows/Mac. | |
| 66 GEN('#if !defined(OS_WINDOWS) && !defined(OS_MACOSX)'); | |
| 67 GEN(' base::FeatureList::ClearInstanceForTesting();'); | |
| 68 GEN(' std::unique_ptr<base::FeatureList>'); | |
| 69 GEN(' feature_list(new base::FeatureList);'); | |
| 70 GEN(' feature_list->InitializeFromCommandLine('); | |
| 71 GEN(' features::kPrintPdfAsImage.name, std::string());'); | |
| 72 GEN(' base::FeatureList::SetInstance(std::move(feature_list));'); | |
| 73 GEN('#endif'); | |
| 74 }, | |
| 75 | |
| 76 /** | |
| 77 * Stub out low-level functionality like the NativeLayer and | 62 * Stub out low-level functionality like the NativeLayer and |
| 78 * CloudPrintInterface. | 63 * CloudPrintInterface. |
| 79 * @this {PrintPreviewWebUITest} | 64 * @this {PrintPreviewWebUITest} |
| 80 * @override | 65 * @override |
| 81 */ | 66 */ |
| 82 preLoad: function() { | 67 preLoad: function() { |
| 83 window.addEventListener('DOMContentLoaded', function() { | 68 window.addEventListener('DOMContentLoaded', function() { |
| 84 function NativeLayerStub() { | 69 function NativeLayerStub() { |
| 85 cr.EventTarget.call(this); | 70 cr.EventTarget.call(this); |
| 86 this.printStarted_ = false; | 71 this.printStarted_ = false; |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 is_default: true | 399 is_default: true |
| 415 } | 400 } |
| 416 ] | 401 ] |
| 417 } | 402 } |
| 418 } | 403 } |
| 419 } | 404 } |
| 420 }; | 405 }; |
| 421 } | 406 } |
| 422 | 407 |
| 423 function isPrintAsImageEnabled() { | 408 function isPrintAsImageEnabled() { |
| 424 return !cr.isWindows && !cr.isMac; | 409 // Should be enabled by default on non Windows/Mac |
| 410 return (!cr.isWindows && !cr.isMac && |
| 411 loadTimeData.getBoolean('printPdfAsImageEnabled')); |
| 425 } | 412 } |
| 426 | 413 |
| 427 // Test restore settings with one destination. | 414 // Test restore settings with one destination. |
| 428 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreLocalDestination', | 415 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreLocalDestination', |
| 429 function() { | 416 function() { |
| 430 this.initialSettings_.serializedAppStateStr_ = | 417 this.initialSettings_.serializedAppStateStr_ = |
| 431 '{"version":2,"recentDestinations":[{"id":"ID", "origin":"local",' + | 418 '{"version":2,"recentDestinations":[{"id":"ID", "origin":"local",' + |
| 432 '"account":"", "capabilities":0, "name":"", "extensionId":"",' + | 419 '"account":"", "capabilities":0, "name":"", "extensionId":"",' + |
| 433 '"extensionName":""}]}'; | 420 '"extensionName":""}]}'; |
| 434 this.setInitialSettings(); | 421 this.setInitialSettings(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 this.setCapabilities(getCddTemplate('ID3')); | 471 this.setCapabilities(getCddTemplate('ID3')); |
| 485 this.setCapabilities(getCddTemplate('ID4')); | 472 this.setCapabilities(getCddTemplate('ID4')); |
| 486 | 473 |
| 487 // The most recently used destination should be the currently selected one. | 474 // The most recently used destination should be the currently selected one. |
| 488 // This is ID1. | 475 // This is ID1. |
| 489 assertEquals( | 476 assertEquals( |
| 490 'ID1', printPreview.destinationStore_.selectedDestination.id); | 477 'ID1', printPreview.destinationStore_.selectedDestination.id); |
| 491 | 478 |
| 492 // Look through the destinations. ID1, ID2, and ID3 should all be recent. | 479 // Look through the destinations. ID1, ID2, and ID3 should all be recent. |
| 493 var destinations = printPreview.destinationStore_.destinations_; | 480 var destinations = printPreview.destinationStore_.destinations_; |
| 494 var ids_found = []; | 481 var idsFound = []; |
| 495 | 482 |
| 496 for (var i = 0; i < destinations.length; i++) { | 483 for (var i = 0; i < destinations.length; i++) { |
| 497 if (!destinations[i]) | 484 if (!destinations[i]) |
| 498 continue; | 485 continue; |
| 499 if (destinations[i].isRecent) | 486 if (destinations[i].isRecent) |
| 500 ids_found.push(destinations[i].id); | 487 idsFound.push(destinations[i].id); |
| 501 } | 488 } |
| 502 | 489 |
| 503 // Make sure there were 3 recent destinations and that they are the correct | 490 // Make sure there were 3 recent destinations and that they are the correct |
| 504 // IDs. | 491 // IDs. |
| 505 assertEquals(3, ids_found.length); | 492 assertEquals(3, idsFound.length); |
| 506 assertNotEquals(-1, ids_found.indexOf("ID1")); | 493 assertNotEquals(-1, idsFound.indexOf("ID1")); |
| 507 assertNotEquals(-1, ids_found.indexOf("ID2")); | 494 assertNotEquals(-1, idsFound.indexOf("ID2")); |
| 508 assertNotEquals(-1, ids_found.indexOf("ID3")); | 495 assertNotEquals(-1, idsFound.indexOf("ID3")); |
| 509 | 496 |
| 510 testDone(); | 497 testDone(); |
| 511 }); | 498 }); |
| 512 | 499 |
| 513 TEST_F('PrintPreviewWebUITest', | 500 TEST_F('PrintPreviewWebUITest', |
| 514 'TestPrintPreviewDefaultDestinationSelectionRules', function() { | 501 'TestPrintPreviewDefaultDestinationSelectionRules', function() { |
| 515 // It also makes sure these rules do override system default destination. | 502 // It also makes sure these rules do override system default destination. |
| 516 this.initialSettings_.serializedDefaultDestinationSelectionRulesStr_ = | 503 this.initialSettings_.serializedDefaultDestinationSelectionRulesStr_ = |
| 517 '{"namePattern":".*Bar.*"}'; | 504 '{"namePattern":".*Bar.*"}'; |
| 518 this.setInitialSettings(); | 505 this.setInitialSettings(); |
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 printPreview.printTicketStore_.pageRange.updateValue("2"); | 1472 printPreview.printTicketStore_.pageRange.updateValue("2"); |
| 1486 expectFalse(this.generateDraft()); | 1473 expectFalse(this.generateDraft()); |
| 1487 | 1474 |
| 1488 // Change the margin type - need to regenerate again. | 1475 // Change the margin type - need to regenerate again. |
| 1489 printPreview.printTicketStore_.marginsType.updateValue( | 1476 printPreview.printTicketStore_.marginsType.updateValue( |
| 1490 print_preview.ticket_items.MarginsTypeValue.NO_MARGINS); | 1477 print_preview.ticket_items.MarginsTypeValue.NO_MARGINS); |
| 1491 expectTrue(this.generateDraft()); | 1478 expectTrue(this.generateDraft()); |
| 1492 | 1479 |
| 1493 testDone(); | 1480 testDone(); |
| 1494 }); | 1481 }); |
| OLD | NEW |