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

Side by Side Diff: ui/events/test/event_generator.cc

Issue 322893005: MacViews: Add WidgetEventGenerator to abstract platform-specific event generation for tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move to events/test. ui:: stripping deferred. fix new win64 warnings (enabled in events) Created 6 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/test/event_generator.h" 5 #include "ui/events/test/event_generator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h"
8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/time/default_tick_clock.h" 11 #include "base/time/default_tick_clock.h"
11 #include "ui/aura/client/screen_position_client.h"
12 #include "ui/aura/window_event_dispatcher.h"
13 #include "ui/aura/window_tree_host.h"
14 #include "ui/events/event.h" 12 #include "ui/events/event.h"
15 #include "ui/events/event_source.h" 13 #include "ui/events/event_source.h"
16 #include "ui/events/event_utils.h" 14 #include "ui/events/event_utils.h"
17 #include "ui/events/test/events_test_utils.h" 15 #include "ui/events/test/events_test_utils.h"
18 #include "ui/gfx/vector2d_conversions.h" 16 #include "ui/gfx/vector2d_conversions.h"
19 17
20 #if defined(USE_X11) 18 #if defined(USE_X11)
21 #include <X11/Xlib.h> 19 #include <X11/Xlib.h>
22 #include "ui/base/x/x11_util.h"
23 #include "ui/events/event_utils.h"
24 #include "ui/events/test/events_test_utils_x11.h" 20 #include "ui/events/test/events_test_utils_x11.h"
25 #endif 21 #endif
26 22
27 #if defined(OS_WIN) 23 #if defined(OS_WIN)
28 #include "ui/events/keycodes/keyboard_code_conversion.h" 24 #include "ui/events/keycodes/keyboard_code_conversion.h"
29 #endif 25 #endif
30 26
31 namespace aura { 27 namespace ui {
32 namespace test { 28 namespace test {
33 namespace { 29 namespace {
34 30
35 void DummyCallback(ui::EventType, const gfx::Vector2dF&) { 31 void DummyCallback(EventType, const gfx::Vector2dF&) {
36 } 32 }
37 33
38 class DefaultEventGeneratorDelegate : public EventGeneratorDelegate {
39 public:
40 explicit DefaultEventGeneratorDelegate(Window* root_window)
41 : root_window_(root_window) {}
42 virtual ~DefaultEventGeneratorDelegate() {}
43
44 // EventGeneratorDelegate overrides:
45 virtual WindowTreeHost* GetHostAt(const gfx::Point& point) const OVERRIDE {
46 return root_window_->GetHost();
47 }
48
49 virtual client::ScreenPositionClient* GetScreenPositionClient(
50 const aura::Window* window) const OVERRIDE {
51 return NULL;
52 }
53
54 private:
55 Window* root_window_;
56
57 DISALLOW_COPY_AND_ASSIGN(DefaultEventGeneratorDelegate);
58 };
59
60 class TestKeyEvent : public ui::KeyEvent { 34 class TestKeyEvent : public ui::KeyEvent {
61 public: 35 public:
62 TestKeyEvent(const base::NativeEvent& native_event, int flags, bool is_char) 36 TestKeyEvent(const base::NativeEvent& native_event, int flags, bool is_char)
63 : KeyEvent(native_event, is_char) { 37 : KeyEvent(native_event, is_char) {
64 set_flags(flags); 38 set_flags(flags);
65 } 39 }
66 }; 40 };
67 41
68 class TestTouchEvent : public ui::TouchEvent { 42 class TestTouchEvent : public ui::TouchEvent {
69 public: 43 public:
70 TestTouchEvent(ui::EventType type, 44 TestTouchEvent(ui::EventType type,
71 const gfx::Point& root_location, 45 const gfx::Point& root_location,
72 int touch_id, 46 int touch_id,
73 int flags, 47 int flags,
74 base::TimeDelta timestamp) 48 base::TimeDelta timestamp)
75 : TouchEvent(type, root_location, flags, touch_id, timestamp, 49 : TouchEvent(type, root_location, flags, touch_id, timestamp,
76 1.0f, 1.0f, 1.0f, 1.0f) { 50 1.0f, 1.0f, 1.0f, 1.0f) {
77 } 51 }
78 52
79 private: 53 private:
80 DISALLOW_COPY_AND_ASSIGN(TestTouchEvent); 54 DISALLOW_COPY_AND_ASSIGN(TestTouchEvent);
81 }; 55 };
82 56
83 const int kAllButtonMask = ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON; 57 const int kAllButtonMask = ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON;
84 58
85 } // namespace 59 } // namespace
86 60
87 EventGenerator::EventGenerator(Window* root_window) 61 EventGenerator::EventGenerator(EventGeneratorDelegate* delegate,
88 : delegate_(new DefaultEventGeneratorDelegate(root_window)), 62 const gfx::Point& initial_location)
89 current_host_(delegate_->GetHostAt(current_location_)), 63 : delegate_(delegate),
64 current_location_(initial_location),
65 current_target_(delegate_->GetTargetAt(current_location_)),
90 flags_(0), 66 flags_(0),
91 grab_(false), 67 grab_(false),
92 async_(false), 68 async_(false),
93 tick_clock_(new base::DefaultTickClock()) {
94 }
95
96 EventGenerator::EventGenerator(Window* root_window, const gfx::Point& point)
97 : delegate_(new DefaultEventGeneratorDelegate(root_window)),
98 current_location_(point),
99 current_host_(delegate_->GetHostAt(current_location_)),
100 flags_(0),
101 grab_(false),
102 async_(false),
103 tick_clock_(new base::DefaultTickClock()) {
104 }
105
106 EventGenerator::EventGenerator(Window* root_window, Window* window)
107 : delegate_(new DefaultEventGeneratorDelegate(root_window)),
108 current_location_(CenterOfWindow(window)),
109 current_host_(delegate_->GetHostAt(current_location_)),
110 flags_(0),
111 grab_(false),
112 async_(false),
113 tick_clock_(new base::DefaultTickClock()) {
114 }
115
116 EventGenerator::EventGenerator(EventGeneratorDelegate* delegate)
117 : delegate_(delegate),
118 current_host_(delegate_->GetHostAt(current_location_)),
119 flags_(0),
120 grab_(false),
121 async_(false),
122 tick_clock_(new base::DefaultTickClock()) { 69 tick_clock_(new base::DefaultTickClock()) {
123 } 70 }
124 71
125 EventGenerator::~EventGenerator() { 72 EventGenerator::~EventGenerator() {
126 for (std::list<ui::Event*>::iterator i = pending_events_.begin(); 73 for (std::list<ui::Event*>::iterator i = pending_events_.begin();
127 i != pending_events_.end(); ++i) 74 i != pending_events_.end(); ++i)
128 delete *i; 75 delete *i;
129 pending_events_.clear(); 76 pending_events_.clear();
130 } 77 }
131 78
(...skipping 27 matching lines...) Expand all
159 106
160 void EventGenerator::MoveMouseWheel(int delta_x, int delta_y) { 107 void EventGenerator::MoveMouseWheel(int delta_x, int delta_y) {
161 gfx::Point location = GetLocationInCurrentRoot(); 108 gfx::Point location = GetLocationInCurrentRoot();
162 ui::MouseEvent mouseev(ui::ET_MOUSEWHEEL, location, location, flags_, 0); 109 ui::MouseEvent mouseev(ui::ET_MOUSEWHEEL, location, location, flags_, 0);
163 ui::MouseWheelEvent wheelev(mouseev, delta_x, delta_y); 110 ui::MouseWheelEvent wheelev(mouseev, delta_x, delta_y);
164 Dispatch(&wheelev); 111 Dispatch(&wheelev);
165 } 112 }
166 113
167 void EventGenerator::SendMouseExit() { 114 void EventGenerator::SendMouseExit() {
168 gfx::Point exit_location(current_location_); 115 gfx::Point exit_location(current_location_);
169 ConvertPointToTarget(current_host_->window(), &exit_location); 116 delegate_->ConvertPointToTarget(current_target_, &exit_location);
170 ui::MouseEvent mouseev(ui::ET_MOUSE_EXITED, exit_location, exit_location, 117 ui::MouseEvent mouseev(ui::ET_MOUSE_EXITED, exit_location, exit_location,
171 flags_, 0); 118 flags_, 0);
172 Dispatch(&mouseev); 119 Dispatch(&mouseev);
173 } 120 }
174 121
175 void EventGenerator::MoveMouseToInHost(const gfx::Point& point_in_host) { 122 void EventGenerator::MoveMouseToInHost(const gfx::Point& point_in_host) {
176 const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ? 123 const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ?
177 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED; 124 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED;
178 ui::MouseEvent mouseev(event_type, point_in_host, point_in_host, flags_, 0); 125 ui::MouseEvent mouseev(event_type, point_in_host, point_in_host, flags_, 0);
179 Dispatch(&mouseev); 126 Dispatch(&mouseev);
180 127
181 current_location_ = point_in_host; 128 current_location_ = point_in_host;
182 current_host_->ConvertPointFromHost(&current_location_); 129 delegate_->ConvertPointFromHost(current_target_, &current_location_);
183 } 130 }
184 131
185 void EventGenerator::MoveMouseTo(const gfx::Point& point_in_screen, 132 void EventGenerator::MoveMouseTo(const gfx::Point& point_in_screen,
186 int count) { 133 int count) {
187 DCHECK_GT(count, 0); 134 DCHECK_GT(count, 0);
188 const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ? 135 const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ?
189 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED; 136 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED;
190 137
191 gfx::Vector2dF diff(point_in_screen - current_location_); 138 gfx::Vector2dF diff(point_in_screen - current_location_);
192 for (float i = 1; i <= count; i++) { 139 for (float i = 1; i <= count; i++) {
193 gfx::Vector2dF step(diff); 140 gfx::Vector2dF step(diff);
194 step.Scale(i / count); 141 step.Scale(i / count);
195 gfx::Point move_point = current_location_ + gfx::ToRoundedVector2d(step); 142 gfx::Point move_point = current_location_ + gfx::ToRoundedVector2d(step);
196 if (!grab_) 143 if (!grab_)
197 UpdateCurrentDispatcher(move_point); 144 UpdateCurrentDispatcher(move_point);
198 ConvertPointToTarget(current_host_->window(), &move_point); 145 delegate_->ConvertPointToTarget(current_target_, &move_point);
199 ui::MouseEvent mouseev(event_type, move_point, move_point, flags_, 0); 146 ui::MouseEvent mouseev(event_type, move_point, move_point, flags_, 0);
200 Dispatch(&mouseev); 147 Dispatch(&mouseev);
201 } 148 }
202 current_location_ = point_in_screen; 149 current_location_ = point_in_screen;
203 } 150 }
204 151
205 void EventGenerator::MoveMouseRelativeTo(const Window* window, 152 void EventGenerator::MoveMouseRelativeTo(const EventTarget* window,
206 const gfx::Point& point_in_parent) { 153 const gfx::Point& point_in_parent) {
207 gfx::Point point(point_in_parent); 154 gfx::Point point(point_in_parent);
208 ConvertPointFromTarget(window, &point); 155 delegate_->ConvertPointFromTarget(window, &point);
209 MoveMouseTo(point); 156 MoveMouseTo(point);
210 } 157 }
211 158
212 void EventGenerator::DragMouseTo(const gfx::Point& point) { 159 void EventGenerator::DragMouseTo(const gfx::Point& point) {
213 PressLeftButton(); 160 PressLeftButton();
214 MoveMouseTo(point); 161 MoveMouseTo(point);
215 ReleaseLeftButton(); 162 ReleaseLeftButton();
216 } 163 }
217 164
218 void EventGenerator::MoveMouseToCenterOf(Window* window) { 165 void EventGenerator::MoveMouseToCenterOf(EventTarget* window) {
219 MoveMouseTo(CenterOfWindow(window)); 166 MoveMouseTo(CenterOfWindow(window));
220 } 167 }
221 168
222 void EventGenerator::PressTouch() { 169 void EventGenerator::PressTouch() {
223 PressTouchId(0); 170 PressTouchId(0);
224 } 171 }
225 172
226 void EventGenerator::PressTouchId(int touch_id) { 173 void EventGenerator::PressTouchId(int touch_id) {
227 TestTouchEvent touchev( 174 TestTouchEvent touchev(
228 ui::ET_TOUCH_PRESSED, GetLocationInCurrentRoot(), touch_id, flags_, 175 ui::ET_TOUCH_PRESSED, GetLocationInCurrentRoot(), touch_id, flags_,
(...skipping 26 matching lines...) Expand all
255 Now()); 202 Now());
256 Dispatch(&touchev); 203 Dispatch(&touchev);
257 } 204 }
258 205
259 void EventGenerator::PressMoveAndReleaseTouchTo(const gfx::Point& point) { 206 void EventGenerator::PressMoveAndReleaseTouchTo(const gfx::Point& point) {
260 PressTouch(); 207 PressTouch();
261 MoveTouch(point); 208 MoveTouch(point);
262 ReleaseTouch(); 209 ReleaseTouch();
263 } 210 }
264 211
265 void EventGenerator::PressMoveAndReleaseTouchToCenterOf(Window* window) { 212 void EventGenerator::PressMoveAndReleaseTouchToCenterOf(EventTarget* window) {
266 PressMoveAndReleaseTouchTo(CenterOfWindow(window)); 213 PressMoveAndReleaseTouchTo(CenterOfWindow(window));
267 } 214 }
268 215
269 void EventGenerator::GestureEdgeSwipe() { 216 void EventGenerator::GestureEdgeSwipe() {
270 ui::GestureEvent gesture( 217 ui::GestureEvent gesture(
271 ui::ET_GESTURE_WIN8_EDGE_SWIPE, 218 ui::ET_GESTURE_WIN8_EDGE_SWIPE,
272 0, 219 0,
273 0, 220 0,
274 0, 221 0,
275 Now(), 222 Now(),
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 x_offset, y_offset, 404 x_offset, y_offset,
458 x_offset, y_offset, 405 x_offset, y_offset,
459 num_fingers); 406 num_fingers);
460 Dispatch(&fling_start); 407 Dispatch(&fling_start);
461 } 408 }
462 409
463 void EventGenerator::ScrollSequence(const gfx::Point& start, 410 void EventGenerator::ScrollSequence(const gfx::Point& start,
464 const base::TimeDelta& step_delay, 411 const base::TimeDelta& step_delay,
465 const std::vector<gfx::Point>& offsets, 412 const std::vector<gfx::Point>& offsets,
466 int num_fingers) { 413 int num_fingers) {
467 int steps = offsets.size(); 414 size_t steps = offsets.size();
468 base::TimeDelta timestamp = Now(); 415 base::TimeDelta timestamp = Now();
469 ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, 416 ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL,
470 start, 417 start,
471 timestamp, 418 timestamp,
472 0, 419 0,
473 0, 0, 420 0, 0,
474 0, 0, 421 0, 0,
475 num_fingers); 422 num_fingers);
476 Dispatch(&fling_cancel); 423 Dispatch(&fling_cancel);
477 424
478 for (int i = 0; i < steps; ++i) { 425 for (size_t i = 0; i < steps; ++i) {
479 timestamp += step_delay; 426 timestamp += step_delay;
480 ui::ScrollEvent scroll(ui::ET_SCROLL, 427 ui::ScrollEvent scroll(ui::ET_SCROLL,
481 start, 428 start,
482 timestamp, 429 timestamp,
483 0, 430 0,
484 offsets[i].x(), offsets[i].y(), 431 offsets[i].x(), offsets[i].y(),
485 offsets[i].x(), offsets[i].y(), 432 offsets[i].x(), offsets[i].y(),
486 num_fingers); 433 num_fingers);
487 Dispatch(&scroll); 434 Dispatch(&scroll);
488 } 435 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 flags); 492 flags);
546 ui::KeyEvent keyev(xevent, false); 493 ui::KeyEvent keyev(xevent, false);
547 #else 494 #else
548 ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED; 495 ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED;
549 ui::KeyEvent keyev(type, key_code, flags, false); 496 ui::KeyEvent keyev(type, key_code, flags, false);
550 #endif // OS_WIN 497 #endif // OS_WIN
551 Dispatch(&keyev); 498 Dispatch(&keyev);
552 } 499 }
553 500
554 void EventGenerator::UpdateCurrentDispatcher(const gfx::Point& point) { 501 void EventGenerator::UpdateCurrentDispatcher(const gfx::Point& point) {
555 current_host_ = delegate_->GetHostAt(point); 502 current_target_ = delegate_->GetTargetAt(point);
556 } 503 }
557 504
558 void EventGenerator::PressButton(int flag) { 505 void EventGenerator::PressButton(int flag) {
559 if (!(flags_ & flag)) { 506 if (!(flags_ & flag)) {
560 flags_ |= flag; 507 flags_ |= flag;
561 grab_ = flags_ & kAllButtonMask; 508 grab_ = (flags_ & kAllButtonMask) != 0;
562 gfx::Point location = GetLocationInCurrentRoot(); 509 gfx::Point location = GetLocationInCurrentRoot();
563 ui::MouseEvent mouseev(ui::ET_MOUSE_PRESSED, location, location, flags_, 510 ui::MouseEvent mouseev(ui::ET_MOUSE_PRESSED, location, location, flags_,
564 flag); 511 flag);
565 Dispatch(&mouseev); 512 Dispatch(&mouseev);
566 } 513 }
567 } 514 }
568 515
569 void EventGenerator::ReleaseButton(int flag) { 516 void EventGenerator::ReleaseButton(int flag) {
570 if (flags_ & flag) { 517 if (flags_ & flag) {
571 gfx::Point location = GetLocationInCurrentRoot(); 518 gfx::Point location = GetLocationInCurrentRoot();
572 ui::MouseEvent mouseev(ui::ET_MOUSE_RELEASED, location, 519 ui::MouseEvent mouseev(ui::ET_MOUSE_RELEASED, location,
573 location, flags_, flag); 520 location, flags_, flag);
574 Dispatch(&mouseev); 521 Dispatch(&mouseev);
575 flags_ ^= flag; 522 flags_ ^= flag;
576 } 523 }
577 grab_ = flags_ & kAllButtonMask; 524 grab_ = (flags_ & kAllButtonMask) != 0;
578 }
579
580 void EventGenerator::ConvertPointFromTarget(const aura::Window* target,
581 gfx::Point* point) const {
582 DCHECK(point);
583 aura::client::ScreenPositionClient* client =
584 delegate_->GetScreenPositionClient(target);
585 if (client)
586 client->ConvertPointToScreen(target, point);
587 else
588 aura::Window::ConvertPointToTarget(target, target->GetRootWindow(), point);
589 }
590
591 void EventGenerator::ConvertPointToTarget(const aura::Window* target,
592 gfx::Point* point) const {
593 DCHECK(point);
594 aura::client::ScreenPositionClient* client =
595 delegate_->GetScreenPositionClient(target);
596 if (client)
597 client->ConvertPointFromScreen(target, point);
598 else
599 aura::Window::ConvertPointToTarget(target->GetRootWindow(), target, point);
600 } 525 }
601 526
602 gfx::Point EventGenerator::GetLocationInCurrentRoot() const { 527 gfx::Point EventGenerator::GetLocationInCurrentRoot() const {
603 gfx::Point p(current_location_); 528 gfx::Point p(current_location_);
604 ConvertPointToTarget(current_host_->window(), &p); 529 delegate_->ConvertPointToTarget(current_target_, &p);
605 return p; 530 return p;
606 } 531 }
607 532
608 gfx::Point EventGenerator::CenterOfWindow(const Window* window) const { 533 gfx::Point EventGenerator::CenterOfWindow(const EventTarget* window) const {
609 gfx::Point center = gfx::Rect(window->bounds().size()).CenterPoint(); 534 return delegate_->CenterOfTarget(window);
610 ConvertPointFromTarget(window, &center);
611 return center;
612 } 535 }
613 536
614 void EventGenerator::DoDispatchEvent(ui::Event* event, bool async) { 537 void EventGenerator::DoDispatchEvent(ui::Event* event, bool async) {
615 if (async) { 538 if (async) {
616 ui::Event* pending_event; 539 ui::Event* pending_event;
617 if (event->IsKeyEvent()) { 540 if (event->IsKeyEvent()) {
618 pending_event = new ui::KeyEvent(*static_cast<ui::KeyEvent*>(event)); 541 pending_event = new ui::KeyEvent(*static_cast<ui::KeyEvent*>(event));
619 } else if (event->IsMouseEvent()) { 542 } else if (event->IsMouseEvent()) {
620 pending_event = new ui::MouseEvent(*static_cast<ui::MouseEvent*>(event)); 543 pending_event = new ui::MouseEvent(*static_cast<ui::MouseEvent*>(event));
621 } else if (event->IsTouchEvent()) { 544 } else if (event->IsTouchEvent()) {
622 pending_event = new ui::TouchEvent(*static_cast<ui::TouchEvent*>(event)); 545 pending_event = new ui::TouchEvent(*static_cast<ui::TouchEvent*>(event));
623 } else if (event->IsScrollEvent()) { 546 } else if (event->IsScrollEvent()) {
624 pending_event = 547 pending_event =
625 new ui::ScrollEvent(*static_cast<ui::ScrollEvent*>(event)); 548 new ui::ScrollEvent(*static_cast<ui::ScrollEvent*>(event));
626 } else { 549 } else {
627 NOTREACHED() << "Invalid event type"; 550 NOTREACHED() << "Invalid event type";
628 return; 551 return;
629 } 552 }
630 if (pending_events_.empty()) { 553 if (pending_events_.empty()) {
631 base::MessageLoopProxy::current()->PostTask( 554 base::MessageLoopProxy::current()->PostTask(
632 FROM_HERE, 555 FROM_HERE,
633 base::Bind(&EventGenerator::DispatchNextPendingEvent, 556 base::Bind(&EventGenerator::DispatchNextPendingEvent,
634 base::Unretained(this))); 557 base::Unretained(this)));
635 } 558 }
636 pending_events_.push_back(pending_event); 559 pending_events_.push_back(pending_event);
637 } else { 560 } else {
638 ui::EventSource* event_source = current_host_->GetEventSource(); 561 ui::EventSource* event_source = delegate_->GetEventSource(current_target_);
639 ui::EventSourceTestApi event_source_test(event_source); 562 ui::EventSourceTestApi event_source_test(event_source);
640 ui::EventDispatchDetails details = 563 ui::EventDispatchDetails details =
641 event_source_test.SendEventToProcessor(event); 564 event_source_test.SendEventToProcessor(event);
642 CHECK(!details.dispatcher_destroyed); 565 CHECK(!details.dispatcher_destroyed);
643 } 566 }
644 } 567 }
645 568
646 void EventGenerator::DispatchNextPendingEvent() { 569 void EventGenerator::DispatchNextPendingEvent() {
647 DCHECK(!pending_events_.empty()); 570 DCHECK(!pending_events_.empty());
648 ui::Event* event = pending_events_.front(); 571 ui::Event* event = pending_events_.front();
649 DoDispatchEvent(event, false); 572 DoDispatchEvent(event, false);
650 pending_events_.pop_front(); 573 pending_events_.pop_front();
651 delete event; 574 delete event;
652 if (!pending_events_.empty()) { 575 if (!pending_events_.empty()) {
653 base::MessageLoopProxy::current()->PostTask( 576 base::MessageLoopProxy::current()->PostTask(
654 FROM_HERE, 577 FROM_HERE,
655 base::Bind(&EventGenerator::DispatchNextPendingEvent, 578 base::Bind(&EventGenerator::DispatchNextPendingEvent,
656 base::Unretained(this))); 579 base::Unretained(this)));
657 } 580 }
658 } 581 }
659 582
660 } // namespace test 583 } // namespace test
661 } // namespace aura 584 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698