Commit 91c5f56a authored by Zach Helfinstein's avatar Zach Helfinstein Committed by Commit Bot

Revert "Ignore virtual KeyEvents in SwitchAccess"

This reverts commit 3a16d8d9.

Reason for revert: The method used to identify virtual key events with the old virtual keyboard UI no longer holds true with the new virtual keyboard UI.

I'm investigating why that's true, but to unblock progress on SwitchAccess typing, I am reverting this change.


Original change's description:
> Ignore virtual KeyEvents in SwitchAccess
> 
> Switch access should only use KeyEvents from physical keyboards as
> switches; virtual keyboard events should be ignored.
> 
> Added a browser test for SwitchAccess
> 
> BUG=864802
> 
> Change-Id: Ia50bacafe0c0740b4eea6c9f290c8679b61d79bc
> Reviewed-on: https://chromium-review.googlesource.com/1114069
> Reviewed-by: David Tseng <dtseng@chromium.org>
> Reviewed-by: Katie Dektar <katie@chromium.org>
> Commit-Queue: Zach Helfinstein <zhelfins@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#580321}

TBR=dtseng@chromium.org,katie@chromium.org,zhelfins@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 864802
Change-Id: I698bbb745e2e1371ecf4e7c800cf8d832919f927
Reviewed-on: https://chromium-review.googlesource.com/1217717Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Zach Helfinstein <zhelfins@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590370}
parent d3406a52
...@@ -451,7 +451,6 @@ class AccessibilityManager ...@@ -451,7 +451,6 @@ class AccessibilityManager
base::WeakPtrFactory<AccessibilityManager> weak_ptr_factory_; base::WeakPtrFactory<AccessibilityManager> weak_ptr_factory_;
friend class DictationTest; friend class DictationTest;
friend class SwitchAccessTest;
DISALLOW_COPY_AND_ASSIGN(AccessibilityManager); DISALLOW_COPY_AND_ASSIGN(AccessibilityManager);
}; };
......
// Copyright 2018 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 "base/command_line.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chromeos/chromeos_switches.h"
#include "content/public/test/browser_test_utils.h"
namespace chromeos {
class SwitchAccessTest : public InProcessBrowserTest {
public:
void SendVirtualKeyPress(ui::KeyboardCode key) {
ASSERT_NO_FATAL_FAILURE(ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
nullptr, key, false, false, false, false)));
}
void EnableSwitchAccess(const std::set<int>& key_codes = {'1', '2', '3',
'4'}) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
chromeos::switches::kEnableExperimentalAccessibilityFeatures);
AccessibilityManager* manager = AccessibilityManager::Get();
manager->SetSwitchAccessEnabled(true);
manager->SetSwitchAccessKeys(key_codes);
EXPECT_TRUE(manager->IsSwitchAccessEnabled());
}
protected:
SwitchAccessTest() = default;
~SwitchAccessTest() override = default;
void SetUpOnMainThread() override {}
};
IN_PROC_BROWSER_TEST_F(SwitchAccessTest, IgnoresVirtualKeyEvents) {
EnableSwitchAccess({'1', '2', '3', '4'});
// Load a webpage with a text box
ui_test_utils::NavigateToURL(
browser(), GURL("data:text/html;charset=utf-8,<input type=text id=in>"));
// Put focus in the text box
SendVirtualKeyPress(ui::KeyboardCode::VKEY_TAB);
// Send a virtual key event for one of the keys taken by switch access
SendVirtualKeyPress(ui::KeyboardCode::VKEY_1);
// Check that the text field received the keystroke
std::string output;
std::string script =
"window.domAutomationController.send("
"document.getElementById('in').value)";
ASSERT_TRUE(ExecuteScriptAndExtractString(
browser()->tab_strip_model()->GetWebContentsAt(0), script, &output));
EXPECT_STREQ(output.c_str(), "1");
}
} // namespace chromeos
...@@ -32,9 +32,6 @@ void SwitchAccessEventHandler::SetKeysToCapture( ...@@ -32,9 +32,6 @@ void SwitchAccessEventHandler::SetKeysToCapture(
void SwitchAccessEventHandler::OnKeyEvent(ui::KeyEvent* event) { void SwitchAccessEventHandler::OnKeyEvent(ui::KeyEvent* event) {
DCHECK(event); DCHECK(event);
if (!event->HasNativeEvent())
return;
ui::KeyboardCode key_code = event->key_code(); ui::KeyboardCode key_code = event->key_code();
if (captured_keys_.find(key_code) != captured_keys_.end()) { if (captured_keys_.find(key_code) != captured_keys_.end()) {
CancelEvent(event); CancelEvent(event);
......
...@@ -5000,7 +5000,6 @@ if (!is_android) { ...@@ -5000,7 +5000,6 @@ if (!is_android) {
"../browser/chromeos/accessibility/select_to_speak_browsertest.cc", "../browser/chromeos/accessibility/select_to_speak_browsertest.cc",
"../browser/chromeos/accessibility/spoken_feedback_browsertest.cc", "../browser/chromeos/accessibility/spoken_feedback_browsertest.cc",
"../browser/chromeos/accessibility/sticky_keys_browsertest.cc", "../browser/chromeos/accessibility/sticky_keys_browsertest.cc",
"../browser/chromeos/accessibility/switch_access_browsertest.cc",
"../browser/chromeos/input_method/textinput_browsertest.cc", "../browser/chromeos/input_method/textinput_browsertest.cc",
"../browser/chromeos/input_method/textinput_surroundingtext_browsertest.cc", "../browser/chromeos/input_method/textinput_surroundingtext_browsertest.cc",
"../browser/chromeos/input_method/textinput_test_helper.cc", "../browser/chromeos/input_method/textinput_test_helper.cc",
......
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