Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / ash / accelerators / spoken_feedback_toggler_unittest.cc
blob20df051f0a914d8772ed16436f1cc0e03df67907
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 } // namespace ash