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/sticky_keys/sticky_keys_overlay.h"
65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/shell.h"
85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/sticky_keys/sticky_keys_controller.h"
95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/test/ash_test_base.h"
105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/events/event.h"
115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace ash {
135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class StickyKeysOverlayTest : public test::AshTestBase {
155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public:
16116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  StickyKeysOverlayTest() {}
175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual ~StickyKeysOverlayTest() {}
185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)};
195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(StickyKeysOverlayTest, OverlayVisibility) {
215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  StickyKeysOverlay overlay;
225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_FALSE(overlay.is_visible());
235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  overlay.Show(true);
245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_TRUE(overlay.is_visible());
255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(StickyKeysOverlayTest, ModifierKeyState) {
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  StickyKeysOverlay overlay;
295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  overlay.SetModifierKeyState(ui::EF_SHIFT_DOWN, STICKY_KEY_STATE_DISABLED);
305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  overlay.SetModifierKeyState(ui::EF_ALT_DOWN, STICKY_KEY_STATE_LOCKED);
315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  overlay.SetModifierKeyState(ui::EF_CONTROL_DOWN, STICKY_KEY_STATE_ENABLED);
325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(STICKY_KEY_STATE_DISABLED,
345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            overlay.GetModifierKeyState(ui::EF_SHIFT_DOWN));
355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(STICKY_KEY_STATE_LOCKED,
365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            overlay.GetModifierKeyState(ui::EF_ALT_DOWN));
375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(STICKY_KEY_STATE_ENABLED,
385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            overlay.GetModifierKeyState(ui::EF_CONTROL_DOWN));
395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
41116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Additional sticky key overlay tests that depend on chromeos::EventRewriter
42116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// are now in chrome/browser/chromeos/events/event_rewriter_unittest.cc .
43c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch
445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}  // namespace ash
45