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.
4
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/event_generator.h"
11 #include "ui/aura/test/test_window_delegate.h"
12
13 namespace ash {
14
15 typedef ash::test::AshTestBase SpokenFeedbackTogglerTest;
16
TEST_F(SpokenFeedbackTogglerTest,Basic)17 TEST_F(SpokenFeedbackTogglerTest, Basic) {
18 SpokenFeedbackToggler::ScopedEnablerForTest scoped;
19 Shell* shell = Shell::GetInstance();
20 AccessibilityDelegate* delegate = shell->accessibility_delegate();
21 aura::test::EventGenerator& generator = GetEventGenerator();
22 EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled());
23
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());
28
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());
38
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());
48 }
49
50 } // namespace ash
51