Chromium Code Reviews| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 window.addEventListener('DOMContentLoaded', function() { | 86 window.addEventListener('DOMContentLoaded', function() { |
| 87 function NativeLayerStub() { | 87 function NativeLayerStub() { |
| 88 cr.EventTarget.call(this); | 88 cr.EventTarget.call(this); |
| 89 } | 89 } |
| 90 NativeLayerStub.prototype = { | 90 NativeLayerStub.prototype = { |
| 91 __proto__: cr.EventTarget.prototype, | 91 __proto__: cr.EventTarget.prototype, |
| 92 startGetInitialSettings: function() {}, | 92 startGetInitialSettings: function() {}, |
| 93 startGetLocalDestinations: function() {}, | 93 startGetLocalDestinations: function() {}, |
| 94 startGetPrivetDestinations: function() {}, | 94 startGetPrivetDestinations: function() {}, |
| 95 startGetExtensionDestinations: function() {}, | 95 startGetExtensionDestinations: function() {}, |
| 96 startGetLocalDestinationCapabilities: function(destinationId) {} | 96 startGetLocalDestinationCapabilities: function(destinationId) {}, |
| 97 startGetPreview: function() {}, | |
| 97 }; | 98 }; |
| 98 var oldNativeLayerEventType = print_preview.NativeLayer.EventType; | 99 var oldNativeLayerEventType = print_preview.NativeLayer.EventType; |
| 99 var oldDuplexMode = print_preview.NativeLayer.DuplexMode; | 100 var oldDuplexMode = print_preview.NativeLayer.DuplexMode; |
| 100 print_preview.NativeLayer = NativeLayerStub; | 101 print_preview.NativeLayer = NativeLayerStub; |
| 101 print_preview.NativeLayer.EventType = oldNativeLayerEventType; | 102 print_preview.NativeLayer.EventType = oldNativeLayerEventType; |
| 102 print_preview.NativeLayer.DuplexMode = oldDuplexMode; | 103 print_preview.NativeLayer.DuplexMode = oldDuplexMode; |
| 103 | 104 |
| 104 function CloudPrintInterfaceStub() { | 105 function CloudPrintInterfaceStub() { |
| 105 cr.EventTarget.call(this); | 106 cr.EventTarget.call(this); |
| 106 } | 107 } |
| (...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1272 // Check advanced settings is visible and that the search box now | 1273 // Check advanced settings is visible and that the search box now |
| 1273 // appears. | 1274 // appears. |
| 1274 var advancedSettingsCloseButton = $('advanced-settings'). | 1275 var advancedSettingsCloseButton = $('advanced-settings'). |
| 1275 querySelector('.close-button'); | 1276 querySelector('.close-button'); |
| 1276 checkElementDisplayed(advancedSettingsCloseButton, true); | 1277 checkElementDisplayed(advancedSettingsCloseButton, true); |
| 1277 checkElementDisplayed($('advanced-settings'). | 1278 checkElementDisplayed($('advanced-settings'). |
| 1278 querySelector('.search-box-area'), true); | 1279 querySelector('.search-box-area'), true); |
| 1279 | 1280 |
| 1280 this.waitForAnimationToEnd('more-settings'); | 1281 this.waitForAnimationToEnd('more-settings'); |
| 1281 }); | 1282 }); |
| 1283 | |
| 1284 // Test that initialization with saved destination only issues one call | |
| 1285 // to startPreview. | |
| 1286 TEST_F('PrintPreviewWebUITest', 'TestInitIssuesOneRequest', function() { | |
| 1287 // Load in a bunch of recent destinations with non null capabilities. | |
| 1288 origin = cr.isChromeOS ? 'chrome_os' : 'local'; | |
|
dpapad
2017/01/14 02:37:00
var origin
rbpotter
2017/01/17 19:51:24
Done.
| |
| 1289 var initSettings = { | |
| 1290 version: 2, | |
| 1291 recentDestinations: [1, 2, 3].map(function(i) { | |
| 1292 return { | |
| 1293 id: 'ID' + i, origin: origin, account: '', | |
| 1294 capabilities: getCddTemplate('ID' + i), name: '', | |
| 1295 extensionId: '', extensionName: '' | |
| 1296 }; | |
| 1297 }), | |
| 1298 }; | |
| 1299 this.initialSettings_.serializedAppStateStr_ = JSON.stringify(initSettings); | |
| 1300 this.setCapabilities(getCddTemplate('ID1')); | |
| 1301 this.setCapabilities(getCddTemplate('ID2')); | |
| 1302 this.setCapabilities(getCddTemplate('ID3')); | |
| 1303 | |
| 1304 // Use a real preview generator. | |
| 1305 printPreview.previewArea_.previewGenerator_ = | |
| 1306 new print_preview.PreviewGenerator(printPreview.destinationStore_, | |
|
dpapad
2017/01/14 02:37:00
indent off by -2
rbpotter
2017/01/17 19:51:24
Done.
| |
| 1307 printPreview.printTicketStore_, this.nativeLayer_, | |
| 1308 printPreview.documentInfo_); | |
| 1309 | |
| 1310 // Preview generator starts out with inFlightRequestId_ == -1. The id | |
| 1311 // increments by 1 for each startGetPreview call it makes. It should only | |
| 1312 // make one such call during initialization or there will be a race; see | |
| 1313 // crbug.com/666595 | |
| 1314 expectEquals(printPreview.previewArea_.previewGenerator_.inFlightRequestId_, | |
| 1315 -1); | |
| 1316 this.setInitialSettings(); | |
| 1317 expectEquals(printPreview.previewArea_.previewGenerator_.inFlightRequestId_, | |
| 1318 0); | |
| 1319 testDone(); | |
| 1320 }); | |
| OLD | NEW |