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

Side by Side Diff: ui/aura/event_filter_unittest.cc

Issue 10908127: events: Move EventTarget into Event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 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 | « ui/aura/event_filter.cc ('k') | ui/aura/gestures/gesture_recognizer_unittest.cc » ('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 "ui/aura/event_filter.h" 5 #include "ui/aura/event_filter.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "ui/aura/focus_manager.h" 9 #include "ui/aura/focus_manager.h"
10 #include "ui/aura/root_window.h" 10 #include "ui/aura/root_window.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 void set_key_event_handling_result(ui::EventResult result) { 49 void set_key_event_handling_result(ui::EventResult result) {
50 key_event_handling_result_ = result; 50 key_event_handling_result_ = result;
51 } 51 }
52 void set_mouse_event_handling_result(ui::EventResult result) { 52 void set_mouse_event_handling_result(ui::EventResult result) {
53 mouse_event_handling_result_ = result; 53 mouse_event_handling_result_ = result;
54 } 54 }
55 void set_consumes_touch_events(bool consumes_touch_events) { 55 void set_consumes_touch_events(bool consumes_touch_events) {
56 consumes_touch_events_ = consumes_touch_events; 56 consumes_touch_events_ = consumes_touch_events;
57 } 57 }
58 58
59 // Overridden from TestWindowDelegate: 59 // Overridden from EventHandler:
60 virtual bool OnKeyEvent(ui::KeyEvent* event) OVERRIDE { 60 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE {
61 return key_event_handling_result_ != ui::ER_UNHANDLED; 61 ++key_event_count_;
62 return key_event_handling_result_;
62 } 63 }
63 virtual bool OnMouseEvent(ui::MouseEvent* event) OVERRIDE { 64
64 return mouse_event_handling_result_ != ui::ER_UNHANDLED; 65 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
66 ++mouse_event_count_;
67 return mouse_event_handling_result_;
65 } 68 }
69
66 virtual ui::TouchStatus OnTouchEvent(ui::TouchEvent* event) OVERRIDE { 70 virtual ui::TouchStatus OnTouchEvent(ui::TouchEvent* event) OVERRIDE {
67 ++touch_event_count_; 71 ++touch_event_count_;
68 // TODO(sadrul): ! 72 // TODO(sadrul): !
69 return ui::TOUCH_STATUS_UNKNOWN; 73 return ui::TOUCH_STATUS_UNKNOWN;
70 } 74 }
71 virtual ui::EventResult OnGestureEvent( 75
72 ui::GestureEvent* event) OVERRIDE { 76 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
73 // TODO(sadrul): ! 77 // TODO(sadrul): !
74 return ui::ER_UNHANDLED; 78 return ui::ER_UNHANDLED;
75 } 79 }
76
77 // Overridden from EventHandler:
78 virtual ui::EventResult OnKeyEvent(ui::EventTarget* target,
79 ui::KeyEvent* event) OVERRIDE {
80 ++key_event_count_;
81 if (key_event_handling_result_ & ui::ER_CONSUMED)
82 return key_event_handling_result_;
83 return WindowDelegate::OnKeyEvent(target, event);
84 }
85
86 virtual ui::EventResult OnMouseEvent(ui::EventTarget* target,
87 ui::MouseEvent* event) OVERRIDE {
88 ++mouse_event_count_;
89 if (mouse_event_handling_result_ & ui::ER_CONSUMED)
90 return mouse_event_handling_result_;
91 return WindowDelegate::OnMouseEvent(target, event);
92 }
93
94 private: 80 private:
95 int key_event_count_; 81 int key_event_count_;
96 int mouse_event_count_; 82 int mouse_event_count_;
97 int touch_event_count_; 83 int touch_event_count_;
98 ui::EventResult key_event_handling_result_; 84 ui::EventResult key_event_handling_result_;
99 ui::EventResult mouse_event_handling_result_; 85 ui::EventResult mouse_event_handling_result_;
100 bool consumes_touch_events_; 86 bool consumes_touch_events_;
101 87
102 DISALLOW_COPY_AND_ASSIGN(TestEventFilterWindowDelegate); 88 DISALLOW_COPY_AND_ASSIGN(TestEventFilterWindowDelegate);
103 }; 89 };
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 generator.PressKey(ui::VKEY_A, 0); 295 generator.PressKey(ui::VKEY_A, 0);
310 generator.PressLeftButton(); 296 generator.PressLeftButton();
311 297
312 EXPECT_EQ(1, w1_filter->key_event_count()); 298 EXPECT_EQ(1, w1_filter->key_event_count());
313 EXPECT_EQ(0, d11.key_event_count()); 299 EXPECT_EQ(0, d11.key_event_count());
314 EXPECT_EQ(1, w1_filter->mouse_event_count()); 300 EXPECT_EQ(1, w1_filter->mouse_event_count());
315 EXPECT_EQ(0, d11.mouse_event_count()); 301 EXPECT_EQ(0, d11.mouse_event_count());
316 } 302 }
317 303
318 } // namespace aura 304 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/event_filter.cc ('k') | ui/aura/gestures/gesture_recognizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698