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

Fix assertion errors in tutorial_test.js.

Fix two assertion errors:
1. The first error was firing because we were asserting things in the
wrong order; to fix it, we just needed to move the assertion after
the speech expectation.
2. The second error was firing because we were asserting the current
range before it changed. To fix this, we add an extra speech
expectation, which is spoken after the range has changed.

Bug: N/A
Change-Id: I06f9ead1815ce2e2e2c0ce77a6459d8cf3dc8f12
AX-Relnotes: N/A
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2461587Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Akihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817291}
parent a3641f74
......@@ -363,8 +363,8 @@ TEST_F('ChromeVoxTutorialTest', 'AllLessonsButton', function() {
.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(this.assertActiveScreen.bind(this, 'lesson'))
.call(doCmd('nextButton'))
.expectSpeech('Next lesson')
.call(doCmd('nextButton'))
......@@ -496,9 +496,10 @@ TEST_F('ChromeVoxTutorialTest', 'QuickOrientationLessonTest', function() {
// Helper functions. For this test, activate commands by hooking into the
// BackgroundKeyboardHandler. This is necessary because UserActionMonitor
// intercepts key sequences before they are routed to CommandHandler.
const getRangeStart = () => {
const getRangeStartNode = () => {
return ChromeVoxState.instance.getCurrentRange().start.node;
};
const simulateKeyPress = (keyCode, opt_modifiers) => {
const keyEvent = TestUtils.createMockKeyEvent(keyCode, opt_modifiers);
keyboardHandler.onKeyDown(keyEvent);
......@@ -517,25 +518,26 @@ TEST_F('ChromeVoxTutorialTest', 'QuickOrientationLessonTest', function() {
.expectSpeech(/Welcome to the ChromeVox tutorial./)
.call(() => {
assertEquals(0, tutorial.activeLessonNum);
firstLessonNode = getRangeStart();
firstLessonNode = getRangeStartNode();
})
.call(simulateKeyPress.bind(this, KeyCode.RIGHT, {searchKeyHeld: true}))
.call(() => {
assertEquals(firstLessonNode, getRangeStart());
assertEquals(firstLessonNode, getRangeStartNode());
assertEquals(0, tutorial.activeLessonNum);
})
.call(simulateKeyPress.bind(this, KeyCode.LEFT, {searchKeyHeld: true}))
.call(() => {
assertEquals(firstLessonNode, getRangeStart());
assertEquals(firstLessonNode, getRangeStartNode());
assertEquals(0, tutorial.activeLessonNum);
})
// Pressing space, which is the desired key sequence, should move us to
// the next lesson.
.call(simulateKeyPress.bind(this, KeyCode.SPACE, {}))
.expectSpeech('Essential Keys: Control')
.expectSpeech(/Let's start with a few keys you'll use regularly:/)
.call(() => {
assertNotEquals(firstLessonNode, getRangeStart());
assertEquals(1, tutorial.activeLessonNum);
assertNotEquals(firstLessonNode, getRangeStartNode());
})
// Pressing control, which is the desired key sequence, should move us
// to the next lesson.
......
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