OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Include test fixture. | 5 // Include test fixture. |
6 GEN_INCLUDE(['../../testing/chromevox_unittest_base.js']); | 6 GEN_INCLUDE(['../../testing/chromevox_unittest_base.js']); |
7 | 7 |
8 /** | 8 /** |
9 * Test fixture. | 9 * Test fixture. |
10 * @constructor | 10 * @constructor |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 * Test that key down events don't cause excessive value and state announcements | 522 * Test that key down events don't cause excessive value and state announcements |
523 * when arrowing around radiobuttons. | 523 * when arrowing around radiobuttons. |
524 */ | 524 */ |
525 TEST_F('CvoxEventWatcherUnitTest', | 525 TEST_F('CvoxEventWatcherUnitTest', |
526 'DISABLED_RadioButtonAnnouncements', | 526 'DISABLED_RadioButtonAnnouncements', |
527 function() { | 527 function() { |
528 this.loadHtml( | 528 this.loadHtml( |
529 '<input id="radio1" type="radio" aria-label="green" tabindex=0>' + | 529 '<input id="radio1" type="radio" aria-label="green" tabindex=0>' + |
530 '<input id="radio2" type="radio" aria-label="blue" tabindex=0>'); | 530 '<input id="radio2" type="radio" aria-label="blue" tabindex=0>'); |
531 function performKeyDown(dir) { | 531 function performKeyDown(dir) { |
532 var evt = document.createEvent('KeyboardEvent'); | 532 var evt = new KeyboardEvent("keydown", {key: dir}); |
533 evt.initKeyboardEvent( | |
534 'keydown', true, true, window, dir, 0, false, false, false, false); | |
535 | |
536 document.activeElement.dispatchEvent(evt); | 533 document.activeElement.dispatchEvent(evt); |
537 }; | 534 }; |
538 | 535 |
539 var radio1 = $('radio1'); | 536 var radio1 = $('radio1'); |
540 radio1.focus(); | 537 radio1.focus(); |
541 | 538 |
542 // TODO(dtseng): Repeated actual spoken text here; this is most certainly a | 539 // TODO(dtseng): Repeated actual spoken text here; this is most certainly a |
543 // test framework bug. | 540 // test framework bug. |
544 this.waitForCalm(this.assertSpoken, 'green Radio button unselected') | 541 this.waitForCalm(this.assertSpoken, 'green Radio button unselected') |
545 .waitForCalm(performKeyDown, 'Right') // right arrow | 542 .waitForCalm(performKeyDown, 'ArrowRight') // right arrow |
546 // Moves to next radiobutton. | 543 // Moves to next radiobutton. |
547 .waitForCalm(this.assertSpoken, | 544 .waitForCalm(this.assertSpoken, |
548 'blue Radio button selected blue Radio button selected') | 545 'blue Radio button selected blue Radio button selected') |
549 .waitForCalm(performKeyDown, 'Right') // right arrow | 546 .waitForCalm(performKeyDown, 'ArrowRight') // right arrow |
550 // Arrowed beyond end. Should be quiet. | 547 // Arrowed beyond end. Should be quiet. |
551 .waitForCalm(this.assertSpoken, ''); | 548 .waitForCalm(this.assertSpoken, ''); |
552 | 549 |
553 this.waitForCalm(performKeyDown, 'Left') // left arrow | 550 this.waitForCalm(performKeyDown, 'ArrowLeft') // left arrow |
554 // Moves back to first radio. | 551 // Moves back to first radio. |
555 .waitForCalm(this.assertSpoken, | 552 .waitForCalm(this.assertSpoken, |
556 'green Radio button selected green Radio button selected') | 553 'green Radio button selected green Radio button selected') |
557 .waitForCalm(performKeyDown, 'Left') // left arrow | 554 .waitForCalm(performKeyDown, 'ArrowLeft') // left arrow |
558 // Arrowed beyond beginning. Should be quiet. | 555 // Arrowed beyond beginning. Should be quiet. |
559 .waitForCalm(this.assertSpoken, ''); | 556 .waitForCalm(this.assertSpoken, ''); |
560 }); | 557 }); |
561 | 558 |
562 /** | 559 /** |
563 * Test time widget. | 560 * Test time widget. |
564 */ | 561 */ |
565 TEST_F('CvoxEventWatcherUnitTest', 'TimeWidget', function() { | 562 TEST_F('CvoxEventWatcherUnitTest', 'TimeWidget', function() { |
566 this.loadHtml( | 563 this.loadHtml( |
567 '<label for="timewidget">Set alarm for:</label>' + | 564 '<label for="timewidget">Set alarm for:</label>' + |
568 '<input id="timewidget" type="time" value="12:00">'); | 565 '<input id="timewidget" type="time" value="12:00">'); |
569 var performKeyDown = function(dir) { | 566 var performKeyDown = function(dir) { |
570 var evt = document.createEvent('KeyboardEvent'); | 567 var evt = new KeyboardEvent("keydown", {key: dir}); |
571 evt.initKeyboardEvent( | |
572 'keydown', true, true, window, dir, 0, false, false, false, false); | |
573 | |
574 document.activeElement.dispatchEvent(evt); | 568 document.activeElement.dispatchEvent(evt); |
575 }; | 569 }; |
576 var performKeyUp = function(dir) { | 570 var performKeyUp = function(dir) { |
577 var evt = document.createEvent('KeyboardEvent'); | 571 var evt = new KeyboardEvent("keyup", {key: dir}); |
578 evt.initKeyboardEvent( | |
579 'keyup', true, true, window, dir, 0, false, false, false, false); | |
580 | |
581 document.activeElement.dispatchEvent(evt); | 572 document.activeElement.dispatchEvent(evt); |
582 }; | 573 }; |
583 | 574 |
584 var timewidget = $('timewidget'); | 575 var timewidget = $('timewidget'); |
585 timewidget.focus(); | 576 timewidget.focus(); |
586 | 577 |
587 this.waitForCalm(this.assertSpoken, | 578 this.waitForCalm(this.assertSpoken, |
588 'Set alarm for: 12:00 Set alarm for: 12 hours 00 minutes PM'); | 579 'Set alarm for: 12:00 Set alarm for: 12 hours 00 minutes PM'); |
589 | 580 |
590 this.waitForCalm(performKeyDown, 'Down') // down arrow | 581 this.waitForCalm(performKeyDown, 'ArrowDown') // down arrow |
591 .waitForCalm(performKeyUp, 'Down') // down arrow | 582 .waitForCalm(performKeyUp, 'ArrowDown') // down arrow |
592 .waitForCalm(this.assertSpoken, | 583 .waitForCalm(this.assertSpoken, |
593 '11 hours'); | 584 '11 hours'); |
594 | 585 |
595 this.waitForCalm(performKeyDown, 'Down') // down arrow | 586 this.waitForCalm(performKeyDown, 'ArrowDown') // down arrow |
596 .waitForCalm(performKeyUp, 'Down') // down arrow | 587 .waitForCalm(performKeyUp, 'ArrowDown') // down arrow |
597 .waitForCalm(this.assertSpoken, | 588 .waitForCalm(this.assertSpoken, |
598 '10 hours'); | 589 '10 hours'); |
599 | 590 |
600 this.waitForCalm(performKeyDown, 'Right') // right arrow | 591 this.waitForCalm(performKeyDown, 'ArrowRight') // right arrow |
601 .waitForCalm(performKeyUp, 'Right') // right arrow | 592 .waitForCalm(performKeyUp, 'ArrowRight') // right arrow |
602 .waitForCalm(performKeyDown, 'Up') // right arrow | 593 .waitForCalm(performKeyDown, 'ArrowUp') // right arrow |
603 .waitForCalm(performKeyUp, 'Up') // right arrow | 594 .waitForCalm(performKeyUp, 'ArrowUp') // right arrow |
604 .waitForCalm(this.assertSpoken, | 595 .waitForCalm(this.assertSpoken, |
605 '01 minutes'); | 596 '01 minutes'); |
606 | 597 |
607 this.waitForCalm(performKeyDown, 'Down') // down arrow | 598 this.waitForCalm(performKeyDown, 'ArrowDown') // down arrow |
608 .waitForCalm(performKeyUp, 'Down') // down arrow | 599 .waitForCalm(performKeyUp, 'ArrowDown') // down arrow |
609 .waitForCalm(this.assertSpoken, | 600 .waitForCalm(this.assertSpoken, |
610 '00 minutes'); | 601 '00 minutes'); |
611 | 602 |
612 this.waitForCalm(performKeyDown, 'Right') // right arrow | 603 this.waitForCalm(performKeyDown, 'ArrowRight') // right arrow |
613 .waitForCalm(performKeyUp, 'Right') // right arrow | 604 .waitForCalm(performKeyUp, 'ArrowRight') // right arrow |
614 .waitForCalm(performKeyDown, 'Up') // right arrow | 605 .waitForCalm(performKeyDown, 'ArrowUp') // right arrow |
615 .waitForCalm(performKeyUp, 'Up') // right arrow | 606 .waitForCalm(performKeyUp, 'ArrowUp') // right arrow |
616 .waitForCalm(this.assertSpoken, | 607 .waitForCalm(this.assertSpoken, |
617 'AM'); | 608 'AM'); |
618 | 609 |
619 this.waitForCalm(performKeyDown, 'Down') // down arrow | 610 this.waitForCalm(performKeyDown, 'ArrowDown') // down arrow |
620 .waitForCalm(performKeyUp, 'Down') // down arrow | 611 .waitForCalm(performKeyUp, 'ArrowDown') // down arrow |
621 .waitForCalm(this.assertSpoken, | 612 .waitForCalm(this.assertSpoken, |
622 'PM'); | 613 'PM'); |
623 }); | 614 }); |
624 | 615 |
625 /** | 616 /** |
626 * Test date widget. | 617 * Test date widget. |
627 */ | 618 */ |
628 TEST_F('CvoxEventWatcherUnitTest', 'DateWidget', function() { | 619 TEST_F('CvoxEventWatcherUnitTest', 'DateWidget', function() { |
629 this.loadHtml( | 620 this.loadHtml( |
630 '<label for="datewidget">Set birthdate:</label>' + | 621 '<label for="datewidget">Set birthdate:</label>' + |
631 '<input id="datewidget" type="date" value="1998-09-04"/>'); | 622 '<input id="datewidget" type="date" value="1998-09-04"/>'); |
632 var performKeyDown = function(dir) { | 623 var performKeyDown = function(dir) { |
633 var evt = document.createEvent('KeyboardEvent'); | 624 var evt = new KeyboardEvent("keydown", {key: dir}); |
634 evt.initKeyboardEvent( | |
635 'keydown', true, true, window, dir, 0, false, false, false, false); | |
636 | |
637 document.activeElement.dispatchEvent(evt); | 625 document.activeElement.dispatchEvent(evt); |
638 }; | 626 }; |
639 var performKeyUp = function(dir) { | 627 var performKeyUp = function(dir) { |
640 var evt = document.createEvent('KeyboardEvent'); | 628 var evt = new KeyboardEvent("keyup", {key: dir}); |
641 evt.initKeyboardEvent( | |
642 'keyup', true, true, window, dir, 0, false, false, false, false); | |
643 | |
644 document.activeElement.dispatchEvent(evt); | 629 document.activeElement.dispatchEvent(evt); |
645 }; | 630 }; |
646 | 631 |
647 var datewidget = $('datewidget'); | 632 var datewidget = $('datewidget'); |
648 datewidget.focus(); | 633 datewidget.focus(); |
649 | 634 |
650 this.waitForCalm(this.assertSpoken, | 635 this.waitForCalm(this.assertSpoken, |
651 'Set birthdate: 1998-09-04 Date control Set birthdate: September 4 1998') | 636 'Set birthdate: 1998-09-04 Date control Set birthdate: September 4 1998') |
652 | 637 |
653 .waitForCalm(performKeyDown, 'Down') // down arrow | 638 .waitForCalm(performKeyDown, 'ArrowDown') // down arrow |
654 .waitForCalm(performKeyUp, 'Down') // down arrow | 639 .waitForCalm(performKeyUp, 'ArrowDown') // down arrow |
655 .waitForCalm(this.assertSpoken, | 640 .waitForCalm(this.assertSpoken, |
656 'August') | 641 'August') |
657 | 642 |
658 .waitForCalm(performKeyDown, 'Down') // down arrow | 643 .waitForCalm(performKeyDown, 'ArrowDown') // down arrow |
659 .waitForCalm(performKeyUp, 'Down') // down arrow | 644 .waitForCalm(performKeyUp, 'ArrowDown') // down arrow |
660 .waitForCalm(this.assertSpoken, 'July') | 645 .waitForCalm(this.assertSpoken, 'July') |
661 | 646 |
662 .waitForCalm(performKeyDown, 'Right') // right arrow | 647 .waitForCalm(performKeyDown, 'ArrowRight') // right arrow |
663 .waitForCalm(performKeyUp, 'Right') // right arrow | 648 .waitForCalm(performKeyUp, 'ArrowRight') // right arrow |
664 .waitForCalm(performKeyDown, 'Up') // right arrow | 649 .waitForCalm(performKeyDown, 'ArrowUp') // right arrow |
665 .waitForCalm(performKeyUp, 'Up') // right arrow | 650 .waitForCalm(performKeyUp, 'ArrowUp') // right arrow |
666 .waitForCalm(this.assertSpoken, '5') | 651 .waitForCalm(this.assertSpoken, '5') |
667 | 652 |
668 .waitForCalm(performKeyDown, 'Down') // down arrow | 653 .waitForCalm(performKeyDown, 'ArrowDown') // down arrow |
669 .waitForCalm(performKeyUp, 'Down') // down arrow | 654 .waitForCalm(performKeyUp, 'ArrowDown') // down arrow |
670 .waitForCalm(this.assertSpoken, '4') | 655 .waitForCalm(this.assertSpoken, '4') |
671 | 656 |
672 .waitForCalm(performKeyDown, 'Right') // right arrow | 657 .waitForCalm(performKeyDown, 'ArrowRight') // right arrow |
673 .waitForCalm(performKeyUp, 'Right') // right arrow | 658 .waitForCalm(performKeyUp, 'ArrowRight') // right arrow |
674 .waitForCalm(performKeyDown, 'Up') // right arrow | 659 .waitForCalm(performKeyDown, 'ArrowUp') // right arrow |
675 .waitForCalm(performKeyUp, 'Up') // right arrow | 660 .waitForCalm(performKeyUp, 'ArrowUp') // right arrow |
676 .waitForCalm(this.assertSpoken, | 661 .waitForCalm(this.assertSpoken, |
677 '1999') | 662 '1999') |
678 | 663 |
679 .waitForCalm(performKeyDown, 'Down') // down arrow | 664 .waitForCalm(performKeyDown, 'ArrowDown') // down arrow |
680 .waitForCalm(performKeyUp, 'Down') // down arrow | 665 .waitForCalm(performKeyUp, 'ArrowDown') // down arrow |
681 .waitForCalm(this.assertSpoken, | 666 .waitForCalm(this.assertSpoken, |
682 '1998'); | 667 '1998'); |
683 }); | 668 }); |
684 | 669 |
685 /** | 670 /** |
686 * Test that ChromeVox speaks the correct state when a focused control | 671 * Test that ChromeVox speaks the correct state when a focused control |
687 * changes as the result of a key up, not just key down. | 672 * changes as the result of a key up, not just key down. |
688 */ | 673 */ |
689 TEST_F('CvoxEventWatcherUnitTest', 'ToggleOnKeyUp', function() { | 674 TEST_F('CvoxEventWatcherUnitTest', 'ToggleOnKeyUp', function() { |
690 this.loadHtml('<div>' + | 675 this.loadHtml('<div>' + |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 this.setFocus('final'); | 730 this.setFocus('final'); |
746 }) | 731 }) |
747 .waitForCalm(function() { | 732 .waitForCalm(function() { |
748 var ulist = cvox.ChromeVoxTester.testTts().getSpeechQueueOutput(); | 733 var ulist = cvox.ChromeVoxTester.testTts().getSpeechQueueOutput(); |
749 assertEquals('Live region changed', ulist[0]); | 734 assertEquals('Live region changed', ulist[0]); |
750 assertEquals('Exited dialog.', ulist[1]); | 735 assertEquals('Exited dialog.', ulist[1]); |
751 assertEquals('Final focus', ulist[2]); | 736 assertEquals('Final focus', ulist[2]); |
752 assertEquals('Button', ulist[3]); | 737 assertEquals('Button', ulist[3]); |
753 }); | 738 }); |
754 }); | 739 }); |
OLD | NEW |