diff options
-rw-r--r-- | ui/aura/test/test_cursor_client.cc | 3 | ||||
-rw-r--r-- | ui/aura/test/test_cursor_client.h | 6 | ||||
-rw-r--r-- | ui/wm/core/compound_event_filter_unittest.cc | 12 |
3 files changed, 19 insertions, 2 deletions
diff --git a/ui/aura/test/test_cursor_client.cc b/ui/aura/test/test_cursor_client.cc index 21f77cc..ef1eba2 100644 --- a/ui/aura/test/test_cursor_client.cc +++ b/ui/aura/test/test_cursor_client.cc @@ -11,6 +11,7 @@ namespace test { TestCursorClient::TestCursorClient(aura::Window* root_window) : visible_(true), + should_hide_cursor_on_key_event_(true), mouse_events_enabled_(true), cursor_lock_count_(0), calls_to_set_cursor_(0), @@ -94,7 +95,7 @@ void TestCursorClient::RemoveObserver( bool TestCursorClient::ShouldHideCursorOnKeyEvent( const ui::KeyEvent& event) const { - return true; + return should_hide_cursor_on_key_event_; } } // namespace test diff --git a/ui/aura/test/test_cursor_client.h b/ui/aura/test/test_cursor_client.h index 089827d..1372c33 100644 --- a/ui/aura/test/test_cursor_client.h +++ b/ui/aura/test/test_cursor_client.h @@ -26,6 +26,11 @@ class TestCursorClient : public aura::client::CursorClient { int calls_to_set_cursor() const { return calls_to_set_cursor_; } void reset_calls_to_set_cursor() { calls_to_set_cursor_ = 0; } + // Set whether or not to hide cursor on key events. + void set_should_hide_cursor_on_key_event(bool hide) { + should_hide_cursor_on_key_event_ = hide; + } + // Overridden from aura::client::CursorClient: virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE; virtual gfx::NativeCursor GetCursor() const OVERRIDE; @@ -50,6 +55,7 @@ class TestCursorClient : public aura::client::CursorClient { private: bool visible_; + bool should_hide_cursor_on_key_event_; bool mouse_events_enabled_; int cursor_lock_count_; int calls_to_set_cursor_; diff --git a/ui/wm/core/compound_event_filter_unittest.cc b/ui/wm/core/compound_event_filter_unittest.cc index c5e5070..aea992c 100644 --- a/ui/wm/core/compound_event_filter_unittest.cc +++ b/ui/wm/core/compound_event_filter_unittest.cc @@ -80,12 +80,21 @@ TEST_F(CompoundEventFilterTest, CursorVisibilityChange) { DispatchEventUsingWindowDispatcher(&move); EXPECT_FALSE(cursor_client.IsCursorVisible()); + // A real mouse event should show the cursor. ui::MouseEvent real_move(ui::ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10), 0, 0); DispatchEventUsingWindowDispatcher(&real_move); EXPECT_TRUE(cursor_client.IsCursorVisible()); - // Send key event to hide the cursor again. + // Disallow hiding the cursor on keypress. + cursor_client.set_should_hide_cursor_on_key_event(false); + key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, true); + DispatchEventUsingWindowDispatcher(&key); + EXPECT_TRUE(cursor_client.IsCursorVisible()); + + // Allow hiding the cursor on keypress. + cursor_client.set_should_hide_cursor_on_key_event(true); + key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, true); DispatchEventUsingWindowDispatcher(&key); EXPECT_FALSE(cursor_client.IsCursorVisible()); @@ -95,6 +104,7 @@ TEST_F(CompoundEventFilterTest, CursorVisibilityChange) { exit.set_flags(enter.flags() | ui::EF_IS_SYNTHESIZED); DispatchEventUsingWindowDispatcher(&exit); EXPECT_FALSE(cursor_client.IsCursorVisible()); + aura::Env::GetInstance()->RemovePreTargetHandler(compound_filter.get()); } #endif // defined(OS_CHROMEOS) |