@@ -13,6 +13,7 @@ cr.define('pages_settings_test', function() {
13
13
ClickingCustomFocusesInput : 'clicking custom focuses input' ,
14
14
InputNotDisabledOnValidityChange : 'input not disabled on validity change' ,
15
15
IgnoreInputKeyEvents : 'ignore input key events' ,
16
+ EnterOnInputTriggersPrint : 'enter on input triggers print' ,
16
17
} ;
17
18
18
19
const suiteName = 'PagesSettingsTest' ;
@@ -501,6 +502,49 @@ cr.define('pages_settings_test', function() {
501
502
} ) ;
502
503
503
504
} ) ;
505
+
506
+ // Verifies that the enter key event is bubbled to the pages settings
507
+ // element, so that it will be bubbled to the print preview app to trigger a
508
+ // print.
509
+ test ( assert ( TestNames . EnterOnInputTriggersPrint ) , function ( ) {
510
+ const input = pagesSection . $ . pageSettingsCustomInput . inputElement ;
511
+ const radioGroup = pagesSection . $$ ( 'paper-radio-group' ) ;
512
+ const whenPrintReceived =
513
+ test_util . eventToPromise ( 'keydown' , pagesSection ) ;
514
+
515
+ // Setup an empty input by clicking on the custom radio button.
516
+ const inputFocused = test_util . eventToPromise ( 'focus' , input ) ;
517
+ pagesSection . $ . customRadioButton . click ( ) ;
518
+ return inputFocused
519
+ . then ( function ( ) {
520
+ assertEquals (
521
+ pagesSection . pagesValueEnum_ . CUSTOM , radioGroup . selected ) ;
522
+ MockInteractions . keyEventOn ( input , 'keydown' , 13 , [ ] , 'Enter' ) ;
523
+ return whenPrintReceived ;
524
+ } )
525
+ // All gets automatically selected
526
+ . then ( function ( ) {
527
+ assertEquals ( pagesSection . pagesValueEnum_ . ALL , radioGroup . selected ) ;
528
+ // Refocus the radio group to reset the focused button to "all".
529
+ // Normally, enter results in print, so this does not need to
530
+ // happen.
531
+ radioGroup . focus ( ) ;
532
+ return setupInput ( '1' , 3 ) ;
533
+ } )
534
+ // Re-select custom and print again.
535
+ . then ( function ( ) {
536
+ assertEquals (
537
+ pagesSection . pagesValueEnum_ . CUSTOM , radioGroup . selected ) ;
538
+ const whenPrintReceived =
539
+ test_util . eventToPromise ( 'keydown' , pagesSection ) ;
540
+ MockInteractions . keyEventOn ( input , 'keydown' , 13 , [ ] , 'Enter' ) ;
541
+ return whenPrintReceived ;
542
+ } )
543
+ . then ( function ( ) {
544
+ assertEquals (
545
+ pagesSection . pagesValueEnum_ . CUSTOM , radioGroup . selected ) ;
546
+ } ) ;
547
+ } ) ;
504
548
} ) ;
505
549
506
550
return {
0 commit comments