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 "ui/aura/root_window.h" | 5 #include "ui/aura/root_window.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/aura/client/event_client.h" | 10 #include "ui/aura/client/event_client.h" |
11 #include "ui/aura/env.h" | 11 #include "ui/aura/env.h" |
12 #include "ui/aura/event.h" | |
13 #include "ui/aura/event_filter.h" | 12 #include "ui/aura/event_filter.h" |
14 #include "ui/aura/focus_manager.h" | 13 #include "ui/aura/focus_manager.h" |
15 #include "ui/aura/test/aura_test_base.h" | 14 #include "ui/aura/test/aura_test_base.h" |
16 #include "ui/aura/test/event_generator.h" | 15 #include "ui/aura/test/event_generator.h" |
17 #include "ui/aura/test/test_window_delegate.h" | 16 #include "ui/aura/test/test_window_delegate.h" |
18 #include "ui/aura/test/test_windows.h" | 17 #include "ui/aura/test/test_windows.h" |
| 18 #include "ui/base/event.h" |
19 #include "ui/base/gestures/gesture_configuration.h" | 19 #include "ui/base/gestures/gesture_configuration.h" |
20 #include "ui/base/hit_test.h" | 20 #include "ui/base/hit_test.h" |
21 #include "ui/base/keycodes/keyboard_codes.h" | 21 #include "ui/base/keycodes/keyboard_codes.h" |
22 #include "ui/gfx/point.h" | 22 #include "ui/gfx/point.h" |
23 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
24 #include "ui/gfx/screen.h" | 24 #include "ui/gfx/screen.h" |
25 | 25 |
26 namespace aura { | 26 namespace aura { |
27 namespace { | 27 namespace { |
28 | 28 |
(...skipping 12 matching lines...) Expand all Loading... |
41 int mouse_event_count() const { return mouse_event_count_; } | 41 int mouse_event_count() const { return mouse_event_count_; } |
42 gfx::Point mouse_event_location() const { return mouse_event_location_; } | 42 gfx::Point mouse_event_location() const { return mouse_event_location_; } |
43 int mouse_event_flags() const { return mouse_event_flags_; } | 43 int mouse_event_flags() const { return mouse_event_flags_; } |
44 | 44 |
45 virtual int GetNonClientComponent(const gfx::Point& location) const OVERRIDE { | 45 virtual int GetNonClientComponent(const gfx::Point& location) const OVERRIDE { |
46 NonClientDelegate* self = const_cast<NonClientDelegate*>(this); | 46 NonClientDelegate* self = const_cast<NonClientDelegate*>(this); |
47 self->non_client_count_++; | 47 self->non_client_count_++; |
48 self->non_client_location_ = location; | 48 self->non_client_location_ = location; |
49 return HTTOPLEFT; | 49 return HTTOPLEFT; |
50 } | 50 } |
51 virtual bool OnMouseEvent(MouseEvent* event) OVERRIDE { | 51 virtual bool OnMouseEvent(ui::MouseEvent* event) OVERRIDE { |
52 mouse_event_count_++; | 52 mouse_event_count_++; |
53 mouse_event_location_ = event->location(); | 53 mouse_event_location_ = event->location(); |
54 mouse_event_flags_ = event->flags(); | 54 mouse_event_flags_ = event->flags(); |
55 return true; | 55 return true; |
56 } | 56 } |
57 | 57 |
58 private: | 58 private: |
59 int non_client_count_; | 59 int non_client_count_; |
60 gfx::Point non_client_location_; | 60 gfx::Point non_client_location_; |
61 int mouse_event_count_; | 61 int mouse_event_count_; |
(...skipping 12 matching lines...) Expand all Loading... |
74 | 74 |
75 int num_key_events() const { return num_key_events_; } | 75 int num_key_events() const { return num_key_events_; } |
76 int num_mouse_events() const { return num_mouse_events_; } | 76 int num_mouse_events() const { return num_mouse_events_; } |
77 | 77 |
78 void Reset() { | 78 void Reset() { |
79 num_key_events_ = 0; | 79 num_key_events_ = 0; |
80 num_mouse_events_ = 0; | 80 num_mouse_events_ = 0; |
81 } | 81 } |
82 | 82 |
83 // EventFilter overrides: | 83 // EventFilter overrides: |
84 virtual bool PreHandleKeyEvent(Window* target, KeyEvent* event) OVERRIDE { | 84 virtual bool PreHandleKeyEvent(Window* target, ui::KeyEvent* event) OVERRIDE { |
85 num_key_events_++; | 85 num_key_events_++; |
86 return true; | 86 return true; |
87 } | 87 } |
88 virtual bool PreHandleMouseEvent(Window* target, MouseEvent* event) OVERRIDE { | 88 virtual bool PreHandleMouseEvent(Window* target, |
| 89 ui::MouseEvent* event) OVERRIDE { |
89 num_mouse_events_++; | 90 num_mouse_events_++; |
90 return true; | 91 return true; |
91 } | 92 } |
92 virtual ui::TouchStatus PreHandleTouchEvent( | 93 virtual ui::TouchStatus PreHandleTouchEvent( |
93 Window* target, TouchEvent* event) OVERRIDE { | 94 Window* target, ui::TouchEventImpl* event) OVERRIDE { |
94 return ui::TOUCH_STATUS_UNKNOWN; | 95 return ui::TOUCH_STATUS_UNKNOWN; |
95 } | 96 } |
96 virtual ui::GestureStatus PreHandleGestureEvent( | 97 virtual ui::GestureStatus PreHandleGestureEvent( |
97 Window* target, GestureEvent* event) OVERRIDE { | 98 Window* target, ui::GestureEventImpl* event) OVERRIDE { |
98 return ui::GESTURE_STATUS_UNKNOWN; | 99 return ui::GESTURE_STATUS_UNKNOWN; |
99 } | 100 } |
100 | 101 |
101 private: | 102 private: |
102 // How many key events have been received? | 103 // How many key events have been received? |
103 int num_key_events_; | 104 int num_key_events_; |
104 | 105 |
105 // How many mouse events have been received? | 106 // How many mouse events have been received? |
106 int num_mouse_events_; | 107 int num_mouse_events_; |
107 | 108 |
(...skipping 13 matching lines...) Expand all Loading... |
121 const int kWindowHeight = 45; | 122 const int kWindowHeight = 45; |
122 gfx::Rect bounds1(100, 200, kWindowWidth, kWindowHeight); | 123 gfx::Rect bounds1(100, 200, kWindowWidth, kWindowHeight); |
123 gfx::Rect bounds2(300, 400, kWindowWidth, kWindowHeight); | 124 gfx::Rect bounds2(300, 400, kWindowWidth, kWindowHeight); |
124 scoped_ptr<aura::Window> window1(CreateTestWindowWithDelegate( | 125 scoped_ptr<aura::Window> window1(CreateTestWindowWithDelegate( |
125 delegate1.get(), -1234, bounds1, NULL)); | 126 delegate1.get(), -1234, bounds1, NULL)); |
126 scoped_ptr<aura::Window> window2(CreateTestWindowWithDelegate( | 127 scoped_ptr<aura::Window> window2(CreateTestWindowWithDelegate( |
127 delegate2.get(), -5678, bounds2, NULL)); | 128 delegate2.get(), -5678, bounds2, NULL)); |
128 | 129 |
129 // Send a mouse event to window1. | 130 // Send a mouse event to window1. |
130 gfx::Point point(101, 201); | 131 gfx::Point point(101, 201); |
131 MouseEvent event1( | 132 ui::MouseEvent event1( |
132 ui::ET_MOUSE_PRESSED, point, point, ui::EF_LEFT_MOUSE_BUTTON); | 133 ui::ET_MOUSE_PRESSED, point, point, ui::EF_LEFT_MOUSE_BUTTON); |
133 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(&event1); | 134 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(&event1); |
134 | 135 |
135 // Event was tested for non-client area for the target window. | 136 // Event was tested for non-client area for the target window. |
136 EXPECT_EQ(1, delegate1->non_client_count()); | 137 EXPECT_EQ(1, delegate1->non_client_count()); |
137 EXPECT_EQ(0, delegate2->non_client_count()); | 138 EXPECT_EQ(0, delegate2->non_client_count()); |
138 // The non-client component test was in local coordinates. | 139 // The non-client component test was in local coordinates. |
139 EXPECT_EQ(gfx::Point(1, 1), delegate1->non_client_location()); | 140 EXPECT_EQ(gfx::Point(1, 1), delegate1->non_client_location()); |
140 // Mouse event was received by target window. | 141 // Mouse event was received by target window. |
141 EXPECT_EQ(1, delegate1->mouse_event_count()); | 142 EXPECT_EQ(1, delegate1->mouse_event_count()); |
142 EXPECT_EQ(0, delegate2->mouse_event_count()); | 143 EXPECT_EQ(0, delegate2->mouse_event_count()); |
143 // Event was in local coordinates. | 144 // Event was in local coordinates. |
144 EXPECT_EQ(gfx::Point(1, 1), delegate1->mouse_event_location()); | 145 EXPECT_EQ(gfx::Point(1, 1), delegate1->mouse_event_location()); |
145 // Non-client flag was set. | 146 // Non-client flag was set. |
146 EXPECT_TRUE(delegate1->mouse_event_flags() & ui::EF_IS_NON_CLIENT); | 147 EXPECT_TRUE(delegate1->mouse_event_flags() & ui::EF_IS_NON_CLIENT); |
147 } | 148 } |
148 | 149 |
149 // Check that we correctly track the state of the mouse buttons in response to | 150 // Check that we correctly track the state of the mouse buttons in response to |
150 // button press and release events. | 151 // button press and release events. |
151 TEST_F(RootWindowTest, MouseButtonState) { | 152 TEST_F(RootWindowTest, MouseButtonState) { |
152 EXPECT_FALSE(Env::GetInstance()->is_mouse_button_down()); | 153 EXPECT_FALSE(Env::GetInstance()->is_mouse_button_down()); |
153 | 154 |
154 gfx::Point location; | 155 gfx::Point location; |
155 scoped_ptr<MouseEvent> event; | 156 scoped_ptr<ui::MouseEvent> event; |
156 | 157 |
157 // Press the left button. | 158 // Press the left button. |
158 event.reset(new MouseEvent( | 159 event.reset(new ui::MouseEvent( |
159 ui::ET_MOUSE_PRESSED, | 160 ui::ET_MOUSE_PRESSED, |
160 location, | 161 location, |
161 location, | 162 location, |
162 ui::EF_LEFT_MOUSE_BUTTON)); | 163 ui::EF_LEFT_MOUSE_BUTTON)); |
163 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(event.get()); | 164 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(event.get()); |
164 EXPECT_TRUE(Env::GetInstance()->is_mouse_button_down()); | 165 EXPECT_TRUE(Env::GetInstance()->is_mouse_button_down()); |
165 | 166 |
166 // Additionally press the right. | 167 // Additionally press the right. |
167 event.reset(new MouseEvent( | 168 event.reset(new ui::MouseEvent( |
168 ui::ET_MOUSE_PRESSED, | 169 ui::ET_MOUSE_PRESSED, |
169 location, | 170 location, |
170 location, | 171 location, |
171 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON)); | 172 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON)); |
172 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(event.get()); | 173 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(event.get()); |
173 EXPECT_TRUE(Env::GetInstance()->is_mouse_button_down()); | 174 EXPECT_TRUE(Env::GetInstance()->is_mouse_button_down()); |
174 | 175 |
175 // Release the left button. | 176 // Release the left button. |
176 event.reset(new MouseEvent( | 177 event.reset(new ui::MouseEvent( |
177 ui::ET_MOUSE_RELEASED, | 178 ui::ET_MOUSE_RELEASED, |
178 location, | 179 location, |
179 location, | 180 location, |
180 ui::EF_RIGHT_MOUSE_BUTTON)); | 181 ui::EF_RIGHT_MOUSE_BUTTON)); |
181 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(event.get()); | 182 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(event.get()); |
182 EXPECT_TRUE(Env::GetInstance()->is_mouse_button_down()); | 183 EXPECT_TRUE(Env::GetInstance()->is_mouse_button_down()); |
183 | 184 |
184 // Release the right button. We should ignore the Shift-is-down flag. | 185 // Release the right button. We should ignore the Shift-is-down flag. |
185 event.reset(new MouseEvent( | 186 event.reset(new ui::MouseEvent( |
186 ui::ET_MOUSE_RELEASED, | 187 ui::ET_MOUSE_RELEASED, |
187 location, | 188 location, |
188 location, | 189 location, |
189 ui::EF_SHIFT_DOWN)); | 190 ui::EF_SHIFT_DOWN)); |
190 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(event.get()); | 191 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(event.get()); |
191 EXPECT_FALSE(Env::GetInstance()->is_mouse_button_down()); | 192 EXPECT_FALSE(Env::GetInstance()->is_mouse_button_down()); |
192 | 193 |
193 // Press the middle button. | 194 // Press the middle button. |
194 event.reset(new MouseEvent( | 195 event.reset(new ui::MouseEvent( |
195 ui::ET_MOUSE_PRESSED, | 196 ui::ET_MOUSE_PRESSED, |
196 location, | 197 location, |
197 location, | 198 location, |
198 ui::EF_MIDDLE_MOUSE_BUTTON)); | 199 ui::EF_MIDDLE_MOUSE_BUTTON)); |
199 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(event.get()); | 200 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(event.get()); |
200 EXPECT_TRUE(Env::GetInstance()->is_mouse_button_down()); | 201 EXPECT_TRUE(Env::GetInstance()->is_mouse_button_down()); |
201 } | 202 } |
202 | 203 |
203 TEST_F(RootWindowTest, TranslatedEvent) { | 204 TEST_F(RootWindowTest, TranslatedEvent) { |
204 scoped_ptr<Window> w1(test::CreateTestWindowWithDelegate(NULL, 1, | 205 scoped_ptr<Window> w1(test::CreateTestWindowWithDelegate(NULL, 1, |
205 gfx::Rect(50, 50, 100, 100), NULL)); | 206 gfx::Rect(50, 50, 100, 100), NULL)); |
206 | 207 |
207 gfx::Point origin(100, 100); | 208 gfx::Point origin(100, 100); |
208 MouseEvent root(ui::ET_MOUSE_PRESSED, origin, origin, 0); | 209 ui::MouseEvent root(ui::ET_MOUSE_PRESSED, origin, origin, 0); |
209 | 210 |
210 EXPECT_EQ("100,100", root.location().ToString()); | 211 EXPECT_EQ("100,100", root.location().ToString()); |
211 EXPECT_EQ("100,100", root.root_location().ToString()); | 212 EXPECT_EQ("100,100", root.root_location().ToString()); |
212 | 213 |
213 MouseEvent translated_event( | 214 ui::MouseEvent translated_event( |
214 root, root_window(), w1.get(), | 215 root, static_cast<Window*>(root_window()), w1.get(), |
215 ui::ET_MOUSE_ENTERED, root.flags()); | 216 ui::ET_MOUSE_ENTERED, root.flags()); |
216 EXPECT_EQ("50,50", translated_event.location().ToString()); | 217 EXPECT_EQ("50,50", translated_event.location().ToString()); |
217 EXPECT_EQ("100,100", translated_event.root_location().ToString()); | 218 EXPECT_EQ("100,100", translated_event.root_location().ToString()); |
218 } | 219 } |
219 | 220 |
220 namespace { | 221 namespace { |
221 | 222 |
222 class TestEventClient : public client::EventClient { | 223 class TestEventClient : public client::EventClient { |
223 public: | 224 public: |
224 static const int kNonLockWindowId = 100; | 225 static const int kNonLockWindowId = 100; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 327 |
327 // Prevent w3 from being deleted by the hierarchy since its delegate is owned | 328 // Prevent w3 from being deleted by the hierarchy since its delegate is owned |
328 // by this scope. | 329 // by this scope. |
329 w3->parent()->RemoveChild(w3.get()); | 330 w3->parent()->RemoveChild(w3.get()); |
330 } | 331 } |
331 | 332 |
332 TEST_F(RootWindowTest, IgnoreUnknownKeys) { | 333 TEST_F(RootWindowTest, IgnoreUnknownKeys) { |
333 EventCountFilter* filter = new EventCountFilter; | 334 EventCountFilter* filter = new EventCountFilter; |
334 root_window()->SetEventFilter(filter); // passes ownership | 335 root_window()->SetEventFilter(filter); // passes ownership |
335 | 336 |
336 KeyEvent unknown_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, 0); | 337 ui::KeyEvent unknown_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, 0); |
337 EXPECT_FALSE(root_window()->AsRootWindowHostDelegate()->OnHostKeyEvent( | 338 EXPECT_FALSE(root_window()->AsRootWindowHostDelegate()->OnHostKeyEvent( |
338 &unknown_event)); | 339 &unknown_event)); |
339 EXPECT_EQ(0, filter->num_key_events()); | 340 EXPECT_EQ(0, filter->num_key_events()); |
340 | 341 |
341 KeyEvent known_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0); | 342 ui::KeyEvent known_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0); |
342 EXPECT_TRUE(root_window()->AsRootWindowHostDelegate()->OnHostKeyEvent( | 343 EXPECT_TRUE(root_window()->AsRootWindowHostDelegate()->OnHostKeyEvent( |
343 &known_event)); | 344 &known_event)); |
344 EXPECT_EQ(1, filter->num_key_events()); | 345 EXPECT_EQ(1, filter->num_key_events()); |
345 } | 346 } |
346 | 347 |
347 namespace { | 348 namespace { |
348 | 349 |
349 // FilterFilter that tracks the types of events it's seen. | 350 // FilterFilter that tracks the types of events it's seen. |
350 class EventFilterRecorder : public EventFilter { | 351 class EventFilterRecorder : public EventFilter { |
351 public: | 352 public: |
352 typedef std::vector<ui::EventType> Events; | 353 typedef std::vector<ui::EventType> Events; |
353 | 354 |
354 EventFilterRecorder() {} | 355 EventFilterRecorder() {} |
355 | 356 |
356 Events& events() { return events_; } | 357 Events& events() { return events_; } |
357 | 358 |
358 // EventFilter overrides: | 359 // EventFilter overrides: |
359 virtual bool PreHandleKeyEvent(Window* target, KeyEvent* event) OVERRIDE { | 360 virtual bool PreHandleKeyEvent(Window* target, ui::KeyEvent* event) OVERRIDE { |
360 events_.push_back(event->type()); | 361 events_.push_back(event->type()); |
361 return true; | 362 return true; |
362 } | 363 } |
363 virtual bool PreHandleMouseEvent(Window* target, MouseEvent* event) OVERRIDE { | 364 virtual bool PreHandleMouseEvent(Window* target, |
| 365 ui::MouseEvent* event) OVERRIDE { |
364 events_.push_back(event->type()); | 366 events_.push_back(event->type()); |
365 return true; | 367 return true; |
366 } | 368 } |
367 virtual ui::TouchStatus PreHandleTouchEvent(Window* target, | 369 virtual ui::TouchStatus PreHandleTouchEvent( |
368 TouchEvent* event) OVERRIDE { | 370 Window* target, |
| 371 ui::TouchEventImpl* event) OVERRIDE { |
369 events_.push_back(event->type()); | 372 events_.push_back(event->type()); |
370 return ui::TOUCH_STATUS_UNKNOWN; | 373 return ui::TOUCH_STATUS_UNKNOWN; |
371 } | 374 } |
372 virtual ui::GestureStatus PreHandleGestureEvent( | 375 virtual ui::GestureStatus PreHandleGestureEvent( |
373 Window* target, | 376 Window* target, |
374 GestureEvent* event) OVERRIDE { | 377 ui::GestureEventImpl* event) OVERRIDE { |
375 events_.push_back(event->type()); | 378 events_.push_back(event->type()); |
376 return ui::GESTURE_STATUS_UNKNOWN; | 379 return ui::GESTURE_STATUS_UNKNOWN; |
377 } | 380 } |
378 | 381 |
379 private: | 382 private: |
380 Events events_; | 383 Events events_; |
381 | 384 |
382 DISALLOW_COPY_AND_ASSIGN(EventFilterRecorder); | 385 DISALLOW_COPY_AND_ASSIGN(EventFilterRecorder); |
383 }; | 386 }; |
384 | 387 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 } // namespace | 458 } // namespace |
456 | 459 |
457 TEST_F(RootWindowTest, HoldMouseMove) { | 460 TEST_F(RootWindowTest, HoldMouseMove) { |
458 EventFilterRecorder* filter = new EventFilterRecorder; | 461 EventFilterRecorder* filter = new EventFilterRecorder; |
459 root_window()->SetEventFilter(filter); // passes ownership | 462 root_window()->SetEventFilter(filter); // passes ownership |
460 | 463 |
461 test::TestWindowDelegate delegate; | 464 test::TestWindowDelegate delegate; |
462 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 465 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
463 &delegate, 1, gfx::Rect(0, 0, 100, 100), NULL)); | 466 &delegate, 1, gfx::Rect(0, 0, 100, 100), NULL)); |
464 | 467 |
465 MouseEvent mouse_move_event(ui::ET_MOUSE_MOVED, gfx::Point(0, 0), | 468 ui::MouseEvent mouse_move_event(ui::ET_MOUSE_MOVED, gfx::Point(0, 0), |
466 gfx::Point(0, 0), 0); | 469 gfx::Point(0, 0), 0); |
467 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent( | 470 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent( |
468 &mouse_move_event); | 471 &mouse_move_event); |
469 // Discard MOUSE_ENTER. | 472 // Discard MOUSE_ENTER. |
470 filter->events().clear(); | 473 filter->events().clear(); |
471 | 474 |
472 root_window()->HoldMouseMoves(); | 475 root_window()->HoldMouseMoves(); |
473 | 476 |
474 // Check that we don't immediately dispatch the MOUSE_DRAGGED event. | 477 // Check that we don't immediately dispatch the MOUSE_DRAGGED event. |
475 MouseEvent mouse_dragged_event(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), | 478 ui::MouseEvent mouse_dragged_event(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), |
476 gfx::Point(0, 0), 0); | 479 gfx::Point(0, 0), 0); |
477 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent( | 480 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent( |
478 &mouse_dragged_event); | 481 &mouse_dragged_event); |
479 EXPECT_TRUE(filter->events().empty()); | 482 EXPECT_TRUE(filter->events().empty()); |
480 | 483 |
481 // Check that we do dispatch the held MOUSE_DRAGGED event before another type | 484 // Check that we do dispatch the held MOUSE_DRAGGED event before another type |
482 // of event. | 485 // of event. |
483 MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), | 486 ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), |
484 gfx::Point(0, 0), 0); | 487 gfx::Point(0, 0), 0); |
485 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent( | 488 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent( |
486 &mouse_pressed_event); | 489 &mouse_pressed_event); |
487 EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED", | 490 EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED", |
488 EventTypesToString(filter->events())); | 491 EventTypesToString(filter->events())); |
489 filter->events().clear(); | 492 filter->events().clear(); |
490 | 493 |
491 // Check that we coalesce held MOUSE_DRAGGED events. | 494 // Check that we coalesce held MOUSE_DRAGGED events. |
492 MouseEvent mouse_dragged_event2(ui::ET_MOUSE_DRAGGED, gfx::Point(1, 1), | 495 ui::MouseEvent mouse_dragged_event2(ui::ET_MOUSE_DRAGGED, gfx::Point(1, 1), |
493 gfx::Point(1, 1), 0); | 496 gfx::Point(1, 1), 0); |
494 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent( | 497 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent( |
495 &mouse_dragged_event); | 498 &mouse_dragged_event); |
496 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent( | 499 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent( |
497 &mouse_dragged_event2); | 500 &mouse_dragged_event2); |
498 EXPECT_TRUE(filter->events().empty()); | 501 EXPECT_TRUE(filter->events().empty()); |
499 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent( | 502 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent( |
500 &mouse_pressed_event); | 503 &mouse_pressed_event); |
501 EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED", | 504 EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED", |
502 EventTypesToString(filter->events())); | 505 EventTypesToString(filter->events())); |
503 filter->events().clear(); | 506 filter->events().clear(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 root_window()->ReleaseMouseMoves(); | 538 root_window()->ReleaseMouseMoves(); |
536 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent( | 539 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent( |
537 &mouse_dragged_event2); | 540 &mouse_dragged_event2); |
538 EXPECT_EQ("MOUSE_DRAGGED", EventTypesToString(filter->events())); | 541 EXPECT_EQ("MOUSE_DRAGGED", EventTypesToString(filter->events())); |
539 filter->events().clear(); | 542 filter->events().clear(); |
540 RunAllPendingInMessageLoop(); | 543 RunAllPendingInMessageLoop(); |
541 EXPECT_TRUE(filter->events().empty()); | 544 EXPECT_TRUE(filter->events().empty()); |
542 } | 545 } |
543 | 546 |
544 } // namespace aura | 547 } // namespace aura |
OLD | NEW |