Commit c8e360cd authored by Akihiro Ota's avatar Akihiro Ota Committed by Commit Bot

ChromeVox Tutorial: Add tests for navigation buttons.

This change adds tests for:
1. The 'Main menu' button; ensure that clicking this button takes the user
to the main menu.
2. The 'All lessons' button; ensure that clicking this button takes the
user to a screen displaying all lessons for the chosen curriculum.
3. The 'Next lesson' and 'Previous lesson' buttons; ensure that
clicking these buttons moves the user between lessons.

Fixed: 1127049
AX-Relnotes: N/A
Change-Id: I0223769bf3ac79071918bcd764b0d2069556f446
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2439480Reviewed-by: default avatarAnastasia Helfinstein <anastasi@google.com>
Commit-Queue: Akihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812331}
parent 37c88eb9
...@@ -33,6 +33,14 @@ ChromeVoxTutorialTest = class extends ChromeVoxNextE2ETest { ...@@ -33,6 +33,14 @@ ChromeVoxTutorialTest = class extends ChromeVoxNextE2ETest {
window.doCmd = this.doCmd; window.doCmd = this.doCmd;
} }
assertActiveLessonIndex(expectedIndex) {
assertEquals(expectedIndex, this.getPanel().iTutorial.activeLessonIndex);
}
assertActiveScreen(expectedScreen) {
assertEquals(expectedScreen, this.getPanel().iTutorial.activeScreen);
}
getPanelWindow() { getPanelWindow() {
let panelWindow = null; let panelWindow = null;
while (!panelWindow) { while (!panelWindow) {
...@@ -271,10 +279,8 @@ TEST_F('ChromeVoxTutorialTest', 'PracticeAreaNudgesTest', function() { ...@@ -271,10 +279,8 @@ TEST_F('ChromeVoxTutorialTest', 'PracticeAreaNudgesTest', function() {
TEST_F('ChromeVoxTutorialTest', 'ExitButtonTest', function() { TEST_F('ChromeVoxTutorialTest', 'ExitButtonTest', function() {
const mockFeedback = this.createMockFeedback(); const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(this.simpleDoc, async function(root) { this.runWithLoadedTree(this.simpleDoc, async function(root) {
const Panel = this.getPanel(); await this.launchAndWaitForTutorial();
assertTrue(Panel.iTutorialEnabled_); const tutorial = this.getPanel().iTutorial;
new PanelCommand(PanelCommandType.TUTORIAL).send();
await this.waitForTutorial();
mockFeedback.expectSpeech('Choose your tutorial experience') mockFeedback.expectSpeech('Choose your tutorial experience')
.call(doCmd('previousButton')) .call(doCmd('previousButton'))
.expectSpeech('Exit tutorial') .expectSpeech('Exit tutorial')
...@@ -288,11 +294,8 @@ TEST_F('ChromeVoxTutorialTest', 'ExitButtonTest', function() { ...@@ -288,11 +294,8 @@ TEST_F('ChromeVoxTutorialTest', 'ExitButtonTest', function() {
TEST_F('ChromeVoxTutorialTest', 'EscapeTest', function() { TEST_F('ChromeVoxTutorialTest', 'EscapeTest', function() {
const mockFeedback = this.createMockFeedback(); const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(this.simpleDoc, async function(root) { this.runWithLoadedTree(this.simpleDoc, async function(root) {
const Panel = this.getPanel(); await this.launchAndWaitForTutorial();
assertTrue(Panel.iTutorialEnabled_); const tutorial = this.getPanel().iTutorial;
new PanelCommand(PanelCommandType.TUTORIAL).send();
await this.waitForTutorial();
const tutorial = Panel.iTutorial;
mockFeedback.expectSpeech('Choose your tutorial experience') mockFeedback.expectSpeech('Choose your tutorial experience')
.call(() => { .call(() => {
// Press Escape. // Press Escape.
...@@ -306,3 +309,89 @@ TEST_F('ChromeVoxTutorialTest', 'EscapeTest', function() { ...@@ -306,3 +309,89 @@ TEST_F('ChromeVoxTutorialTest', 'EscapeTest', function() {
.replay(); .replay();
}); });
}); });
// Tests that the main menu button navigates the user to the main menu screen.
TEST_F('ChromeVoxTutorialTest', 'MainMenuButton', function() {
const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(this.simpleDoc, async function(root) {
await this.launchAndWaitForTutorial();
const tutorial = this.getPanel().iTutorial;
mockFeedback.expectSpeech('Choose your tutorial experience')
.call(this.assertActiveScreen.bind(this, 'main_menu'))
.call(doCmd('nextObject'))
.expectSpeech('Quick orientation')
.call(doCmd('nextObject'))
.expectSpeech('Essential keys')
.call(doCmd('forceClickOnCurrentItem'))
.expectSpeech(/Essential Keys Tutorial, [0-9]+ Lessons/)
.call(this.assertActiveScreen.bind(this, 'lesson_menu'))
.call(doCmd('previousButton'))
.expectSpeech('Exit tutorial')
.call(doCmd('previousButton'))
.expectSpeech('Main menu')
.call(doCmd('forceClickOnCurrentItem'))
.expectSpeech('Choose your tutorial experience')
.call(this.assertActiveScreen.bind(this, 'main_menu'))
.replay();
});
});
// Tests that the all lessons button navigates the user to the lesson menu
// screen.
TEST_F('ChromeVoxTutorialTest', 'AllLessonsButton', function() {
const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(this.simpleDoc, async function(root) {
await this.launchAndWaitForTutorial();
const tutorial = this.getPanel().iTutorial;
mockFeedback.expectSpeech('Choose your tutorial experience')
.call(this.assertActiveScreen.bind(this, 'main_menu'))
.call(doCmd('nextObject'))
.expectSpeech('Quick orientation')
.call(doCmd('nextObject'))
.expectSpeech('Essential keys')
.call(doCmd('forceClickOnCurrentItem'))
.expectSpeech(/Essential Keys Tutorial, [0-9]+ Lessons/)
.call(this.assertActiveScreen.bind(this, 'lesson_menu'))
.call(doCmd('nextObject'))
.expectSpeech('On, Off, and Stop', 'Button')
.call(doCmd('forceClickOnCurrentItem'))
.call(this.assertActiveScreen.bind(this, 'lesson'))
.expectSpeech('On, Off, and Stop', 'Heading 1')
.call(doCmd('nextButton'))
.expectSpeech('Next lesson')
.call(doCmd('nextButton'))
.expectSpeech('All lessons')
.call(doCmd('forceClickOnCurrentItem'))
.expectSpeech(/Essential Keys Tutorial, [0-9]+ Lessons/)
.call(this.assertActiveScreen.bind(this, 'lesson_menu'))
.replay();
});
});
// Tests that the next and previous lesson buttons navigate properly.
TEST_F('ChromeVoxTutorialTest', 'NextPreviousButtons', function() {
const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(this.simpleDoc, async function(root) {
await this.launchAndWaitForTutorial();
const tutorial = this.getPanel().iTutorial;
mockFeedback.expectSpeech('Choose your tutorial experience')
.call(() => {
tutorial.curriculum = 'essential_keys';
tutorial.showLesson(0);
this.assertActiveLessonIndex(0);
this.assertActiveScreen('lesson');
})
.expectSpeech('On, Off, and Stop', 'Heading 1')
.call(doCmd('nextButton'))
.expectSpeech('Next lesson')
.call(doCmd('forceClickOnCurrentItem'))
.expectSpeech('The ChromeVox Modifier Key', 'Heading 1')
.call(this.assertActiveLessonIndex.bind(this, 1))
.call(doCmd('nextButton'))
.expectSpeech('Previous lesson')
.call(doCmd('forceClickOnCurrentItem'))
.expectSpeech('On, Off, and Stop', 'Heading 1')
.call(this.assertActiveLessonIndex.bind(this, 0))
.replay();
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment