Commit 6d9b0b8d authored by Hiroki Sato's avatar Hiroki Sato Committed by Commit Bot

Add missing chrome.accessibilityFeature APIs

Bug: None
Test: browser_tests --gtest_filter="AccessibilityFeaturesApiTest*"
Change-Id: I075f1c3c563ee311e733bf7dea59cbcf1c41cf47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1994551
Commit-Queue: Hiroki Sato <hirokisato@chromium.org>
Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732717}
parent c62ee9f8
......@@ -83,11 +83,21 @@ class AccessibilityFeaturesApiTest : public ExtensionApiTest,
return ash::prefs::kAccessibilityAutoclickEnabled;
if (feature == "virtualKeyboard")
return ash::prefs::kAccessibilityVirtualKeyboardEnabled;
if (feature == "caretHighlight")
return ash::prefs::kAccessibilityCaretHighlightEnabled;
if (feature == "cursorHighlight")
return ash::prefs::kAccessibilityCursorHighlightEnabled;
if (feature == "focusHighlight")
return ash::prefs::kAccessibilityFocusHighlightEnabled;
if (feature == "selectToSpeak")
return ash::prefs::kAccessibilitySelectToSpeakEnabled;
if (feature == "switchAccess")
return ash::prefs::kAccessibilitySwitchAccessEnabled;
return NULL;
}
// Initializes preferences before running the test extension.
// |prefs| Pref service which should be initializzed.
// |prefs| Pref service which should be initialized.
// |enabled_features| List of boolean preference whose value should be set to
// true.
// |disabled_features| List of boolean preferences whose value should be set
......@@ -163,32 +173,28 @@ class AccessibilityFeaturesApiTest : public ExtensionApiTest,
}
};
INSTANTIATE_TEST_SUITE_P(AccessibilityFeatureaApiTestInstantiatePermission,
INSTANTIATE_TEST_SUITE_P(AccessibilityFeaturesApiTestInstantiatePermission,
AccessibilityFeaturesApiTest,
testing::Bool());
// Tests that an extension with read permission can read accessibility features
// state, while an extension that doesn't have the permission cannot.
IN_PROC_BROWSER_TEST_P(AccessibilityFeaturesApiTest, Get) {
// WARNING: Make sure that spoken feedback is not among enabled_features
// (see |Set| test for the reason).
std::vector<std::string> enabled_features;
enabled_features.push_back("largeCursor");
enabled_features.push_back("stickyKeys");
enabled_features.push_back("highContrast");
std::vector<std::string> disabled_features;
disabled_features.push_back("spokenFeedback");
disabled_features.push_back("screenMagnifier");
disabled_features.push_back("autoclick");
disabled_features.push_back("virtualKeyboard");
// WARNING: Make sure that features which load Chrome extension are not among
// enabled_features (see |Set| test for the reason).
std::vector<std::string> enabled_features = {
"largeCursor", "stickyKeys", "highContrast", "cursorHighlight"};
std::vector<std::string> disabled_features = {
"spokenFeedback", "screenMagnifier", "autoclick", "virtualKeyboard",
"focusHighlight", "selectToSpeak", "switchAccess", "caretHighlight"};
ASSERT_TRUE(
InitPrefServiceForTest(GetPrefs(), enabled_features, disabled_features));
std::string test_arg;
ASSERT_TRUE(GenerateTestArg(
"getterTest", enabled_features, disabled_features, &test_arg));
ASSERT_TRUE(GenerateTestArg("getterTest", enabled_features, disabled_features,
&test_arg));
EXPECT_TRUE(
RunPlatformAppTestWithArg(GetTestExtensionPath(), test_arg.c_str()))
<< message_;
......@@ -205,13 +211,14 @@ IN_PROC_BROWSER_TEST_P(AccessibilityFeaturesApiTest, PRE_Get_ComponentApp) {
// sets up access to accessibility prefs. Otherwise,this is the same as the
// |Get| test.
IN_PROC_BROWSER_TEST_P(AccessibilityFeaturesApiTest, Get_ComponentApp) {
// WARNING: Make sure that spoken feedback is not among enabled_features
// (see |AccessibilityFeaturesApiTest.Set| test for the reason).
std::vector<std::string> enabled_features = {"largeCursor", "stickyKeys",
"highContrast"};
// WARNING: Make sure that features which load Chrome extension are not among
// enabled_features (see |Set| test for the reason).
std::vector<std::string> enabled_features = {
"largeCursor", "stickyKeys", "highContrast", "cursorHighlight"};
std::vector<std::string> disabled_features = {
"spokenFeedback", "screenMagnifier", "autoclick", "virtualKeyboard"};
"spokenFeedback", "screenMagnifier", "autoclick", "virtualKeyboard",
"focusHighlight", "selectToSpeak", "switchAccess", "caretHighlight"};
ASSERT_TRUE(
InitPrefServiceForTest(GetPrefs(), enabled_features, disabled_features));
......@@ -228,30 +235,28 @@ IN_PROC_BROWSER_TEST_P(AccessibilityFeaturesApiTest, Get_ComponentApp) {
// Tests that an extension with modify permission can modify accessibility
// features, while an extension that doesn't have the permission can't.
IN_PROC_BROWSER_TEST_P(AccessibilityFeaturesApiTest, Set) {
// WARNING: Make sure that spoken feedback does not get enabled at this point
// (before the test app is loaded), as that may break the test:
// WARNING: Make sure that features which load Chrome extension are not
// enabled at this point (before the test app is loaded), as that may break
// the test:
// |RunPlatformAppTestWithArg| waits for the test extension to load by
// waiting for EXTENSION_LOADED notification to be observed. It also assumes
// that there is only one extension being loaded during this time (it finishes
// when the first notification is seen). Enabling spoken feedback here would
// break this assumption as it would induce loading of ChromeVox extension.
std::vector<std::string> enabled_features;
enabled_features.push_back("stickyKeys");
enabled_features.push_back("virtualKeyboard");
std::vector<std::string> disabled_features;
disabled_features.push_back("spokenFeedback");
disabled_features.push_back("largeCursor");
disabled_features.push_back("highContrast");
disabled_features.push_back("screenMagnifier");
disabled_features.push_back("autoclick");
// when the first notification is seen). Enabling spoken feedback, select to
// speak, autoclick, or switch access here would break this assumption as it
// would induce loading of Chrome extension.
std::vector<std::string> enabled_features = {
"stickyKeys", "virtualKeyboard", "caretHighlight", "focusHighlight"};
std::vector<std::string> disabled_features = {
"spokenFeedback", "largeCursor", "highContrast", "screenMagnifier",
"autoclick", "cursorHighlight", "selectToSpeak", "switchAccess"};
ASSERT_TRUE(
InitPrefServiceForTest(GetPrefs(), enabled_features, disabled_features));
std::string test_arg;
ASSERT_TRUE(GenerateTestArg(
"setterTest", enabled_features, disabled_features, &test_arg));
ASSERT_TRUE(GenerateTestArg("setterTest", enabled_features, disabled_features,
&test_arg));
// The test extension attempts to flip all feature values.
ASSERT_TRUE(
......@@ -269,27 +274,24 @@ IN_PROC_BROWSER_TEST_P(AccessibilityFeaturesApiTest, Set) {
// Tests that an extension with read permission is notified when accessibility
// features change.
IN_PROC_BROWSER_TEST_F(AccessibilityFeaturesApiTest, ObserveFeatures) {
// WARNING: Make sure that spoken feedback is not among enabled_features
// (see |Set| test for the reason).
std::vector<std::string> enabled_features;
enabled_features.push_back("largeCursor");
enabled_features.push_back("stickyKeys");
enabled_features.push_back("highContrast");
// WARNING: Make sure that features which load Chrome extension are not among
// enabled_features (see |Set| test for the reason).
std::vector<std::string> enabled_features = {"largeCursor", "stickyKeys",
"highContrast"};
std::vector<std::string> disabled_features;
disabled_features.push_back("screenMagnifier");
std::vector<std::string> disabled_features = {"screenMagnifier"};
ASSERT_TRUE(
InitPrefServiceForTest(GetPrefs(), enabled_features, disabled_features));
std::string test_arg;
ASSERT_TRUE(GenerateTestArg(
"observerTest", enabled_features, disabled_features, &test_arg));
ASSERT_TRUE(GenerateTestArg("observerTest", enabled_features,
disabled_features, &test_arg));
// The test extension is supposed to report result twice when runnign this
// The test extension is supposed to report result twice when running this
// test. First time when in initializes it's feature listeners, and second
// time, when gets all expected events. This is done so the extension is
// running when the accessibility features are flipped; oterwise, the
// running when the accessibility features are flipped; otherwise, the
// extension may not see events.
ASSERT_TRUE(RunPlatformAppTestWithArg(kTestExtensionPathReadPermission,
test_arg.c_str()))
......
......@@ -146,6 +146,15 @@ const PrefMappingEntry kPrefMapping[] = {
{"autoclick", ash::prefs::kAccessibilityAutoclickEnabled,
APIPermission::kAccessibilityFeaturesRead,
APIPermission::kAccessibilityFeaturesModify},
{"caretHighlight", ash::prefs::kAccessibilityCaretHighlightEnabled,
APIPermission::kAccessibilityFeaturesRead,
APIPermission::kAccessibilityFeaturesModify},
{"cursorHighlight", ash::prefs::kAccessibilityCursorHighlightEnabled,
APIPermission::kAccessibilityFeaturesRead,
APIPermission::kAccessibilityFeaturesModify},
{"focusHighlight", ash::prefs::kAccessibilityFocusHighlightEnabled,
APIPermission::kAccessibilityFeaturesRead,
APIPermission::kAccessibilityFeaturesModify},
{"highContrast", ash::prefs::kAccessibilityHighContrastEnabled,
APIPermission::kAccessibilityFeaturesRead,
APIPermission::kAccessibilityFeaturesModify},
......@@ -164,6 +173,9 @@ const PrefMappingEntry kPrefMapping[] = {
{"stickyKeys", ash::prefs::kAccessibilityStickyKeysEnabled,
APIPermission::kAccessibilityFeaturesRead,
APIPermission::kAccessibilityFeaturesModify},
{"switchAccess", ash::prefs::kAccessibilitySwitchAccessEnabled,
APIPermission::kAccessibilityFeaturesRead,
APIPermission::kAccessibilityFeaturesModify},
{"virtualKeyboard", ash::prefs::kAccessibilityVirtualKeyboardEnabled,
APIPermission::kAccessibilityFeaturesRead,
APIPermission::kAccessibilityFeaturesModify},
......
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