| OLD | NEW |
| 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 expectEquals('FooDevice', printerList.options[fooIndex].value, | 228 expectEquals('FooDevice', printerList.options[fooIndex].value, |
| 229 'fooIndex=' + fooIndex); | 229 'fooIndex=' + fooIndex); |
| 230 expectEquals('BarName', printerList.options[barIndex].text, | 230 expectEquals('BarName', printerList.options[barIndex].text, |
| 231 'barIndex=' + barIndex); | 231 'barIndex=' + barIndex); |
| 232 expectEquals('BarDevice', printerList.options[barIndex].value, | 232 expectEquals('BarDevice', printerList.options[barIndex].value, |
| 233 'barIndex=' + barIndex); | 233 'barIndex=' + barIndex); |
| 234 }); | 234 }); |
| 235 | 235 |
| 236 // Test that the printer list is structured correctly after calling | 236 // Test that the printer list is structured correctly after calling |
| 237 // addCloudPrinters with an empty list. | 237 // addCloudPrinters with an empty list. |
| 238 TEST_F('PrintPreviewWebUITest', 'FLAKY_TestPrinterListCloudEmpty', function() { | 238 TEST_F('PrintPreviewWebUITest', 'TestPrinterListCloudEmpty', function() { |
| 239 addCloudPrinters([]); | 239 cloudprint.addCloudPrinters([], addDestinationListOptionAtPosition); |
| 240 var printerList = $('printer-list'); | 240 var printerList = $('printer-list'); |
| 241 assertNotEquals(null, printerList); | 241 assertNotEquals(null, printerList); |
| 242 expectEquals(localStrings.getString('cloudPrinters'), | |
| 243 printerList.options[0].text); | |
| 244 expectEquals(localStrings.getString('addCloudPrinter'), | |
| 245 printerList.options[1].text); | |
| 246 }); | 242 }); |
| 247 | 243 |
| 248 // Test that the printer list is structured correctly after calling | 244 // Test that the printer list is structured correctly after calling |
| 249 // addCloudPrinters with a null list. | 245 // addCloudPrinters with a null list. |
| 250 TEST_F('PrintPreviewWebUITest', 'FLAKY_TestPrinterListCloudNull', function() { | 246 TEST_F('PrintPreviewWebUITest', 'TestPrinterListCloudNull', function() { |
| 251 addCloudPrinters(null); | 247 cloudprint.addCloudPrinters(null, addDestinationListOptionAtPosition); |
| 252 var printerList = $('printer-list'); | 248 var printerList = $('printer-list'); |
| 253 assertNotEquals(null, printerList); | 249 assertNotEquals(null, printerList); |
| 254 expectEquals(localStrings.getString('cloudPrinters'), | 250 expectEquals(localStrings.getString('signIn'), |
| 255 printerList.options[0].text); | 251 printerList.options[0].text); |
| 256 expectEquals(localStrings.getString('signIn'), | |
| 257 printerList.options[1].text); | |
| 258 }); | 252 }); |
| 259 | 253 |
| 260 // Test that the printer list is structured correctly after attempting to add | 254 // Test that the printer list is structured correctly after attempting to add |
| 261 // individual cloud printers until no more can be added. | 255 // individual cloud printers until no more can be added. |
| 262 TEST_F('PrintPreviewWebUITest', 'FLAKY_TestPrinterListCloud', function() { | 256 TEST_F('PrintPreviewWebUITest', 'TestPrinterListCloud', function() { |
| 263 var printerList = $('printer-list'); | 257 var printerList = $('printer-list'); |
| 264 assertNotEquals(null, printerList); | 258 assertNotEquals(null, printerList); |
| 265 var printer = new Object; | 259 var printer = new Object; |
| 266 printer['name'] = 'FooCloud'; | 260 printer['name'] = 'FooCloud'; |
| 267 for (var i = 0; i < maxCloudPrinters; i++) { | 261 for (var i = 0; i < maxCloudPrinters; i++) { |
| 268 printer['id'] = String(i); | 262 printer['id'] = String(i); |
| 269 addCloudPrinters([printer]); | 263 cloudprint.addCloudPrinters([printer], addDestinationListOptionAtPosition); |
| 270 expectEquals(localStrings.getString('cloudPrinters'), | 264 expectEquals('FooCloud', printerList.options[i].text); |
| 271 printerList.options[0].text); | 265 expectEquals(String(i), printerList.options[i].value); |
| 272 expectEquals('FooCloud', printerList.options[i + 1].text); | |
| 273 expectEquals(String(i), printerList.options[i + 1].value); | |
| 274 } | 266 } |
| 275 printer['id'] = maxCloudPrinters + 1; | 267 cloudprint.addCloudPrinters([printer], addDestinationListOptionAtPosition); |
| 276 addCloudPrinters([printer]); | 268 expectNotEquals('FooCloud', printerList.options[i].text); |
| 277 expectEquals('', printerList.options[maxCloudPrinters + 1].text); | 269 expectNotEquals(String(i), printerList.options[i].value); |
| 278 expectEquals(localStrings.getString('morePrinters'), | 270 for (var i = 0; i < maxCloudPrinters; i++) { |
| 279 printerList.options[maxCloudPrinters + 2].text); | 271 expectEquals('FooCloud', printerList.options[i].text); |
| 272 expectEquals(String(i), printerList.options[i].value); |
| 273 } |
| 280 }); | 274 }); |
| 281 | 275 |
| 282 /** | 276 /** |
| 283 * Verify that |section| visibility matches |visible|. | 277 * Verify that |section| visibility matches |visible|. |
| 284 * @param {HTMLDivElement} section The section to check. | 278 * @param {HTMLDivElement} section The section to check. |
| 285 * @param {boolean} visible The expected state of visibility. | 279 * @param {boolean} visible The expected state of visibility. |
| 286 */ | 280 */ |
| 287 function checkSectionVisible(section, visible) { | 281 function checkSectionVisible(section, visible) { |
| 288 assertNotEquals(null, section); | 282 assertNotEquals(null, section); |
| 289 expectEquals(section.classList.contains('visible'), visible, | 283 expectEquals(section.classList.contains('visible'), visible, |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 | 440 |
| 447 // Test that error message is displayed when plugin doesn't exist. | 441 // Test that error message is displayed when plugin doesn't exist. |
| 448 TEST_F('PrintPreviewNoPDFWebUITest', 'TestErrorMessage', function() { | 442 TEST_F('PrintPreviewNoPDFWebUITest', 'TestErrorMessage', function() { |
| 449 var errorButton = $('error-button'); | 443 var errorButton = $('error-button'); |
| 450 assertNotEquals(null, errorButton); | 444 assertNotEquals(null, errorButton); |
| 451 expectFalse(errorButton.disabled); | 445 expectFalse(errorButton.disabled); |
| 452 var errorText = $('custom-message'); | 446 var errorText = $('custom-message'); |
| 453 assertNotEquals(null, errorText); | 447 assertNotEquals(null, errorText); |
| 454 expectFalse(errorText.classList.contains('hidden')); | 448 expectFalse(errorText.classList.contains('hidden')); |
| 455 }); | 449 }); |
| OLD | NEW |