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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 assertNotEquals(null, section); | 217 assertNotEquals(null, section); |
218 expectEquals( | 218 expectEquals( |
219 visible, section.classList.contains('visible'), 'section=' + section.id); | 219 visible, section.classList.contains('visible'), 'section=' + section.id); |
220 } | 220 } |
221 | 221 |
222 function checkElementDisplayed(el, isDisplayed) { | 222 function checkElementDisplayed(el, isDisplayed) { |
223 assertNotEquals(null, el); | 223 assertNotEquals(null, el); |
224 expectEquals(isDisplayed, !el.hidden); | 224 expectEquals(isDisplayed, !el.hidden); |
225 } | 225 } |
226 | 226 |
| 227 function getCddTemplate(printerId) { |
| 228 return { |
| 229 "printerId": printerId, |
| 230 "capabilities": { |
| 231 "version": "1.0", |
| 232 "printer": { |
| 233 "supported_content_type": [{"content_type": "application/pdf"}], |
| 234 "collate": {}, |
| 235 "color": { |
| 236 "option": [ |
| 237 {"is_default": true, "type": "STANDARD_COLOR"}, |
| 238 {"type": "STANDARD_MONOCHROME"} |
| 239 ] |
| 240 }, |
| 241 "copies": {}, |
| 242 "duplex": { |
| 243 "option": [ |
| 244 {"is_default": true, "type": "NO_DUPLEX"}, |
| 245 {"type": "LONG_EDGE"}, |
| 246 {"type": "SHORT_EDGE"} |
| 247 ] |
| 248 }, |
| 249 "page_orientation": { |
| 250 "option": [ |
| 251 {"is_default": true, "type": "PORTRAIT"}, |
| 252 {"type": "LANDSCAPE"}, |
| 253 {"type": "AUTO"} |
| 254 ] |
| 255 } |
| 256 } |
| 257 } |
| 258 }; |
| 259 } |
| 260 |
227 // Test that disabled settings hide the disabled sections. | 261 // Test that disabled settings hide the disabled sections. |
228 TEST_F('PrintPreviewWebUITest', 'TestSectionsDisabled', function() { | 262 TEST_F('PrintPreviewWebUITest', 'TestSectionsDisabled', function() { |
229 checkSectionVisible($('layout-settings'), false); | 263 checkSectionVisible($('layout-settings'), false); |
230 checkSectionVisible($('color-settings'), false); | 264 checkSectionVisible($('color-settings'), false); |
231 checkSectionVisible($('copies-settings'), false); | 265 checkSectionVisible($('copies-settings'), false); |
232 | 266 |
233 var initialSettingsSetEvent = | 267 var initialSettingsSetEvent = |
234 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | 268 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); |
235 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 269 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
236 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 270 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
237 | 271 |
238 var localDestsSetEvent = | 272 var localDestsSetEvent = |
239 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 273 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
240 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 274 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
241 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 275 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
242 | 276 |
243 var capsSetEvent = | 277 var capsSetEvent = |
244 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 278 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
245 capsSetEvent.settingsInfo = { | 279 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
246 'printerId': 'FooDevice', | 280 capsSetEvent.settingsInfo.capabilities.printer.color = { |
247 'disableColorOption': true, | 281 "option": [ |
248 'setColorAsDefault': true, | 282 {"is_default": true, "type": "STANDARD_COLOR"} |
249 'disableCopiesOption': true, | 283 ] |
250 'disableLandscapeOption': false, | |
251 'printerDefaultDuplexValue': 0 | |
252 }; | 284 }; |
| 285 delete capsSetEvent.settingsInfo.capabilities.printer.copies; |
253 this.nativeLayer_.dispatchEvent(capsSetEvent); | 286 this.nativeLayer_.dispatchEvent(capsSetEvent); |
254 | 287 |
255 checkSectionVisible($('layout-settings'), true); | 288 checkSectionVisible($('layout-settings'), true); |
256 checkSectionVisible($('color-settings'), false); | 289 checkSectionVisible($('color-settings'), false); |
257 checkSectionVisible($('copies-settings'), false); | 290 checkSectionVisible($('copies-settings'), false); |
258 }); | 291 }); |
259 | 292 |
260 // When the source is 'PDF' and 'Save as PDF' option is selected, we hide the | 293 // When the source is 'PDF' and 'Save as PDF' option is selected, we hide the |
261 // fit to page option. | 294 // fit to page option. |
262 TEST_F('PrintPreviewWebUITest', | 295 TEST_F('PrintPreviewWebUITest', |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 347 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
315 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 348 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
316 | 349 |
317 var localDestsSetEvent = | 350 var localDestsSetEvent = |
318 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 351 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
319 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 352 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
320 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 353 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
321 | 354 |
322 var capsSetEvent = | 355 var capsSetEvent = |
323 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 356 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
324 capsSetEvent.settingsInfo = { | 357 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
325 'printerId': 'FooDevice', | |
326 'disableColorOption': false, | |
327 'setColorAsDefault': true, | |
328 'disableCopiesOption': true, | |
329 'disableLandscapeOption': true, | |
330 'printerDefaultDuplexValue': 0 | |
331 }; | |
332 this.nativeLayer_.dispatchEvent(capsSetEvent); | 358 this.nativeLayer_.dispatchEvent(capsSetEvent); |
333 | 359 |
334 checkElementDisplayed( | 360 checkElementDisplayed( |
335 $('other-options-settings').querySelector('.fit-to-page-container'), | 361 $('other-options-settings').querySelector('.fit-to-page-container'), |
336 false); | 362 false); |
337 }); | 363 }); |
338 | 364 |
339 // When the source is "PDF", depending on the selected destination printer, we | 365 // When the source is "PDF", depending on the selected destination printer, we |
340 // show/hide the fit to page option. | 366 // show/hide the fit to page option. |
341 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFShowFitToPageOption', function() { | 367 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFShowFitToPageOption', function() { |
342 this.initialSettings_.isDocumentModifiable_ = false; | 368 this.initialSettings_.isDocumentModifiable_ = false; |
343 | 369 |
344 var initialSettingsSetEvent = | 370 var initialSettingsSetEvent = |
345 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | 371 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); |
346 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 372 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
347 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 373 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
348 | 374 |
349 var localDestsSetEvent = | 375 var localDestsSetEvent = |
350 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 376 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
351 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 377 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
352 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 378 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
353 | 379 |
354 var capsSetEvent = | 380 var capsSetEvent = |
355 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 381 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
356 capsSetEvent.settingsInfo = { | 382 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
357 'printerId': 'FooDevice', | |
358 'disableColorOption': false, | |
359 'setColorAsDefault': true, | |
360 'disableCopiesOption': true, | |
361 'disableLandscapeOption': true, | |
362 'printerDefaultDuplexValue': 0 | |
363 }; | |
364 this.nativeLayer_.dispatchEvent(capsSetEvent); | 383 this.nativeLayer_.dispatchEvent(capsSetEvent); |
365 | 384 |
366 checkElementDisplayed( | 385 checkElementDisplayed( |
367 $('other-options-settings').querySelector('.fit-to-page-container'), | 386 $('other-options-settings').querySelector('.fit-to-page-container'), |
368 true); | 387 true); |
369 expectTrue( | 388 expectTrue( |
370 $('other-options-settings').querySelector('.fit-to-page-checkbox'). | 389 $('other-options-settings').querySelector('.fit-to-page-checkbox'). |
371 checked); | 390 checked); |
372 }); | 391 }); |
373 | 392 |
374 // When the print scaling is disabled for the source "PDF", we show the fit | 393 // When the print scaling is disabled for the source "PDF", we show the fit |
375 // to page option but the state is unchecked by default. | 394 // to page option but the state is unchecked by default. |
376 TEST_F('PrintPreviewWebUITest', 'PrintScalingDisabledForPlugin', function() { | 395 TEST_F('PrintPreviewWebUITest', 'PrintScalingDisabledForPlugin', function() { |
377 this.initialSettings_.isDocumentModifiable_ = false; | 396 this.initialSettings_.isDocumentModifiable_ = false; |
378 | 397 |
379 var initialSettingsSetEvent = | 398 var initialSettingsSetEvent = |
380 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | 399 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); |
381 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 400 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
382 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 401 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
383 | 402 |
384 var localDestsSetEvent = | 403 var localDestsSetEvent = |
385 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 404 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
386 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 405 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
387 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 406 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
388 | 407 |
389 var capsSetEvent = | 408 var capsSetEvent = |
390 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 409 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
391 capsSetEvent.settingsInfo = { | 410 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
392 'printerId': 'FooDevice', | |
393 'disableColorOption': false, | |
394 'setColorAsDefault': true, | |
395 'disableCopiesOption': true, | |
396 'disableLandscapeOption': true, | |
397 'printerDefaultDuplexValue': 0 | |
398 }; | |
399 this.nativeLayer_.dispatchEvent(capsSetEvent); | 411 this.nativeLayer_.dispatchEvent(capsSetEvent); |
400 | 412 |
401 // Indicate that the PDF does not support scaling by default. | 413 // Indicate that the PDF does not support scaling by default. |
402 cr.dispatchSimpleEvent( | 414 cr.dispatchSimpleEvent( |
403 this.nativeLayer_, print_preview.NativeLayer.EventType.DISABLE_SCALING); | 415 this.nativeLayer_, print_preview.NativeLayer.EventType.DISABLE_SCALING); |
404 | 416 |
405 checkElementDisplayed( | 417 checkElementDisplayed( |
406 $('other-options-settings').querySelector('.fit-to-page-container'), | 418 $('other-options-settings').querySelector('.fit-to-page-container'), |
407 true); | 419 true); |
408 expectFalse( | 420 expectFalse( |
409 $('other-options-settings').querySelector('.fit-to-page-checkbox'). | 421 $('other-options-settings').querySelector('.fit-to-page-checkbox'). |
410 checked); | 422 checked); |
411 }); | 423 }); |
412 | 424 |
413 // Make sure that custom margins controls are properly set up. | 425 // Make sure that custom margins controls are properly set up. |
414 TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() { | 426 TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() { |
415 var initialSettingsSetEvent = | 427 var initialSettingsSetEvent = |
416 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | 428 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); |
417 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 429 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
418 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 430 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
419 | 431 |
420 var localDestsSetEvent = | 432 var localDestsSetEvent = |
421 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 433 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
422 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 434 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
423 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 435 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
424 | 436 |
425 var capsSetEvent = | 437 var capsSetEvent = |
426 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 438 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
427 capsSetEvent.settingsInfo = { | 439 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
428 'printerId': 'FooDevice', | |
429 'disableColorOption': false, | |
430 'setColorAsDefault': true, | |
431 'disableCopiesOption': true, | |
432 'disableLandscapeOption': true, | |
433 'printerDefaultDuplexValue': 0 | |
434 }; | |
435 this.nativeLayer_.dispatchEvent(capsSetEvent); | 440 this.nativeLayer_.dispatchEvent(capsSetEvent); |
436 | 441 |
437 printPreview.printTicketStore_.marginsType.updateValue( | 442 printPreview.printTicketStore_.marginsType.updateValue( |
438 print_preview.ticket_items.MarginsType.Value.CUSTOM); | 443 print_preview.ticket_items.MarginsType.Value.CUSTOM); |
439 | 444 |
440 ['left', 'top', 'right', 'bottom'].forEach(function(margin) { | 445 ['left', 'top', 'right', 'bottom'].forEach(function(margin) { |
441 var control = $('preview-area').querySelector('.margin-control-' + margin); | 446 var control = $('preview-area').querySelector('.margin-control-' + margin); |
442 assertNotEquals(null, control); | 447 assertNotEquals(null, control); |
443 var input = control.querySelector('.margin-control-textbox'); | 448 var input = control.querySelector('.margin-control-textbox'); |
444 assertTrue(input.hasAttribute('aria-label')); | 449 assertTrue(input.hasAttribute('aria-label')); |
(...skipping 10 matching lines...) Expand all Loading... |
455 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 460 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
456 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 461 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
457 | 462 |
458 var localDestsSetEvent = | 463 var localDestsSetEvent = |
459 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 464 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
460 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 465 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
461 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 466 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
462 | 467 |
463 var capsSetEvent = | 468 var capsSetEvent = |
464 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 469 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
465 capsSetEvent.settingsInfo = { | 470 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
466 'printerId': 'FooDevice', | |
467 'disableColorOption': false, | |
468 'setColorAsDefault': true, | |
469 'disableCopiesOption': true, | |
470 'disableLandscapeOption': true, | |
471 'printerDefaultDuplexValue': 0 | |
472 }; | |
473 this.nativeLayer_.dispatchEvent(capsSetEvent); | 471 this.nativeLayer_.dispatchEvent(capsSetEvent); |
474 | 472 |
475 checkElementDisplayed( | 473 checkElementDisplayed( |
476 $('other-options-settings').querySelector('.header-footer-container'), | 474 $('other-options-settings').querySelector('.header-footer-container'), |
477 true); | 475 true); |
478 | 476 |
479 printPreview.printTicketStore_.marginsType.updateValue( | 477 printPreview.printTicketStore_.marginsType.updateValue( |
480 print_preview.ticket_items.MarginsType.Value.CUSTOM); | 478 print_preview.ticket_items.MarginsType.Value.CUSTOM); |
481 printPreview.printTicketStore_.customMargins.updateValue( | 479 printPreview.printTicketStore_.customMargins.updateValue( |
482 new print_preview.Margins(0, 0, 0, 0)); | 480 new print_preview.Margins(0, 0, 0, 0)); |
(...skipping 12 matching lines...) Expand all Loading... |
495 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 493 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
496 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 494 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
497 | 495 |
498 var localDestsSetEvent = | 496 var localDestsSetEvent = |
499 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 497 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
500 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 498 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
501 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 499 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
502 | 500 |
503 var capsSetEvent = | 501 var capsSetEvent = |
504 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 502 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
505 capsSetEvent.settingsInfo = { | 503 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
506 'printerId': 'FooDevice', | |
507 'disableColorOption': false, | |
508 'setColorAsDefault': true, | |
509 'disableCopiesOption': true, | |
510 'disableLandscapeOption': true, | |
511 'printerDefaultDuplexValue': 0 | |
512 }; | |
513 this.nativeLayer_.dispatchEvent(capsSetEvent); | 504 this.nativeLayer_.dispatchEvent(capsSetEvent); |
514 | 505 |
515 checkElementDisplayed( | 506 checkElementDisplayed( |
516 $('other-options-settings').querySelector('.header-footer-container'), | 507 $('other-options-settings').querySelector('.header-footer-container'), |
517 true); | 508 true); |
518 | 509 |
519 printPreview.printTicketStore_.marginsType.updateValue( | 510 printPreview.printTicketStore_.marginsType.updateValue( |
520 print_preview.ticket_items.MarginsType.Value.CUSTOM); | 511 print_preview.ticket_items.MarginsType.Value.CUSTOM); |
521 printPreview.printTicketStore_.customMargins.updateValue( | 512 printPreview.printTicketStore_.customMargins.updateValue( |
522 new print_preview.Margins(36, 36, 36, 36)); | 513 new print_preview.Margins(36, 36, 36, 36)); |
(...skipping 12 matching lines...) Expand all Loading... |
535 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 526 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
536 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 527 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
537 | 528 |
538 var localDestsSetEvent = | 529 var localDestsSetEvent = |
539 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 530 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
540 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 531 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
541 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 532 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
542 | 533 |
543 var capsSetEvent = | 534 var capsSetEvent = |
544 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 535 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
545 capsSetEvent.settingsInfo = { | 536 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
546 'printerId': 'FooDevice', | |
547 'disableColorOption': false, | |
548 'setColorAsDefault': true, | |
549 'disableCopiesOption': true, | |
550 'disableLandscapeOption': true, | |
551 'printerDefaultDuplexValue': 0 | |
552 }; | |
553 this.nativeLayer_.dispatchEvent(capsSetEvent); | 537 this.nativeLayer_.dispatchEvent(capsSetEvent); |
554 | 538 |
555 checkElementDisplayed( | 539 checkElementDisplayed( |
556 $('other-options-settings').querySelector('.header-footer-container'), | 540 $('other-options-settings').querySelector('.header-footer-container'), |
557 true); | 541 true); |
558 | 542 |
559 printPreview.printTicketStore_.marginsType.updateValue( | 543 printPreview.printTicketStore_.marginsType.updateValue( |
560 print_preview.ticket_items.MarginsType.Value.CUSTOM); | 544 print_preview.ticket_items.MarginsType.Value.CUSTOM); |
561 printPreview.printTicketStore_.customMargins.updateValue( | 545 printPreview.printTicketStore_.customMargins.updateValue( |
562 new print_preview.Margins(0, 36, 0, 36)); | 546 new print_preview.Margins(0, 36, 0, 36)); |
(...skipping 13 matching lines...) Expand all Loading... |
576 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 560 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
577 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 561 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
578 | 562 |
579 var localDestsSetEvent = | 563 var localDestsSetEvent = |
580 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 564 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
581 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 565 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
582 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 566 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
583 | 567 |
584 var capsSetEvent = | 568 var capsSetEvent = |
585 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 569 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
586 capsSetEvent.settingsInfo = { | 570 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
587 'printerId': 'FooDevice', | |
588 'disableColorOption': false, | |
589 'setColorAsDefault': true, | |
590 'disableCopiesOption': true, | |
591 'disableLandscapeOption': true, | |
592 'printerDefaultDuplexValue': 0 | |
593 }; | |
594 this.nativeLayer_.dispatchEvent(capsSetEvent); | 571 this.nativeLayer_.dispatchEvent(capsSetEvent); |
595 | 572 |
596 checkElementDisplayed( | 573 checkElementDisplayed( |
597 $('other-options-settings').querySelector('.header-footer-container'), | 574 $('other-options-settings').querySelector('.header-footer-container'), |
598 true); | 575 true); |
599 | 576 |
600 printPreview.printTicketStore_.marginsType.updateValue( | 577 printPreview.printTicketStore_.marginsType.updateValue( |
601 print_preview.ticket_items.MarginsType.Value.CUSTOM); | 578 print_preview.ticket_items.MarginsType.Value.CUSTOM); |
602 printPreview.printTicketStore_.customMargins.updateValue( | 579 printPreview.printTicketStore_.customMargins.updateValue( |
603 new print_preview.Margins(0, 36, 36, 36)); | 580 new print_preview.Margins(0, 36, 36, 36)); |
(...skipping 10 matching lines...) Expand all Loading... |
614 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 591 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
615 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 592 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
616 | 593 |
617 var localDestsSetEvent = | 594 var localDestsSetEvent = |
618 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 595 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
619 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 596 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
620 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 597 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
621 | 598 |
622 var capsSetEvent = | 599 var capsSetEvent = |
623 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 600 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
624 capsSetEvent.settingsInfo = { | 601 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
625 'printerId': 'FooDevice', | |
626 'disableColorOption': false, | |
627 'setColorAsDefault': true, | |
628 'disableCopiesOption': false, | |
629 'disableLandscapeOption': true, | |
630 'printerDefaultDuplexValue': 0 | |
631 }; | |
632 this.nativeLayer_.dispatchEvent(capsSetEvent); | 602 this.nativeLayer_.dispatchEvent(capsSetEvent); |
633 | 603 |
634 checkSectionVisible($('color-settings'), true); | 604 checkSectionVisible($('color-settings'), true); |
635 | 605 |
636 var colorOption = $('color-settings').querySelector('.color-option'); | 606 var colorOption = $('color-settings').querySelector('.color-option'); |
637 var bwOption = $('color-settings').querySelector('.bw-option'); | 607 var bwOption = $('color-settings').querySelector('.bw-option'); |
638 expectTrue(colorOption.checked); | 608 expectTrue(colorOption.checked); |
639 expectFalse(bwOption.checked); | 609 expectFalse(bwOption.checked); |
640 }); | 610 }); |
641 | 611 |
642 //Test that the color settings are set according to the printer capabilities. | 612 //Test that the color settings are set according to the printer capabilities. |
643 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsFalse', function() { | 613 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsFalse', function() { |
644 var initialSettingsSetEvent = | 614 var initialSettingsSetEvent = |
645 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | 615 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); |
646 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 616 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
647 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 617 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
648 | 618 |
649 var localDestsSetEvent = | 619 var localDestsSetEvent = |
650 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 620 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
651 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 621 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
652 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 622 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
653 | 623 |
654 var capsSetEvent = | 624 var capsSetEvent = |
655 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 625 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
656 capsSetEvent.settingsInfo = { | 626 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
657 'printerId': 'FooDevice', | 627 capsSetEvent.settingsInfo.capabilities.printer.color = { |
658 'disableColorOption': true, | 628 "option": [ |
659 'setColorAsDefault': false, | 629 {"is_default": true, "type": "STANDARD_MONOCHROME"} |
660 'disableCopiesOption': false, | 630 ] |
661 'disableLandscapeOption': true, | |
662 'printerDefaultDuplexValue': 0 | |
663 }; | 631 }; |
664 this.nativeLayer_.dispatchEvent(capsSetEvent); | 632 this.nativeLayer_.dispatchEvent(capsSetEvent); |
665 | 633 |
666 checkSectionVisible($('color-settings'), false); | 634 checkSectionVisible($('color-settings'), false); |
667 | 635 |
668 var colorOption = $('color-settings').querySelector('.color-option'); | 636 var colorOption = $('color-settings').querySelector('.color-option'); |
669 var bwOption = $('color-settings').querySelector('.bw-option'); | 637 var bwOption = $('color-settings').querySelector('.bw-option'); |
670 expectFalse(colorOption.checked); | 638 expectFalse(colorOption.checked); |
671 expectTrue(bwOption.checked); | 639 expectTrue(bwOption.checked); |
672 }); | 640 }); |
(...skipping 10 matching lines...) Expand all Loading... |
683 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 651 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
684 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 652 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
685 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 653 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
686 | 654 |
687 var otherOptionsDiv = $('other-options-settings'); | 655 var otherOptionsDiv = $('other-options-settings'); |
688 var duplexDiv = otherOptionsDiv.querySelector('.duplex-container'); | 656 var duplexDiv = otherOptionsDiv.querySelector('.duplex-container'); |
689 var duplexCheckbox = otherOptionsDiv.querySelector('.duplex-checkbox'); | 657 var duplexCheckbox = otherOptionsDiv.querySelector('.duplex-checkbox'); |
690 | 658 |
691 var capsSetEvent = | 659 var capsSetEvent = |
692 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 660 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
693 capsSetEvent.settingsInfo = { | 661 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
694 'printerId': 'FooDevice', | |
695 'disableColorOption': false, | |
696 'setColorAsDefault': true, | |
697 'disableCopiesOption': false, | |
698 'disableLandscapeOption': true, | |
699 'printerDefaultDuplexValue': 0, | |
700 'setDuplexAsDefault': false | |
701 }; | |
702 this.nativeLayer_.dispatchEvent(capsSetEvent); | 662 this.nativeLayer_.dispatchEvent(capsSetEvent); |
703 | 663 |
704 checkSectionVisible(otherOptionsDiv, true); | 664 checkSectionVisible(otherOptionsDiv, true); |
705 expectFalse(duplexDiv.hidden); | 665 expectFalse(duplexDiv.hidden); |
706 expectFalse(duplexCheckbox.checked); | 666 expectFalse(duplexCheckbox.checked); |
707 }); | 667 }); |
708 | 668 |
709 //Test to verify that duplex settings are set according to the printer | 669 //Test to verify that duplex settings are set according to the printer |
710 //capabilities. | 670 //capabilities. |
711 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() { | 671 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() { |
712 var initialSettingsSetEvent = | 672 var initialSettingsSetEvent = |
713 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | 673 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); |
714 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 674 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
715 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 675 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
716 | 676 |
717 var localDestsSetEvent = | 677 var localDestsSetEvent = |
718 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 678 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
719 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 679 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
720 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 680 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
721 | 681 |
722 var otherOptionsDiv = $('other-options-settings'); | 682 var otherOptionsDiv = $('other-options-settings'); |
723 var duplexDiv = otherOptionsDiv.querySelector('.duplex-container'); | 683 var duplexDiv = otherOptionsDiv.querySelector('.duplex-container'); |
724 | 684 |
725 var capsSetEvent = | 685 var capsSetEvent = |
726 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 686 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
727 capsSetEvent.settingsInfo = { | 687 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
728 'printerId': 'FooDevice', | 688 delete capsSetEvent.settingsInfo.capabilities.printer.duplex; |
729 'disableColorOption': false, | |
730 'setColorAsDefault': true, | |
731 'disableCopiesOption': false, | |
732 'disableLandscapeOption': true, | |
733 'printerDefaultDuplexValue': -1, | |
734 'setDuplexAsDefault': false | |
735 }; | |
736 this.nativeLayer_.dispatchEvent(capsSetEvent); | 689 this.nativeLayer_.dispatchEvent(capsSetEvent); |
737 | 690 |
738 checkSectionVisible(otherOptionsDiv, true); | 691 checkSectionVisible(otherOptionsDiv, true); |
739 expectTrue(duplexDiv.hidden); | 692 expectTrue(duplexDiv.hidden); |
740 }); | 693 }); |
741 | 694 |
742 // Test that changing the selected printer updates the preview. | 695 // Test that changing the selected printer updates the preview. |
743 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { | 696 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { |
744 | 697 |
745 var initialSettingsSetEvent = | 698 var initialSettingsSetEvent = |
746 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | 699 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); |
747 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 700 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
748 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 701 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
749 | 702 |
750 var localDestsSetEvent = | 703 var localDestsSetEvent = |
751 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 704 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
752 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 705 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
753 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 706 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
754 | 707 |
755 var capsSetEvent = | 708 var capsSetEvent = |
756 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 709 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
757 capsSetEvent.settingsInfo = { | 710 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
758 'printerId': 'FooDevice', | |
759 'disableColorOption': false, | |
760 'setColorAsDefault': true, | |
761 'disableCopiesOption': true, | |
762 'disableLandscapeOption': true, | |
763 'printerDefaultDuplexValue': 0 | |
764 }; | |
765 this.nativeLayer_.dispatchEvent(capsSetEvent); | 711 this.nativeLayer_.dispatchEvent(capsSetEvent); |
766 | 712 |
767 var previewGenerator = mock(print_preview.PreviewGenerator); | 713 var previewGenerator = mock(print_preview.PreviewGenerator); |
768 printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy(); | 714 printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy(); |
769 previewGenerator.expects(exactly(6)).requestPreview(); | 715 previewGenerator.expects(exactly(6)).requestPreview(); |
770 | 716 |
771 var barDestination; | 717 var barDestination; |
772 var destinations = printPreview.destinationStore_.destinations(); | 718 var destinations = printPreview.destinationStore_.destinations(); |
773 for (var destination, i = 0; destination = destinations[i]; i++) { | 719 for (var destination, i = 0; destination = destinations[i]; i++) { |
774 if (destination.id == 'BarDevice') { | 720 if (destination.id == 'BarDevice') { |
775 barDestination = destination; | 721 barDestination = destination; |
776 break; | 722 break; |
777 } | 723 } |
778 } | 724 } |
779 | 725 |
780 printPreview.destinationStore_.selectDestination(barDestination); | 726 printPreview.destinationStore_.selectDestination(barDestination); |
781 | 727 |
782 var capsSetEvent = | 728 var capsSetEvent = |
783 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 729 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
784 capsSetEvent.settingsInfo = { | 730 capsSetEvent.settingsInfo = getCddTemplate("BarDevice"); |
785 'printerId': 'BarDevice', | 731 capsSetEvent.settingsInfo.capabilities.printer.color = { |
786 'disableColorOption': true, | 732 "option": [ |
787 'setColorAsDefault': false, | 733 {"is_default": true, "type": "STANDARD_MONOCHROME"} |
788 'disableCopiesOption': true, | 734 ] |
789 'disableLandscapeOption': true, | |
790 'printerDefaultDuplexValue': 0 | |
791 }; | 735 }; |
792 this.nativeLayer_.dispatchEvent(capsSetEvent); | 736 this.nativeLayer_.dispatchEvent(capsSetEvent); |
793 }); | 737 }); |
794 | 738 |
795 // Test that error message is displayed when plugin doesn't exist. | 739 // Test that error message is displayed when plugin doesn't exist. |
796 TEST_F('PrintPreviewWebUITest', 'TestNoPDFPluginErrorMessage', function() { | 740 TEST_F('PrintPreviewWebUITest', 'TestNoPDFPluginErrorMessage', function() { |
797 var previewAreaEl = $('preview-area'); | 741 var previewAreaEl = $('preview-area'); |
798 | 742 |
799 var loadingMessageEl = | 743 var loadingMessageEl = |
800 previewAreaEl.getElementsByClassName('preview-area-loading-message')[0]; | 744 previewAreaEl.getElementsByClassName('preview-area-loading-message')[0]; |
801 expectEquals(true, loadingMessageEl.hidden); | 745 expectEquals(true, loadingMessageEl.hidden); |
802 | 746 |
803 var previewFailedMessageEl = previewAreaEl.getElementsByClassName( | 747 var previewFailedMessageEl = previewAreaEl.getElementsByClassName( |
804 'preview-area-preview-failed-message')[0]; | 748 'preview-area-preview-failed-message')[0]; |
805 expectEquals(true, previewFailedMessageEl.hidden); | 749 expectEquals(true, previewFailedMessageEl.hidden); |
806 | 750 |
807 var printFailedMessageEl = | 751 var printFailedMessageEl = |
808 previewAreaEl.getElementsByClassName('preview-area-print-failed')[0]; | 752 previewAreaEl.getElementsByClassName('preview-area-print-failed')[0]; |
809 expectEquals(true, printFailedMessageEl.hidden); | 753 expectEquals(true, printFailedMessageEl.hidden); |
810 | 754 |
811 var customMessageEl = | 755 var customMessageEl = |
812 previewAreaEl.getElementsByClassName('preview-area-custom-message')[0]; | 756 previewAreaEl.getElementsByClassName('preview-area-custom-message')[0]; |
813 expectEquals(false, customMessageEl.hidden); | 757 expectEquals(false, customMessageEl.hidden); |
814 }); | 758 }); |
OLD | NEW |