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, ...@@ -83,11 +83,21 @@ class AccessibilityFeaturesApiTest : public ExtensionApiTest,
return ash::prefs::kAccessibilityAutoclickEnabled; return ash::prefs::kAccessibilityAutoclickEnabled;
if (feature == "virtualKeyboard") if (feature == "virtualKeyboard")
return ash::prefs::kAccessibilityVirtualKeyboardEnabled; 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; return NULL;
} }
// Initializes preferences before running the test extension. // 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 // |enabled_features| List of boolean preference whose value should be set to
// true. // true.
// |disabled_features| List of boolean preferences whose value should be set // |disabled_features| List of boolean preferences whose value should be set
...@@ -163,32 +173,28 @@ class AccessibilityFeaturesApiTest : public ExtensionApiTest, ...@@ -163,32 +173,28 @@ class AccessibilityFeaturesApiTest : public ExtensionApiTest,
} }
}; };
INSTANTIATE_TEST_SUITE_P(AccessibilityFeatureaApiTestInstantiatePermission, INSTANTIATE_TEST_SUITE_P(AccessibilityFeaturesApiTestInstantiatePermission,
AccessibilityFeaturesApiTest, AccessibilityFeaturesApiTest,
testing::Bool()); testing::Bool());
// Tests that an extension with read permission can read accessibility features // Tests that an extension with read permission can read accessibility features
// state, while an extension that doesn't have the permission cannot. // state, while an extension that doesn't have the permission cannot.
IN_PROC_BROWSER_TEST_P(AccessibilityFeaturesApiTest, Get) { IN_PROC_BROWSER_TEST_P(AccessibilityFeaturesApiTest, Get) {
// WARNING: Make sure that spoken feedback is not among enabled_features // WARNING: Make sure that features which load Chrome extension are not among
// (see |Set| test for the reason). // enabled_features (see |Set| test for the reason).
std::vector<std::string> enabled_features; std::vector<std::string> enabled_features = {
enabled_features.push_back("largeCursor"); "largeCursor", "stickyKeys", "highContrast", "cursorHighlight"};
enabled_features.push_back("stickyKeys");
enabled_features.push_back("highContrast"); std::vector<std::string> disabled_features = {
"spokenFeedback", "screenMagnifier", "autoclick", "virtualKeyboard",
std::vector<std::string> disabled_features; "focusHighlight", "selectToSpeak", "switchAccess", "caretHighlight"};
disabled_features.push_back("spokenFeedback");
disabled_features.push_back("screenMagnifier");
disabled_features.push_back("autoclick");
disabled_features.push_back("virtualKeyboard");
ASSERT_TRUE( ASSERT_TRUE(
InitPrefServiceForTest(GetPrefs(), enabled_features, disabled_features)); InitPrefServiceForTest(GetPrefs(), enabled_features, disabled_features));
std::string test_arg; std::string test_arg;
ASSERT_TRUE(GenerateTestArg( ASSERT_TRUE(GenerateTestArg("getterTest", enabled_features, disabled_features,
"getterTest", enabled_features, disabled_features, &test_arg)); &test_arg));
EXPECT_TRUE( EXPECT_TRUE(
RunPlatformAppTestWithArg(GetTestExtensionPath(), test_arg.c_str())) RunPlatformAppTestWithArg(GetTestExtensionPath(), test_arg.c_str()))
<< message_; << message_;
...@@ -205,13 +211,14 @@ IN_PROC_BROWSER_TEST_P(AccessibilityFeaturesApiTest, PRE_Get_ComponentApp) { ...@@ -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 // sets up access to accessibility prefs. Otherwise,this is the same as the
// |Get| test. // |Get| test.
IN_PROC_BROWSER_TEST_P(AccessibilityFeaturesApiTest, Get_ComponentApp) { IN_PROC_BROWSER_TEST_P(AccessibilityFeaturesApiTest, Get_ComponentApp) {
// WARNING: Make sure that spoken feedback is not among enabled_features // WARNING: Make sure that features which load Chrome extension are not among
// (see |AccessibilityFeaturesApiTest.Set| test for the reason). // enabled_features (see |Set| test for the reason).
std::vector<std::string> enabled_features = {"largeCursor", "stickyKeys", std::vector<std::string> enabled_features = {
"highContrast"}; "largeCursor", "stickyKeys", "highContrast", "cursorHighlight"};
std::vector<std::string> disabled_features = { std::vector<std::string> disabled_features = {
"spokenFeedback", "screenMagnifier", "autoclick", "virtualKeyboard"}; "spokenFeedback", "screenMagnifier", "autoclick", "virtualKeyboard",
"focusHighlight", "selectToSpeak", "switchAccess", "caretHighlight"};
ASSERT_TRUE( ASSERT_TRUE(
InitPrefServiceForTest(GetPrefs(), enabled_features, disabled_features)); InitPrefServiceForTest(GetPrefs(), enabled_features, disabled_features));
...@@ -228,30 +235,28 @@ IN_PROC_BROWSER_TEST_P(AccessibilityFeaturesApiTest, Get_ComponentApp) { ...@@ -228,30 +235,28 @@ IN_PROC_BROWSER_TEST_P(AccessibilityFeaturesApiTest, Get_ComponentApp) {
// Tests that an extension with modify permission can modify accessibility // Tests that an extension with modify permission can modify accessibility
// features, while an extension that doesn't have the permission can't. // features, while an extension that doesn't have the permission can't.
IN_PROC_BROWSER_TEST_P(AccessibilityFeaturesApiTest, Set) { IN_PROC_BROWSER_TEST_P(AccessibilityFeaturesApiTest, Set) {
// WARNING: Make sure that spoken feedback does not get enabled at this point // WARNING: Make sure that features which load Chrome extension are not
// (before the test app is loaded), as that may break the test: // 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 // |RunPlatformAppTestWithArg| waits for the test extension to load by
// waiting for EXTENSION_LOADED notification to be observed. It also assumes // waiting for EXTENSION_LOADED notification to be observed. It also assumes
// that there is only one extension being loaded during this time (it finishes // that there is only one extension being loaded during this time (it finishes
// when the first notification is seen). Enabling spoken feedback here would // when the first notification is seen). Enabling spoken feedback, select to
// break this assumption as it would induce loading of ChromeVox extension. // speak, autoclick, or switch access here would break this assumption as it
std::vector<std::string> enabled_features; // would induce loading of Chrome extension.
enabled_features.push_back("stickyKeys"); std::vector<std::string> enabled_features = {
enabled_features.push_back("virtualKeyboard"); "stickyKeys", "virtualKeyboard", "caretHighlight", "focusHighlight"};
std::vector<std::string> disabled_features; std::vector<std::string> disabled_features = {
disabled_features.push_back("spokenFeedback"); "spokenFeedback", "largeCursor", "highContrast", "screenMagnifier",
disabled_features.push_back("largeCursor"); "autoclick", "cursorHighlight", "selectToSpeak", "switchAccess"};
disabled_features.push_back("highContrast");
disabled_features.push_back("screenMagnifier");
disabled_features.push_back("autoclick");
ASSERT_TRUE( ASSERT_TRUE(
InitPrefServiceForTest(GetPrefs(), enabled_features, disabled_features)); InitPrefServiceForTest(GetPrefs(), enabled_features, disabled_features));
std::string test_arg; std::string test_arg;
ASSERT_TRUE(GenerateTestArg( ASSERT_TRUE(GenerateTestArg("setterTest", enabled_features, disabled_features,
"setterTest", enabled_features, disabled_features, &test_arg)); &test_arg));
// The test extension attempts to flip all feature values. // The test extension attempts to flip all feature values.
ASSERT_TRUE( ASSERT_TRUE(
...@@ -269,27 +274,24 @@ IN_PROC_BROWSER_TEST_P(AccessibilityFeaturesApiTest, Set) { ...@@ -269,27 +274,24 @@ IN_PROC_BROWSER_TEST_P(AccessibilityFeaturesApiTest, Set) {
// Tests that an extension with read permission is notified when accessibility // Tests that an extension with read permission is notified when accessibility
// features change. // features change.
IN_PROC_BROWSER_TEST_F(AccessibilityFeaturesApiTest, ObserveFeatures) { IN_PROC_BROWSER_TEST_F(AccessibilityFeaturesApiTest, ObserveFeatures) {
// WARNING: Make sure that spoken feedback is not among enabled_features // WARNING: Make sure that features which load Chrome extension are not among
// (see |Set| test for the reason). // enabled_features (see |Set| test for the reason).
std::vector<std::string> enabled_features; std::vector<std::string> enabled_features = {"largeCursor", "stickyKeys",
enabled_features.push_back("largeCursor"); "highContrast"};
enabled_features.push_back("stickyKeys");
enabled_features.push_back("highContrast");
std::vector<std::string> disabled_features; std::vector<std::string> disabled_features = {"screenMagnifier"};
disabled_features.push_back("screenMagnifier");
ASSERT_TRUE( ASSERT_TRUE(
InitPrefServiceForTest(GetPrefs(), enabled_features, disabled_features)); InitPrefServiceForTest(GetPrefs(), enabled_features, disabled_features));
std::string test_arg; std::string test_arg;
ASSERT_TRUE(GenerateTestArg( ASSERT_TRUE(GenerateTestArg("observerTest", enabled_features,
"observerTest", enabled_features, disabled_features, &test_arg)); 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 // 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 // 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. // extension may not see events.
ASSERT_TRUE(RunPlatformAppTestWithArg(kTestExtensionPathReadPermission, ASSERT_TRUE(RunPlatformAppTestWithArg(kTestExtensionPathReadPermission,
test_arg.c_str())) test_arg.c_str()))
......
...@@ -146,6 +146,15 @@ const PrefMappingEntry kPrefMapping[] = { ...@@ -146,6 +146,15 @@ const PrefMappingEntry kPrefMapping[] = {
{"autoclick", ash::prefs::kAccessibilityAutoclickEnabled, {"autoclick", ash::prefs::kAccessibilityAutoclickEnabled,
APIPermission::kAccessibilityFeaturesRead, APIPermission::kAccessibilityFeaturesRead,
APIPermission::kAccessibilityFeaturesModify}, 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, {"highContrast", ash::prefs::kAccessibilityHighContrastEnabled,
APIPermission::kAccessibilityFeaturesRead, APIPermission::kAccessibilityFeaturesRead,
APIPermission::kAccessibilityFeaturesModify}, APIPermission::kAccessibilityFeaturesModify},
...@@ -164,6 +173,9 @@ const PrefMappingEntry kPrefMapping[] = { ...@@ -164,6 +173,9 @@ const PrefMappingEntry kPrefMapping[] = {
{"stickyKeys", ash::prefs::kAccessibilityStickyKeysEnabled, {"stickyKeys", ash::prefs::kAccessibilityStickyKeysEnabled,
APIPermission::kAccessibilityFeaturesRead, APIPermission::kAccessibilityFeaturesRead,
APIPermission::kAccessibilityFeaturesModify}, APIPermission::kAccessibilityFeaturesModify},
{"switchAccess", ash::prefs::kAccessibilitySwitchAccessEnabled,
APIPermission::kAccessibilityFeaturesRead,
APIPermission::kAccessibilityFeaturesModify},
{"virtualKeyboard", ash::prefs::kAccessibilityVirtualKeyboardEnabled, {"virtualKeyboard", ash::prefs::kAccessibilityVirtualKeyboardEnabled,
APIPermission::kAccessibilityFeaturesRead, APIPermission::kAccessibilityFeaturesRead,
APIPermission::kAccessibilityFeaturesModify}, 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