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 * @extends {testing.Test} | 7 * @extends {testing.Test} |
8 * @constructor | 8 * @constructor |
9 */ | 9 */ |
10 function PrintPreviewWebUITest() {} | 10 function PrintPreviewWebUITest() {} |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 }); | 263 }); |
264 })); | 264 })); |
265 | 265 |
266 updateControlsWithSelectedPrinterCapabilities(); | 266 updateControlsWithSelectedPrinterCapabilities(); |
267 | 267 |
268 checkSectionVisible(layoutSettings.layoutOption_, false); | 268 checkSectionVisible(layoutSettings.layoutOption_, false); |
269 checkSectionVisible(colorSettings.colorOption_, false); | 269 checkSectionVisible(colorSettings.colorOption_, false); |
270 checkSectionVisible(copiesSettings.copiesOption_, false); | 270 checkSectionVisible(copiesSettings.copiesOption_, false); |
271 }); | 271 }); |
272 | 272 |
| 273 // Page layout has zero margins. Hide header and footer option. |
| 274 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasNoMarginsHideHeaderFooter', |
| 275 function() { |
| 276 setInitialSettings({previewModifiable: true}); |
| 277 onDidGetDefaultPageLayout({ |
| 278 contentWidth: 100, |
| 279 contentHeight: 200, |
| 280 marginLeft: 0, |
| 281 marginRight: 0, |
| 282 marginTop: 0, |
| 283 marginBottom: 0}, {x: 0, y: 0, width: 100, height: 200}, true); |
| 284 checkSectionVisible(headerFooterSettings.headerFooterOption_, false); |
| 285 }); |
| 286 |
| 287 // Page layout has non-zero margins. Show header and footer option. |
| 288 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasMarginsShowHeaderFooter', |
| 289 function() { |
| 290 setInitialSettings({previewModifiable: true}); |
| 291 onDidGetDefaultPageLayout({ |
| 292 contentWidth: 100, |
| 293 contentHeight: 200, |
| 294 marginLeft: 3, |
| 295 marginRight: 2, |
| 296 marginTop: 4, |
| 297 marginBottom: 1}, {x: 1, y: 1, width: 103, height: 203}, true); |
| 298 checkSectionVisible(headerFooterSettings.headerFooterOption_, true); |
| 299 }); |
| 300 |
| 301 // Page layout has zero top and bottom margins. Hide header and footer option. |
| 302 TEST_F('PrintPreviewWebUITest', 'ZeroTopAndBottomMarginsHideHeaderFooter', |
| 303 function() { |
| 304 setInitialSettings({previewModifiable: true}); |
| 305 onDidGetDefaultPageLayout({ |
| 306 contentWidth: 100, |
| 307 contentHeight: 200, |
| 308 marginLeft: 3, |
| 309 marginRight: 2, |
| 310 marginTop: 0, |
| 311 marginBottom: 0}, {x: 1, y: 1, width: 98, height: 198}, false); |
| 312 checkSectionVisible(headerFooterSettings.headerFooterOption_, false); |
| 313 }); |
| 314 |
| 315 // Page layout has zero top and non-zero bottom margin. Show header and footer |
| 316 // option. |
| 317 TEST_F('PrintPreviewWebUITest', 'ZeroTopAndNonZeroBottomMarginShowHeaderFooter', |
| 318 function() { |
| 319 setInitialSettings({previewModifiable: true}); |
| 320 onDidGetDefaultPageLayout({ |
| 321 contentWidth: 100, |
| 322 contentHeight: 200, |
| 323 marginLeft: 6, |
| 324 marginRight: 4, |
| 325 marginTop: 0, |
| 326 marginBottom: 3}, {x: 1, y: 1, width: 103, height: 208}, false); |
| 327 checkSectionVisible(headerFooterSettings.headerFooterOption_, true); |
| 328 }); |
| 329 |
273 // Test that the color settings are set according to the printer capabilities. | 330 // Test that the color settings are set according to the printer capabilities. |
274 TEST_F('PrintPreviewWebUITest', 'TestColorSettings', function() { | 331 TEST_F('PrintPreviewWebUITest', 'TestColorSettings', function() { |
275 this.mockHandler.expects(once()).getPrinterCapabilities('FooDevice'). | 332 this.mockHandler.expects(once()).getPrinterCapabilities('FooDevice'). |
276 will(callFunction(function() { | 333 will(callFunction(function() { |
277 updateWithPrinterCapabilities({ | 334 updateWithPrinterCapabilities({ |
278 disableColorOption: false, | 335 disableColorOption: false, |
279 setColorAsDefault: true, | 336 setColorAsDefault: true, |
280 disableCopiesOption: false, | 337 disableCopiesOption: false, |
281 disableLandscapeOption: false, | 338 disableLandscapeOption: false, |
282 printerDefaultDuplexValue: print_preview.CopiesSettings.SIMPLEX, | 339 printerDefaultDuplexValue: print_preview.CopiesSettings.SIMPLEX, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 | 466 |
410 // Test that error message is displayed when plugin doesn't exist. | 467 // Test that error message is displayed when plugin doesn't exist. |
411 TEST_F('PrintPreviewNoPDFWebUITest', 'TestErrorMessage', function() { | 468 TEST_F('PrintPreviewNoPDFWebUITest', 'TestErrorMessage', function() { |
412 var errorButton = $('error-button'); | 469 var errorButton = $('error-button'); |
413 assertNotEquals(null, errorButton); | 470 assertNotEquals(null, errorButton); |
414 expectFalse(errorButton.disabled); | 471 expectFalse(errorButton.disabled); |
415 var errorText = $('custom-message'); | 472 var errorText = $('custom-message'); |
416 assertNotEquals(null, errorText); | 473 assertNotEquals(null, errorText); |
417 expectFalse(errorText.hidden); | 474 expectFalse(errorText.hidden); |
418 }); | 475 }); |
OLD | NEW |