15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file.
45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/accelerators/spoken_feedback_toggler.h"
65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/accessibility_delegate.h"
75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/shell.h"
85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/test/ash_test_base.h"
95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/wm/window_util.h"
105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/aura/test/test_window_delegate.h"
115f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "ui/events/test/event_generator.h"
125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace ash {
145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)typedef ash::test::AshTestBase SpokenFeedbackTogglerTest;
165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(SpokenFeedbackTogglerTest, Basic) {
185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  SpokenFeedbackToggler::ScopedEnablerForTest scoped;
195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  Shell* shell = Shell::GetInstance();
205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  AccessibilityDelegate* delegate = shell->accessibility_delegate();
215f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  ui::test::EventGenerator& generator = GetEventGenerator();
225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled());
235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled());
265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  generator.ReleaseKey(ui::VKEY_F6, 0);
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled());
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Click and hold toggles the spoken feedback.
305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled());
325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_TRUE(delegate->IsSpokenFeedbackEnabled());
345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_TRUE(delegate->IsSpokenFeedbackEnabled());
365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  generator.ReleaseKey(ui::VKEY_F6, 0);
375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_TRUE(delegate->IsSpokenFeedbackEnabled());
385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // toggle again
405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_TRUE(delegate->IsSpokenFeedbackEnabled());
425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled());
445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN);
455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled());
465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  generator.ReleaseKey(ui::VKEY_F6, 0);
475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled());
485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}  // namespace ash
51