Commit 18c3d3d9 authored by Akihiro Ota's avatar Akihiro Ota Committed by Commit Bot

ChromeVox Tutorial: Write lessons test.

This test ensures that the lessons shown depends on the category the
user chooses. For example, the lessons shown for 'New User' and
'Experienced User' are different.

It also adds logic to compute the header for the lesson screen, which
will be localized in a follow-up (see TODO).

Bug: 1127034
Change-Id: Ib523205368593c7b782a9491c17f3f6608c7f491
AX-Relnotes: N/A
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2404150Reviewed-by: default avatarAnastasia Helfinstein <anastasi@google.com>
Commit-Queue: Akihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807659}
parent 967b8020
......@@ -107,7 +107,7 @@ h1 {
<div id="lessonMenu"
hidden$="[[ shouldHideLessonMenu(activeScreen) ]]">
<h1 id="lessonMenuHeader"
tabindex="-1">[[ computeLessonMenuHeader(curriculum, medium) ]]</h1>
tabindex="-1">[[ computeLessonMenuHeader(curriculum) ]]</h1>
<div id="lessonShortcuts"></div>
</div>
......
......@@ -9,6 +9,7 @@ import {TutorialLesson} from './tutorial_lesson.js';
/** @enum {string} */
const Curriculum = {
NONE: 'none',
OOBE: 'oobe',
NEW_USER: 'new_user',
EXPERIENCED_USER: 'experienced_user',
......@@ -57,7 +58,11 @@ Polymer({
_template: html`{__html_template__}`,
properties: {
curriculum: {type: String, observer: 'updateIncludedLessons'},
curriculum: {
type: String,
value: Curriculum.NONE,
observer: 'updateIncludedLessons'
},
medium: {
type: String,
......@@ -648,6 +653,8 @@ Polymer({
*/
shouldHideLessonMenuButton(activeScreen) {
return !this.curriculum || this.curriculum === Curriculum.OOBE ||
this.curriculum === Curriculum.NONE ||
activeScreen === Screen.MAIN_MENU ||
activeScreen === Screen.LESSON_MENU;
},
......@@ -702,12 +709,25 @@ Polymer({
/**
* @param {Curriculum} curriculum
* @param {InteractionMedium} medium
* @return {string}
* @private
*/
computeLessonMenuHeader(curriculum, medium) {
return 'Lessons for the ' + curriculum + ' ' + medium + ' experience';
computeLessonMenuHeader(curriculum) {
// TODO (akihiroota): localize. (http://crbug.com/1124068).
let numLessons = 0;
for (let i = 0; i < this.lessonData.length; ++i) {
if (this.lessonData[i].curriculums.includes(curriculum)) {
numLessons += 1;
}
}
// Remove underscores and capitalize the first letter of each word.
const words = curriculum.split('_');
for (let i = 0; i < words.length; ++i) {
words[i] = words[i][0].toUpperCase() + words[i].substring(1);
}
const curriculumCopy = words.join(' ');
return `${curriculumCopy} Tutorial, ${numLessons} ${
numLessons > 1 ? 'Lessons' : 'Lesson'}`;
},
/** @private */
......
......@@ -106,4 +106,39 @@ TEST_F('ChromeVoxTutorialTest', 'BasicTest', function() {
.expectSpeech('Exit tutorial', 'Button')
.replay();
});
});
// Tests that different lessons are shown when choosing an experience from the
// main menu.
TEST_F('ChromeVoxTutorialTest', 'LessonSetTest', function() {
const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(this.simpleDoc, async function(root) {
const Panel = this.getPanel();
assertTrue(Panel.iTutorialEnabled_);
new PanelCommand(PanelCommandType.TUTORIAL).send();
await this.waitForTutorial();
const tutorial = Panel.iTutorial;
mockFeedback.expectSpeech('Choose your tutorial experience')
.call(doCmd('nextObject'))
.expectSpeech('New user', 'Button')
.call(doCmd('forceClickOnCurrentItem'))
.expectSpeech('New User Tutorial, 8 Lessons')
.call(doCmd('nextObject'))
.expectSpeech('On, Off, and Stop')
.call(() => {
// Call from the tutorial directly, instead of navigating to and
// clicking on the main menu button.
tutorial.showMainMenu();
})
.expectSpeech('Choose your tutorial experience')
.call(doCmd('nextObject'))
.expectSpeech('New user', 'Button')
.call(doCmd('nextObject'))
.expectSpeech('Experienced user', 'Button')
.call(doCmd('forceClickOnCurrentItem'))
.expectSpeech('Experienced User Tutorial, 2 Lessons')
.call(doCmd('nextObject'))
.expectSpeech('Text fields')
.replay();
});
});
\ No newline at end of file
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