OLD | NEW |
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" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 212 |
213 generator_->ReleaseLeftButton(); | 213 generator_->ReleaseLeftButton(); |
214 EXPECT_FALSE(event_capturer_.last_mouse_event()); | 214 EXPECT_FALSE(event_capturer_.last_mouse_event()); |
215 EXPECT_TRUE(event_delegate_->CapturedAXEvent(ui::AX_EVENT_MOUSE_RELEASED)); | 215 EXPECT_TRUE(event_delegate_->CapturedAXEvent(ui::AX_EVENT_MOUSE_RELEASED)); |
216 | 216 |
217 event_capturer_.Reset(); | 217 event_capturer_.Reset(); |
218 generator_->ReleaseKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN); | 218 generator_->ReleaseKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN); |
219 EXPECT_FALSE(event_capturer_.last_key_event()); | 219 EXPECT_FALSE(event_capturer_.last_key_event()); |
220 } | 220 } |
221 | 221 |
| 222 TEST_F(SelectToSpeakEventHandlerTest, SearchPlusMouseThenCancel) { |
| 223 // If the user holds the Search key and then presses the mouse button, |
| 224 // but then releases the Search key first while the mouse is still down, |
| 225 // a cancel AX event is sent and the subsequent mouse up is canceled too. |
| 226 |
| 227 generator_->PressKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN); |
| 228 ASSERT_TRUE(event_capturer_.last_key_event()); |
| 229 EXPECT_FALSE(event_capturer_.last_key_event()->handled()); |
| 230 |
| 231 generator_->set_current_location(gfx::Point(100, 12)); |
| 232 generator_->PressLeftButton(); |
| 233 EXPECT_FALSE(event_capturer_.last_mouse_event()); |
| 234 EXPECT_TRUE(event_delegate_->CapturedAXEvent(ui::AX_EVENT_MOUSE_PRESSED)); |
| 235 |
| 236 event_capturer_.Reset(); |
| 237 generator_->ReleaseKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN); |
| 238 EXPECT_FALSE(event_capturer_.last_key_event()); |
| 239 |
| 240 EXPECT_TRUE(event_delegate_->CapturedAXEvent(ui::AX_EVENT_MOUSE_CANCELED)); |
| 241 |
| 242 generator_->ReleaseLeftButton(); |
| 243 EXPECT_FALSE(event_capturer_.last_mouse_event()); |
| 244 } |
| 245 |
222 TEST_F(SelectToSpeakEventHandlerTest, SearchPlusKeyIgnoresClicks) { | 246 TEST_F(SelectToSpeakEventHandlerTest, SearchPlusKeyIgnoresClicks) { |
223 // If the user presses the Search key and then some other key, | 247 // If the user presses the Search key and then some other key, |
224 // we should assume the user does not want select-to-speak, and | 248 // we should assume the user does not want select-to-speak, and |
225 // click events should be ignored. | 249 // click events should be ignored. |
226 | 250 |
227 generator_->PressKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN); | 251 generator_->PressKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN); |
228 ASSERT_TRUE(event_capturer_.last_key_event()); | 252 ASSERT_TRUE(event_capturer_.last_key_event()); |
229 EXPECT_FALSE(event_capturer_.last_key_event()->handled()); | 253 EXPECT_FALSE(event_capturer_.last_key_event()->handled()); |
230 | 254 |
231 generator_->PressKey(ui::VKEY_I, ui::EF_COMMAND_DOWN); | 255 generator_->PressKey(ui::VKEY_I, ui::EF_COMMAND_DOWN); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 TEST_F(SelectToSpeakEventHandlerTest, PressingControlZDoesNotStopSpeech) { | 306 TEST_F(SelectToSpeakEventHandlerTest, PressingControlZDoesNotStopSpeech) { |
283 SpeechMonitor monitor; | 307 SpeechMonitor monitor; |
284 generator_->PressKey(ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN); | 308 generator_->PressKey(ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN); |
285 generator_->PressKey(ui::VKEY_Z, ui::EF_CONTROL_DOWN); | 309 generator_->PressKey(ui::VKEY_Z, ui::EF_CONTROL_DOWN); |
286 generator_->ReleaseKey(ui::VKEY_Z, ui::EF_CONTROL_DOWN); | 310 generator_->ReleaseKey(ui::VKEY_Z, ui::EF_CONTROL_DOWN); |
287 generator_->ReleaseKey(ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN); | 311 generator_->ReleaseKey(ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN); |
288 EXPECT_FALSE(monitor.DidStop()); | 312 EXPECT_FALSE(monitor.DidStop()); |
289 } | 313 } |
290 | 314 |
291 } // namespace chromeos | 315 } // namespace chromeos |
OLD | NEW |