diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-15 03:21:06 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-15 03:21:06 +0000 |
commit | e4ea52364663acf64dc3a197660b78b38761a3fc (patch) | |
tree | 7ed815df5517e9c978359777cca0e860950af5ae /ash/accelerators/spoken_feedback_toggler_unittest.cc | |
parent | 726127fdb3582f187eda5595fab13eb49de11fb2 (diff) | |
download | chromium_src-e4ea52364663acf64dc3a197660b78b38761a3fc.zip chromium_src-e4ea52364663acf64dc3a197660b78b38761a3fc.tar.gz chromium_src-e4ea52364663acf64dc3a197660b78b38761a3fc.tar.bz2 |
Long press menu (shift+f6) to toggle spoken feedback.
Factor out KeyHoldDetector.
BUG=343277
TEST=SpokenFeedbackTogglerTest
Review URL: https://codereview.chromium.org/164823005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251490 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/accelerators/spoken_feedback_toggler_unittest.cc')
-rw-r--r-- | ash/accelerators/spoken_feedback_toggler_unittest.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/ash/accelerators/spoken_feedback_toggler_unittest.cc b/ash/accelerators/spoken_feedback_toggler_unittest.cc new file mode 100644 index 0000000..9344471 --- /dev/null +++ b/ash/accelerators/spoken_feedback_toggler_unittest.cc @@ -0,0 +1,50 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/accelerators/spoken_feedback_toggler.h" +#include "ash/accessibility_delegate.h" +#include "ash/shell.h" +#include "ash/test/ash_test_base.h" +#include "ash/wm/window_util.h" +#include "ui/aura/test/event_generator.h" +#include "ui/aura/test/test_window_delegate.h" + +namespace ash { + +typedef ash::test::AshTestBase SpokenFeedbackTogglerTest; + +TEST_F(SpokenFeedbackTogglerTest, Basic) { + SpokenFeedbackToggler::ScopedEnablerForTest scoped; + Shell* shell = Shell::GetInstance(); + AccessibilityDelegate* delegate = shell->accessibility_delegate(); + aura::test::EventGenerator& generator = GetEventGenerator(); + EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled()); + + generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN); + EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled()); + generator.ReleaseKey(ui::VKEY_F6, 0); + EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled()); + + // Click and hold toggles the spoken feedback. + generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN); + EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled()); + generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN); + EXPECT_TRUE(delegate->IsSpokenFeedbackEnabled()); + generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN); + EXPECT_TRUE(delegate->IsSpokenFeedbackEnabled()); + generator.ReleaseKey(ui::VKEY_F6, 0); + EXPECT_TRUE(delegate->IsSpokenFeedbackEnabled()); + + // toggle again + generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN); + EXPECT_TRUE(delegate->IsSpokenFeedbackEnabled()); + generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN); + EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled()); + generator.PressKey(ui::VKEY_F6, ui::EF_SHIFT_DOWN); + EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled()); + generator.ReleaseKey(ui::VKEY_F6, 0); + EXPECT_FALSE(delegate->IsSpokenFeedbackEnabled()); +} + +} // namespace ash |