| 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 /** | 5 /** |
| 6 * Test fixture for print preview WebUI testing. | 6 * Test fixture for print preview WebUI testing. |
| 7 * @constructor | 7 * @constructor |
| 8 * @extends {testing.Test} | 8 * @extends {testing.Test} |
| 9 */ | 9 */ |
| 10 function PrintPreviewWebUITest() { | 10 function PrintPreviewWebUITest() { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 preLoad: function() { | 63 preLoad: function() { |
| 64 window.addEventListener('DOMContentLoaded', function() { | 64 window.addEventListener('DOMContentLoaded', function() { |
| 65 function NativeLayerStub() { | 65 function NativeLayerStub() { |
| 66 cr.EventTarget.call(this); | 66 cr.EventTarget.call(this); |
| 67 } | 67 } |
| 68 NativeLayerStub.prototype = { | 68 NativeLayerStub.prototype = { |
| 69 __proto__: cr.EventTarget.prototype, | 69 __proto__: cr.EventTarget.prototype, |
| 70 startGetInitialSettings: function() {}, | 70 startGetInitialSettings: function() {}, |
| 71 startGetLocalDestinations: function() {}, | 71 startGetLocalDestinations: function() {}, |
| 72 startGetPrivetDestinations: function() {}, | 72 startGetPrivetDestinations: function() {}, |
| 73 startGetExtensionDestinations: function() {}, |
| 73 startGetLocalDestinationCapabilities: function(destinationId) {} | 74 startGetLocalDestinationCapabilities: function(destinationId) {} |
| 74 }; | 75 }; |
| 75 var oldNativeLayerEventType = print_preview.NativeLayer.EventType; | 76 var oldNativeLayerEventType = print_preview.NativeLayer.EventType; |
| 76 var oldDuplexMode = print_preview.NativeLayer.DuplexMode; | 77 var oldDuplexMode = print_preview.NativeLayer.DuplexMode; |
| 77 print_preview.NativeLayer = NativeLayerStub; | 78 print_preview.NativeLayer = NativeLayerStub; |
| 78 print_preview.NativeLayer.EventType = oldNativeLayerEventType; | 79 print_preview.NativeLayer.EventType = oldNativeLayerEventType; |
| 79 print_preview.NativeLayer.DuplexMode = oldDuplexMode; | 80 print_preview.NativeLayer.DuplexMode = oldDuplexMode; |
| 80 | 81 |
| 81 function CloudPrintInterfaceStub() { | 82 function CloudPrintInterfaceStub() { |
| 82 cr.EventTarget.call(this); | 83 cr.EventTarget.call(this); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 false /*hidePrintWithSystemDialogLink*/, | 174 false /*hidePrintWithSystemDialogLink*/, |
| 174 ',' /*thousandsDelimeter*/, | 175 ',' /*thousandsDelimeter*/, |
| 175 '.' /*decimalDelimeter*/, | 176 '.' /*decimalDelimeter*/, |
| 176 1 /*unitType*/, | 177 1 /*unitType*/, |
| 177 true /*isDocumentModifiable*/, | 178 true /*isDocumentModifiable*/, |
| 178 'title' /*documentTitle*/, | 179 'title' /*documentTitle*/, |
| 179 true /*documentHasSelection*/, | 180 true /*documentHasSelection*/, |
| 180 false /*selectionOnly*/, | 181 false /*selectionOnly*/, |
| 181 'FooDevice' /*systemDefaultDestinationId*/, | 182 'FooDevice' /*systemDefaultDestinationId*/, |
| 182 null /*serializedAppStateStr*/, | 183 null /*serializedAppStateStr*/, |
| 183 false /*documentHasSelection*/); | 184 null /*serializedDefaultDestinationSelectionRulesStr*/); |
| 184 this.localDestinationInfos_ = [ | 185 this.localDestinationInfos_ = [ |
| 185 { printerName: 'FooName', deviceName: 'FooDevice' }, | 186 { printerName: 'FooName', deviceName: 'FooDevice' }, |
| 186 { printerName: 'BarName', deviceName: 'BarDevice' } | 187 { printerName: 'BarName', deviceName: 'BarDevice' } |
| 187 ]; | 188 ]; |
| 188 this.nativeLayer_ = printPreview.nativeLayer_; | 189 this.nativeLayer_ = printPreview.nativeLayer_; |
| 189 | 190 |
| 190 testing.Test.disableAnimationsAndTransitions(); | 191 testing.Test.disableAnimationsAndTransitions(); |
| 191 } | 192 } |
| 192 }; | 193 }; |
| 193 | 194 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreLocalDestination', | 332 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreLocalDestination', |
| 332 function() { | 333 function() { |
| 333 this.initialSettings_.serializedAppStateStr_ = | 334 this.initialSettings_.serializedAppStateStr_ = |
| 334 '{"version":2,"selectedDestinationId":"ID",' + | 335 '{"version":2,"selectedDestinationId":"ID",' + |
| 335 '"selectedDestinationOrigin":"local"}'; | 336 '"selectedDestinationOrigin":"local"}'; |
| 336 this.setInitialSettings(); | 337 this.setInitialSettings(); |
| 337 | 338 |
| 338 testDone(); | 339 testDone(); |
| 339 }); | 340 }); |
| 340 | 341 |
| 342 TEST_F('PrintPreviewWebUITest', |
| 343 'TestPrintPreviewDefaultDestinationSelectionRules', function() { |
| 344 // It also makes sure these rules do override system default destination. |
| 345 this.initialSettings_.serializedDefaultDestinationSelectionRulesStr_ = |
| 346 '{"namePattern":".*Bar.*"}'; |
| 347 this.setInitialSettings(); |
| 348 this.setLocalDestinations(); |
| 349 |
| 350 assertEquals( |
| 351 'BarDevice', printPreview.destinationStore_.selectedDestination.id); |
| 352 |
| 353 testDone(); |
| 354 }); |
| 355 |
| 341 TEST_F('PrintPreviewWebUITest', 'TestSystemDialogLinkIsHiddenInAppKioskMode', | 356 TEST_F('PrintPreviewWebUITest', 'TestSystemDialogLinkIsHiddenInAppKioskMode', |
| 342 function() { | 357 function() { |
| 343 if (cr.isChromeOS) { | 358 if (cr.isChromeOS) { |
| 344 assertEquals(null, $('system-dialog-link')); | 359 assertEquals(null, $('system-dialog-link')); |
| 345 } else { | 360 } else { |
| 346 this.initialSettings_.isInAppKioskMode_ = true; | 361 this.initialSettings_.isInAppKioskMode_ = true; |
| 347 this.setInitialSettings(); | 362 this.setInitialSettings(); |
| 348 | 363 |
| 349 checkElementDisplayed($('system-dialog-link'), false); | 364 checkElementDisplayed($('system-dialog-link'), false); |
| 350 } | 365 } |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 expectEquals( | 968 expectEquals( |
| 954 customLocalizedMediaName, | 969 customLocalizedMediaName, |
| 955 mediaSelect.options[mediaSelect.selectedIndex].text); | 970 mediaSelect.options[mediaSelect.selectedIndex].text); |
| 956 // Check the other media item. | 971 // Check the other media item. |
| 957 expectEquals( | 972 expectEquals( |
| 958 customMediaName, | 973 customMediaName, |
| 959 mediaSelect.options[mediaSelect.selectedIndex == 0 ? 1 : 0].text); | 974 mediaSelect.options[mediaSelect.selectedIndex == 0 ? 1 : 0].text); |
| 960 | 975 |
| 961 this.waitForAnimationToEnd('more-settings'); | 976 this.waitForAnimationToEnd('more-settings'); |
| 962 }); | 977 }); |
| OLD | NEW |