Commit af9bb675 authored by Akihiro Ota's avatar Akihiro Ota Committed by Chromium LUCI CQ

ChromeVox tutorial: Test interactive mode is properly set.

This change adds a test that verifies interactive mode and
UserActionMonitor are properly set when moving throughout the tutorial.

Fixed: 1130681
AX-Relnotes: N/A
Change-Id: I3c3f6ff08fb0144a9b04db071b1c1f24e1341475
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2584683
Commit-Queue: Akihiro Ota <akihiroota@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835898}
parent 583f52a3
......@@ -620,4 +620,56 @@ TEST_F('ChromeVoxTutorialTest', 'OnlyLessonTest', function() {
.expectSpeech('Exit tutorial')
.replay();
});
});
\ No newline at end of file
});
// Tests that interactive mode and UserActionMonitor are properly set when
// showing different screens in the tutorial.
TEST_F('ChromeVoxTutorialTest', 'StartStopInteractiveMode', function() {
this.runWithLoadedTree(this.simpleDoc, async function(root) {
await this.launchAndWaitForTutorial();
const tutorial = this.getPanel().iTutorial;
let userActionMonitorCreatedCount = 0;
let userActionMonitorDestroyedCount = 0;
let isUserActionMonitorActive = false;
// Swap in functions below so we can track the number of times
// UserActionMonitor is created and destroyed.
ChromeVoxState.instance.createUserActionMonitor = (actions, callback) => {
userActionMonitorCreatedCount += 1;
isUserActionMonitorActive = true;
};
ChromeVoxState.instance.destroyUserActionMonitor = () => {
userActionMonitorDestroyedCount += 1;
isUserActionMonitorActive = false;
};
// A helper to make assertions on four variables of interest.
const makeAssertions = (expectedVars) => {
assertEquals(expectedVars.createdCount, userActionMonitorCreatedCount);
assertEquals(
expectedVars.destroyedCount, userActionMonitorDestroyedCount);
assertEquals(expectedVars.interactiveMode, tutorial.interactiveMode);
// Note: Interactive mode and UserActionMonitor should always be in
// sync in the context of the tutorial.
assertEquals(expectedVars.interactiveMode, isUserActionMonitorActive);
};
makeAssertions(
{createdCount: 0, destroyedCount: 0, interactiveMode: false});
// Show the first lesson of the quick orientation, which is interactive.
tutorial.curriculum = 'quick_orientation';
tutorial.showLesson(0);
makeAssertions({createdCount: 1, destroyedCount: 0, interactiveMode: true});
// Move to the next lesson in the quick orientation. This lesson is also
// interactive, so UserActionMonitor should be destroyed and re-created.
tutorial.showNextLesson();
makeAssertions({createdCount: 2, destroyedCount: 1, interactiveMode: true});
// Leave the quick orientation by navigating to the lesson menu. This should
// stop interactive mode and destroy UserActionMonitor.
tutorial.showLessonMenu();
makeAssertions(
{createdCount: 2, destroyedCount: 2, interactiveMode: false});
});
});
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