Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(604)

Side by Side Diff: ash/wm/window_manager_unittest.cc

Issue 206593004: Move TestEventHandler to ui/events/test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/wm/system_gesture_event_filter_unittest.cc ('k') | ui/aura/aura.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "ui/aura/client/activation_client.h" 11 #include "ui/aura/client/activation_client.h"
12 #include "ui/aura/client/activation_delegate.h" 12 #include "ui/aura/client/activation_delegate.h"
13 #include "ui/aura/client/cursor_client_observer.h" 13 #include "ui/aura/client/cursor_client_observer.h"
14 #include "ui/aura/client/focus_client.h" 14 #include "ui/aura/client/focus_client.h"
15 #include "ui/aura/env.h" 15 #include "ui/aura/env.h"
16 #include "ui/aura/test/aura_test_base.h" 16 #include "ui/aura/test/aura_test_base.h"
17 #include "ui/aura/test/event_generator.h" 17 #include "ui/aura/test/event_generator.h"
18 #include "ui/aura/test/test_event_handler.h"
19 #include "ui/aura/test/test_window_delegate.h" 18 #include "ui/aura/test/test_window_delegate.h"
20 #include "ui/aura/test/test_windows.h" 19 #include "ui/aura/test/test_windows.h"
21 #include "ui/base/cursor/cursor.h" 20 #include "ui/base/cursor/cursor.h"
22 #include "ui/base/hit_test.h" 21 #include "ui/base/hit_test.h"
23 #include "ui/events/event.h" 22 #include "ui/events/event.h"
24 #include "ui/events/event_processor.h" 23 #include "ui/events/event_processor.h"
25 #include "ui/events/event_utils.h" 24 #include "ui/events/event_utils.h"
25 #include "ui/events/test/test_event_handler.h"
26 #include "ui/gfx/screen.h" 26 #include "ui/gfx/screen.h"
27 #include "ui/wm/core/compound_event_filter.h" 27 #include "ui/wm/core/compound_event_filter.h"
28 #include "ui/wm/core/input_method_event_filter.h" 28 #include "ui/wm/core/input_method_event_filter.h"
29 29
30 namespace { 30 namespace {
31 31
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),
(...skipping 14 matching lines...) Expand all
50 50
51 DISALLOW_COPY_AND_ASSIGN(TestingCursorClientObserver); 51 DISALLOW_COPY_AND_ASSIGN(TestingCursorClientObserver);
52 }; 52 };
53 53
54 base::TimeDelta getTime() { 54 base::TimeDelta getTime() {
55 return ui::EventTimeForNow(); 55 return ui::EventTimeForNow();
56 } 56 }
57 57
58 // A slightly changed TestEventHandler which can be configured to return a 58 // A slightly changed TestEventHandler which can be configured to return a
59 // specified value for key/mouse event handling. 59 // specified value for key/mouse event handling.
60 class CustomEventHandler : public aura::test::TestEventHandler { 60 class CustomEventHandler : public ui::test::TestEventHandler {
61 public: 61 public:
62 CustomEventHandler() 62 CustomEventHandler()
63 : key_result_(ui::ER_UNHANDLED), 63 : key_result_(ui::ER_UNHANDLED),
64 mouse_result_(ui::ER_UNHANDLED) { 64 mouse_result_(ui::ER_UNHANDLED) {
65 } 65 }
66 66
67 virtual ~CustomEventHandler() {} 67 virtual ~CustomEventHandler() {}
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 aura::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 aura::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
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « ash/wm/system_gesture_event_filter_unittest.cc ('k') | ui/aura/aura.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698