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

Share more code among panel tests.

This change adds a base class for panel tests and makes
ChromeVoxPanelTest and ChromeVoxTutorialTest inherit from it.

Bug: 1127967
Change-Id: I68131a5d12e79910779cd41ad0ae51a923d6f214
AX-Relnotes: N/A
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2568685
Commit-Queue: Akihiro Ota <akihiroota@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833893}
parent 70b81ac6
......@@ -469,6 +469,7 @@ if (is_chromeos_ash) {
"options/options_test.js",
"panel/i_search_test.js",
"panel/panel_test.js",
"panel/panel_test_base.js",
"panel/tutorial_test.js",
]
gen_include_files = [
......
......@@ -3,38 +3,12 @@
// found in the LICENSE file.
// Include test fixture.
GEN_INCLUDE([
'//chrome/browser/resources/chromeos/accessibility/chromevox/testing/chromevox_next_e2e_test_base.js'
]);
GEN_INCLUDE(['panel_test_base.js']);
/**
* Test fixture for Panel.
*/
ChromeVoxPanelTest = class extends ChromeVoxNextE2ETest {
/** @override */
testGenCppIncludes() {
ChromeVoxE2ETest.prototype.testGenCppIncludes.call(this);
}
getPanelWindow() {
let panelWindow = null;
while (!panelWindow) {
panelWindow = chrome.extension.getViews().find(function(view) {
return view.location.href.indexOf('chromevox/panel/panel.html') > 0;
});
}
return panelWindow;
}
/**
* Gets the Panel object in the panel.html window. Note that the extension
* system destroys our reference to this object unpredictably so always ask
* chrome.extension.getViews for it.
*/
getPanel() {
return this.getPanelWindow().Panel;
}
ChromeVoxPanelTest = class extends ChromeVoxPanelTestBase {
fireMockEvent(key) {
return function() {
const obj = {};
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Include test fixture.
GEN_INCLUDE(['../testing/chromevox_next_e2e_test_base.js']);
/**
* Base class for Panel tests.
*/
ChromeVoxPanelTestBase = class extends ChromeVoxNextE2ETest {
/** @override */
setUp() {
window.doCmd = this.doCmd;
}
getPanelWindow() {
let panelWindow = null;
while (!panelWindow) {
panelWindow = chrome.extension.getViews().find(function(view) {
return view.location.href.indexOf('chromevox/panel/panel.html') > 0;
});
}
return panelWindow;
}
/**
* Gets the Panel object in the panel.html window. Note that the extension
* system destroys our reference to this object unpredictably so always ask
* chrome.extension.getViews for it.
*/
getPanel() {
return this.getPanelWindow().Panel;
}
};
\ No newline at end of file
......@@ -3,18 +3,13 @@
// found in the LICENSE file.
// Include test fixture.
GEN_INCLUDE(['../testing/chromevox_next_e2e_test_base.js']);
GEN_INCLUDE(['panel_test_base.js']);
GEN_INCLUDE(['../testing/mock_feedback.js']);
/**
* Test fixture for the interactive tutorial.
*/
ChromeVoxTutorialTest = class extends ChromeVoxNextE2ETest {
/** @override */
setUp() {
window.doCmd = this.doCmd;
}
ChromeVoxTutorialTest = class extends ChromeVoxPanelTestBase {
assertActiveLessonIndex(expectedIndex) {
assertEquals(expectedIndex, this.getPanel().iTutorial.activeLessonIndex);
}
......@@ -23,20 +18,6 @@ ChromeVoxTutorialTest = class extends ChromeVoxNextE2ETest {
assertEquals(expectedScreen, this.getPanel().iTutorial.activeScreen);
}
getPanelWindow() {
let panelWindow = null;
while (!panelWindow) {
panelWindow = chrome.extension.getViews().find(function(view) {
return view.location.href.indexOf('chromevox/panel/panel.html') > 0;
});
}
return panelWindow;
}
getPanel() {
return this.getPanelWindow().Panel;
}
async launchAndWaitForTutorial() {
new PanelCommand(PanelCommandType.TUTORIAL).send();
await this.waitForTutorial();
......
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