Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: chrome/browser/chromeos/accessibility/select_to_speak_event_handler_unittest.cc

Issue 2698273002: Select-to-speak: Stop speech when tapping Search or Control (Closed)
Patch Set: Trigger on tap and release of Search or Control Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/accessibility/select_to_speak_event_handler.h" 5 #include "chrome/browser/chromeos/accessibility/select_to_speak_event_handler.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
11 #include "ash/test/ash_test_helper.h" 11 #include "ash/test/ash_test_helper.h"
12 #include "ash/test/ash_test_views_delegate.h" 12 #include "ash/test/ash_test_views_delegate.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "chrome/browser/chromeos/accessibility/speech_monitor.h"
14 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" 15 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h"
15 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
16 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
17 #include "ui/events/event.h" 18 #include "ui/events/event.h"
18 #include "ui/events/event_constants.h" 19 #include "ui/events/event_constants.h"
19 #include "ui/events/test/event_generator.h" 20 #include "ui/events/test/event_generator.h"
20 #include "ui/views/views_delegate.h" 21 #include "ui/views/views_delegate.h"
21 22
22 using chromeos::SelectToSpeakEventHandler; 23 using chromeos::SelectToSpeakEventHandler;
23 24
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 std::unique_ptr<SelectToSpeakAccessibilityEventDelegate> event_delegate_; 108 std::unique_ptr<SelectToSpeakAccessibilityEventDelegate> event_delegate_;
108 109
109 private: 110 private:
110 std::unique_ptr<SelectToSpeakEventHandler> select_to_speak_event_handler_; 111 std::unique_ptr<SelectToSpeakEventHandler> select_to_speak_event_handler_;
111 112
112 DISALLOW_COPY_AND_ASSIGN(SelectToSpeakEventHandlerTest); 113 DISALLOW_COPY_AND_ASSIGN(SelectToSpeakEventHandlerTest);
113 }; 114 };
114 115
115 } // namespace 116 } // namespace
116 117
118 namespace chromeos {
119
117 TEST_F(SelectToSpeakEventHandlerTest, PressAndReleaseSearchNotHandled) { 120 TEST_F(SelectToSpeakEventHandlerTest, PressAndReleaseSearchNotHandled) {
118 // If the user presses and releases the Search key, with no mouse 121 // If the user presses and releases the Search key, with no mouse
119 // presses, the key events won't be handled by the SelectToSpeakEventHandler 122 // presses, the key events won't be handled by the SelectToSpeakEventHandler
120 // and the normal behavior will occur. 123 // and the normal behavior will occur.
121 124
122 EXPECT_FALSE(event_capturer_.last_key_event()); 125 EXPECT_FALSE(event_capturer_.last_key_event());
123 126
124 generator_->PressKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN); 127 generator_->PressKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN);
125 ASSERT_TRUE(event_capturer_.last_key_event()); 128 ASSERT_TRUE(event_capturer_.last_key_event());
126 EXPECT_FALSE(event_capturer_.last_key_event()->handled()); 129 EXPECT_FALSE(event_capturer_.last_key_event()->handled());
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 event_capturer_.Reset(); 271 event_capturer_.Reset();
269 generator_->ReleaseKey(ui::VKEY_I, ui::EF_COMMAND_DOWN); 272 generator_->ReleaseKey(ui::VKEY_I, ui::EF_COMMAND_DOWN);
270 ASSERT_TRUE(event_capturer_.last_key_event()); 273 ASSERT_TRUE(event_capturer_.last_key_event());
271 EXPECT_FALSE(event_capturer_.last_key_event()->handled()); 274 EXPECT_FALSE(event_capturer_.last_key_event()->handled());
272 275
273 event_capturer_.Reset(); 276 event_capturer_.Reset();
274 generator_->ReleaseKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN); 277 generator_->ReleaseKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN);
275 ASSERT_TRUE(event_capturer_.last_key_event()); 278 ASSERT_TRUE(event_capturer_.last_key_event());
276 EXPECT_FALSE(event_capturer_.last_key_event()->handled()); 279 EXPECT_FALSE(event_capturer_.last_key_event()->handled());
277 } 280 }
281
282 TEST_F(SelectToSpeakEventHandlerTest, TappingControlStopsSpeech) {
283 SpeechMonitor monitor;
284 EXPECT_FALSE(monitor.DidStop());
285 generator_->PressKey(ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN);
286 generator_->ReleaseKey(ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN);
287 EXPECT_TRUE(monitor.DidStop());
288 }
289
290 TEST_F(SelectToSpeakEventHandlerTest, TappingSearchStopsSpeech) {
291 SpeechMonitor monitor;
292 EXPECT_FALSE(monitor.DidStop());
293 generator_->PressKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN);
294 generator_->ReleaseKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN);
295 EXPECT_TRUE(monitor.DidStop());
296 }
297
298 TEST_F(SelectToSpeakEventHandlerTest, TappingShiftDoesNotStopSpeech) {
299 SpeechMonitor monitor;
300 generator_->PressKey(ui::VKEY_SHIFT, ui::EF_SHIFT_DOWN);
301 generator_->ReleaseKey(ui::VKEY_SHIFT, ui::EF_SHIFT_DOWN);
302 EXPECT_FALSE(monitor.DidStop());
303 }
304
305 TEST_F(SelectToSpeakEventHandlerTest, PressingControlZDoesNotStopSpeech) {
306 SpeechMonitor monitor;
307 generator_->PressKey(ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN);
308 generator_->PressKey(ui::VKEY_Z, ui::EF_CONTROL_DOWN);
309 generator_->ReleaseKey(ui::VKEY_Z, ui::EF_CONTROL_DOWN);
310 generator_->ReleaseKey(ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN);
311 EXPECT_FALSE(monitor.DidStop());
312 }
313
314 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698