| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/shell.h" | 5 #include "ash/shell.h" |
| 6 #include "ash/shell_window_ids.h" | 6 #include "ash/shell_window_ids.h" |
| 7 #include "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
| 8 #include "ash/test/shell_test_api.h" | 8 #include "ash/test/shell_test_api.h" |
| 9 #include "ash/test/test_activation_delegate.h" | 9 #include "ash/test/test_activation_delegate.h" |
| 10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 class TestingCursorClientObserver : public aura::client::CursorClientObserver { | 32 class TestingCursorClientObserver : public aura::client::CursorClientObserver { |
| 33 public: | 33 public: |
| 34 TestingCursorClientObserver() | 34 TestingCursorClientObserver() |
| 35 : cursor_visibility_(false), | 35 : cursor_visibility_(false), |
| 36 did_visibility_change_(false) {} | 36 did_visibility_change_(false) {} |
| 37 void reset() { cursor_visibility_ = did_visibility_change_ = false; } | 37 void reset() { cursor_visibility_ = did_visibility_change_ = false; } |
| 38 bool is_cursor_visible() const { return cursor_visibility_; } | 38 bool is_cursor_visible() const { return cursor_visibility_; } |
| 39 bool did_visibility_change() const { return did_visibility_change_; } | 39 bool did_visibility_change() const { return did_visibility_change_; } |
| 40 | 40 |
| 41 // Overridden from aura::client::CursorClientObserver: | 41 // Overridden from aura::client::CursorClientObserver: |
| 42 virtual void OnCursorVisibilityChanged(bool is_visible) OVERRIDE { | 42 virtual void OnCursorVisibilityChanged(bool is_visible) override { |
| 43 cursor_visibility_ = is_visible; | 43 cursor_visibility_ = is_visible; |
| 44 did_visibility_change_ = true; | 44 did_visibility_change_ = true; |
| 45 } | 45 } |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 bool cursor_visibility_; | 48 bool cursor_visibility_; |
| 49 bool did_visibility_change_; | 49 bool did_visibility_change_; |
| 50 | 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(TestingCursorClientObserver); | 51 DISALLOW_COPY_AND_ASSIGN(TestingCursorClientObserver); |
| 52 }; | 52 }; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 68 | 68 |
| 69 void set_key_event_handling_result(ui::EventResult result) { | 69 void set_key_event_handling_result(ui::EventResult result) { |
| 70 key_result_ = result; | 70 key_result_ = result; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void set_mouse_event_handling_result(ui::EventResult result) { | 73 void set_mouse_event_handling_result(ui::EventResult result) { |
| 74 mouse_result_ = result; | 74 mouse_result_ = result; |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Overridden from ui::EventHandler: | 77 // Overridden from ui::EventHandler: |
| 78 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { | 78 virtual void OnKeyEvent(ui::KeyEvent* event) override { |
| 79 ui::test::TestEventHandler::OnKeyEvent(event); | 79 ui::test::TestEventHandler::OnKeyEvent(event); |
| 80 if (key_result_ & ui::ER_HANDLED) | 80 if (key_result_ & ui::ER_HANDLED) |
| 81 event->SetHandled(); | 81 event->SetHandled(); |
| 82 if (key_result_ & ui::ER_CONSUMED) | 82 if (key_result_ & ui::ER_CONSUMED) |
| 83 event->StopPropagation(); | 83 event->StopPropagation(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 86 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
| 87 ui::test::TestEventHandler::OnMouseEvent(event); | 87 ui::test::TestEventHandler::OnMouseEvent(event); |
| 88 if (mouse_result_ & ui::ER_HANDLED) | 88 if (mouse_result_ & ui::ER_HANDLED) |
| 89 event->SetHandled(); | 89 event->SetHandled(); |
| 90 if (mouse_result_ & ui::ER_CONSUMED) | 90 if (mouse_result_ & ui::ER_CONSUMED) |
| 91 event->StopPropagation(); | 91 event->StopPropagation(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 ui::EventResult key_result_; | 95 ui::EventResult key_result_; |
| 96 ui::EventResult mouse_result_; | 96 ui::EventResult mouse_result_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(CustomEventHandler); | 98 DISALLOW_COPY_AND_ASSIGN(CustomEventHandler); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 } // namespace | 101 } // namespace |
| 102 | 102 |
| 103 namespace ash { | 103 namespace ash { |
| 104 | 104 |
| 105 typedef test::AshTestBase WindowManagerTest; | 105 typedef test::AshTestBase WindowManagerTest; |
| 106 | 106 |
| 107 class NonFocusableDelegate : public aura::test::TestWindowDelegate { | 107 class NonFocusableDelegate : public aura::test::TestWindowDelegate { |
| 108 public: | 108 public: |
| 109 NonFocusableDelegate() {} | 109 NonFocusableDelegate() {} |
| 110 | 110 |
| 111 private: | 111 private: |
| 112 virtual bool CanFocus() OVERRIDE { | 112 virtual bool CanFocus() override { |
| 113 return false; | 113 return false; |
| 114 } | 114 } |
| 115 | 115 |
| 116 DISALLOW_COPY_AND_ASSIGN(NonFocusableDelegate); | 116 DISALLOW_COPY_AND_ASSIGN(NonFocusableDelegate); |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 class HitTestWindowDelegate : public aura::test::TestWindowDelegate { | 119 class HitTestWindowDelegate : public aura::test::TestWindowDelegate { |
| 120 public: | 120 public: |
| 121 HitTestWindowDelegate() | 121 HitTestWindowDelegate() |
| 122 : hittest_code_(HTNOWHERE) { | 122 : hittest_code_(HTNOWHERE) { |
| 123 } | 123 } |
| 124 virtual ~HitTestWindowDelegate() {} | 124 virtual ~HitTestWindowDelegate() {} |
| 125 void set_hittest_code(int hittest_code) { hittest_code_ = hittest_code; } | 125 void set_hittest_code(int hittest_code) { hittest_code_ = hittest_code; } |
| 126 | 126 |
| 127 private: | 127 private: |
| 128 // Overridden from TestWindowDelegate: | 128 // Overridden from TestWindowDelegate: |
| 129 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE { | 129 virtual int GetNonClientComponent(const gfx::Point& point) const override { |
| 130 return hittest_code_; | 130 return hittest_code_; |
| 131 } | 131 } |
| 132 | 132 |
| 133 int hittest_code_; | 133 int hittest_code_; |
| 134 | 134 |
| 135 DISALLOW_COPY_AND_ASSIGN(HitTestWindowDelegate); | 135 DISALLOW_COPY_AND_ASSIGN(HitTestWindowDelegate); |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 TEST_F(WindowManagerTest, Focus) { | 138 TEST_F(WindowManagerTest, Focus) { |
| 139 // The IME event filter interferes with the basic key event propagation we | 139 // The IME event filter interferes with the basic key event propagation we |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 observer_a.reset(); | 831 observer_a.reset(); |
| 832 observer_b.reset(); | 832 observer_b.reset(); |
| 833 generator.MoveMouseTo(50, 50); | 833 generator.MoveMouseTo(50, 50); |
| 834 EXPECT_TRUE(observer_a.did_visibility_change()); | 834 EXPECT_TRUE(observer_a.did_visibility_change()); |
| 835 EXPECT_FALSE(observer_b.did_visibility_change()); | 835 EXPECT_FALSE(observer_b.did_visibility_change()); |
| 836 EXPECT_TRUE(observer_a.is_cursor_visible()); | 836 EXPECT_TRUE(observer_a.is_cursor_visible()); |
| 837 } | 837 } |
| 838 #endif // defined(OS_CHROMEOS) | 838 #endif // defined(OS_CHROMEOS) |
| 839 | 839 |
| 840 } // namespace ash | 840 } // namespace ash |
| OLD | NEW |