Commit 7fa3da5c authored by David Tseng's avatar David Tseng Committed by Chromium LUCI CQ

Add test suite for STS options page

After
https://chromium-review.googlesource.com/c/chromium/src/+/2613726
and
https://chromium-review.googlesource.com/c/chromium/src/+/2622754

there appears to be a lack of testing for Select to Speak's options page.

This change adds a basic sanity test and a foundation to write more as
features are added.

R=joelriley@google.com, katie@chromium.org

AX-Relnotes: n/a
Bug: none
Test: this.
Change-Id: Id9fc395b1b95c81fbea4e10bfc5fb86e3f3645fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2626914
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarKatie Dektar <katie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843167}
parent 2fb616ae
......@@ -136,6 +136,33 @@ E2ETestBase = class extends testing.Test {
});
}
/**
* Opens the options page for the running extension and calls |callback| with
* the options page root once ready.
* @param {function(chrome.automation.AutomationNode)} callback
* @param {!RegExp} matchUrlRegExp The url pattern of the options page if
* different than the supplied default pattern below.
*/
runWithLoadedOptionsPage(callback, matchUrlRegExp = /options.html/) {
callback = this.newCallback(callback);
chrome.automation.getDesktop((desktop) => {
const listener = (event) => {
if (!matchUrlRegExp.test(event.target.docUrl) ||
!event.target.docLoaded) {
return;
}
desktop.removeEventListener(
chrome.automation.EventType.LOAD_COMPLETE, listener);
callback(event.target);
};
desktop.addEventListener(
chrome.automation.EventType.LOAD_COMPLETE, listener);
chrome.runtime.openOptionsPage();
});
}
/**
* Finds one specific node in the automation tree.
* This function is expected to run within a callback passed to
......
......@@ -82,6 +82,7 @@ js2gtest("select_to_speak_extjs_tests") {
"select_to_speak_keystroke_selection_test.js",
"select_to_speak_mouse_selection_test.js",
"select_to_speak_navigation_control_test.js",
"select_to_speak_options_test.js",
"select_to_speak_prefs_test.js",
]
......
// Copyright 2021 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.
GEN_INCLUDE(['select_to_speak_e2e_test_base.js']);
/**
* Browser tests for select-to-speak's options page.
*/
SelectToSpeakOptionsTest = class extends SelectToSpeakE2ETest {};
TEST_F('SelectToSpeakOptionsTest', 'RendersContent', function() {
this.runWithLoadedOptionsPage(root => {
// Sanity check the page renders correctly by looking for an item close or
// at the very end of the page.
const enableNavControlsSwitch =
root.find({attributes: {name: 'Enable navigation controls'}});
assertNotNullNorUndefined(enableNavControlsSwitch);
assertEquals(
chrome.automation.RoleType.SWITCH, enableNavControlsSwitch.role);
});
});
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