cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / ash / accelerators / spoken_feedback_toggler_unittest.cc
blob6263089fc45db9315c1b45a1c8531b9aaf7d862a
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/accelerators/spoken_feedback_toggler.h"
6 #include "ash/accessibility_delegate.h"
7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h"
9 #include "ash/wm/window_util.h"
10 #include "ui/aura/test/test_window_delegate.h"
11 #include "ui/events/test/event_generator.h"
13 namespace ash {
15 typedef ash::test::AshTestBase SpokenFeedbackTogglerTest;
17 TEST_F(SpokenFeedbackTogglerTest, Basic) {
18 SpokenFeedbackToggler::ScopedEnablerForTest scoped;
19 Shell* shell = Shell::GetInstance();
20 AccessibilityDelegate* delegate = shell->accessibility_delegate();
21 ui::test::EventGenerator& generator = GetEventGenerator();
22 EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled());
24 generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
25 EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled());
26 generator.ReleaseKey(ui::VKEY_F6, 0);
27 EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled());
29 // Click and hold toggles the spoken feedback.
30 generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
31 EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled());
32 generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
33 EXPECT_TRUE(delegate->IsSpokenFeedbackEnabled());
34 generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
35 EXPECT_TRUE(delegate->IsSpokenFeedbackEnabled());
36 generator.ReleaseKey(ui::VKEY_F6, 0);
37 EXPECT_TRUE(delegate->IsSpokenFeedbackEnabled());
39 // toggle again
40 generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
41 EXPECT_TRUE(delegate->IsSpokenFeedbackEnabled());
42 generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
43 EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled());
44 generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
45 EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled());
46 generator.ReleaseKey(ui::VKEY_F6, 0);
47 EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled());
50 TEST_F(SpokenFeedbackTogglerTest, PassThroughEvents) {
51 SpokenFeedbackToggler::ScopedEnablerForTest scoped;
53 aura::test::EventCountDelegate delegate;
54 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate(
55 &delegate, 0, gfx::Rect(0, 0, 100, 100)));
56 window->Focus();
58 ui::test::EventGenerator& generator = GetEventGenerator();
60 // None hotkey events.
61 generator.PressKey(ui::VKEY_A, 0);
62 generator.ReleaseKey(ui::VKEY_F6, 0);
63 EXPECT_EQ("1 1", delegate.GetKeyCountsAndReset());
65 // Single hotkey press and release.
66 generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
67 generator.ReleaseKey(ui::VKEY_F6, 0);
68 EXPECT_EQ("1 1", delegate.GetKeyCountsAndReset());
70 // Hotkey press and hold.
71 generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
72 generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
73 generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
74 generator.ReleaseKey(ui::VKEY_F6, 0);
75 EXPECT_EQ("3 1", delegate.GetKeyCountsAndReset());
78 } // namespace ash