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

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: self review + related fix for r283070 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 0, 218 0,
272 0, 219 0,
273 0, 220 0,
274 Now(), 221 Now(),
275 ui::GestureEventDetails(ui::ET_GESTURE_WIN8_EDGE_SWIPE, 0, 0)); 222 ui::GestureEventDetails(ui::ET_GESTURE_WIN8_EDGE_SWIPE, 0, 0));
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 x_offset, y_offset, 402 x_offset, y_offset,
456 x_offset, y_offset, 403 x_offset, y_offset,
457 num_fingers); 404 num_fingers);
458 Dispatch(&fling_start); 405 Dispatch(&fling_start);
459 } 406 }
460 407
461 void EventGenerator::ScrollSequence(const gfx::Point& start, 408 void EventGenerator::ScrollSequence(const gfx::Point& start,
462 const base::TimeDelta& step_delay, 409 const base::TimeDelta& step_delay,
463 const std::vector<gfx::Point>& offsets, 410 const std::vector<gfx::Point>& offsets,
464 int num_fingers) { 411 int num_fingers) {
465 int steps = offsets.size(); 412 size_t steps = offsets.size();
466 base::TimeDelta timestamp = Now(); 413 base::TimeDelta timestamp = Now();
467 ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, 414 ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL,
468 start, 415 start,
469 timestamp, 416 timestamp,
470 0, 417 0,
471 0, 0, 418 0, 0,
472 0, 0, 419 0, 0,
473 num_fingers); 420 num_fingers);
474 Dispatch(&fling_cancel); 421 Dispatch(&fling_cancel);
475 422
476 for (int i = 0; i < steps; ++i) { 423 for (size_t i = 0; i < steps; ++i) {
477 timestamp += step_delay; 424 timestamp += step_delay;
478 ui::ScrollEvent scroll(ui::ET_SCROLL, 425 ui::ScrollEvent scroll(ui::ET_SCROLL,
479 start, 426 start,
480 timestamp, 427 timestamp,
481 0, 428 0,
482 offsets[i].x(), offsets[i].y(), 429 offsets[i].x(), offsets[i].y(),
483 offsets[i].x(), offsets[i].y(), 430 offsets[i].x(), offsets[i].y(),
484 num_fingers); 431 num_fingers);
485 Dispatch(&scroll); 432 Dispatch(&scroll);
486 } 433 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 flags); 490 flags);
544 ui::KeyEvent keyev(xevent, false); 491 ui::KeyEvent keyev(xevent, false);
545 #else 492 #else
546 ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED; 493 ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED;
547 ui::KeyEvent keyev(type, key_code, flags, false); 494 ui::KeyEvent keyev(type, key_code, flags, false);
548 #endif // OS_WIN 495 #endif // OS_WIN
549 Dispatch(&keyev); 496 Dispatch(&keyev);
550 } 497 }
551 498
552 void EventGenerator::UpdateCurrentDispatcher(const gfx::Point& point) { 499 void EventGenerator::UpdateCurrentDispatcher(const gfx::Point& point) {
553 current_host_ = delegate_->GetHostAt(point); 500 current_target_ = delegate_->GetTargetAt(point);
554 } 501 }
555 502
556 void EventGenerator::PressButton(int flag) { 503 void EventGenerator::PressButton(int flag) {
557 if (!(flags_ & flag)) { 504 if (!(flags_ & flag)) {
558 flags_ |= flag; 505 flags_ |= flag;
559 grab_ = flags_ & kAllButtonMask; 506 grab_ = (flags_ & kAllButtonMask) != 0;
560 gfx::Point location = GetLocationInCurrentRoot(); 507 gfx::Point location = GetLocationInCurrentRoot();
561 ui::MouseEvent mouseev(ui::ET_MOUSE_PRESSED, location, location, flags_, 508 ui::MouseEvent mouseev(ui::ET_MOUSE_PRESSED, location, location, flags_,
562 flag); 509 flag);
563 Dispatch(&mouseev); 510 Dispatch(&mouseev);
564 } 511 }
565 } 512 }
566 513
567 void EventGenerator::ReleaseButton(int flag) { 514 void EventGenerator::ReleaseButton(int flag) {
568 if (flags_ & flag) { 515 if (flags_ & flag) {
569 gfx::Point location = GetLocationInCurrentRoot(); 516 gfx::Point location = GetLocationInCurrentRoot();
570 ui::MouseEvent mouseev(ui::ET_MOUSE_RELEASED, location, 517 ui::MouseEvent mouseev(ui::ET_MOUSE_RELEASED, location,
571 location, flags_, flag); 518 location, flags_, flag);
572 Dispatch(&mouseev); 519 Dispatch(&mouseev);
573 flags_ ^= flag; 520 flags_ ^= flag;
574 } 521 }
575 grab_ = flags_ & kAllButtonMask; 522 grab_ = (flags_ & kAllButtonMask) != 0;
576 }
577
578 void EventGenerator::ConvertPointFromTarget(const aura::Window* target,
579 gfx::Point* point) const {
580 DCHECK(point);
581 aura::client::ScreenPositionClient* client =
582 delegate_->GetScreenPositionClient(target);
583 if (client)
584 client->ConvertPointToScreen(target, point);
585 else
586 aura::Window::ConvertPointToTarget(target, target->GetRootWindow(), point);
587 }
588
589 void EventGenerator::ConvertPointToTarget(const aura::Window* target,
590 gfx::Point* point) const {
591 DCHECK(point);
592 aura::client::ScreenPositionClient* client =
593 delegate_->GetScreenPositionClient(target);
594 if (client)
595 client->ConvertPointFromScreen(target, point);
596 else
597 aura::Window::ConvertPointToTarget(target->GetRootWindow(), target, point);
598 } 523 }
599 524
600 gfx::Point EventGenerator::GetLocationInCurrentRoot() const { 525 gfx::Point EventGenerator::GetLocationInCurrentRoot() const {
601 gfx::Point p(current_location_); 526 gfx::Point p(current_location_);
602 ConvertPointToTarget(current_host_->window(), &p); 527 delegate_->ConvertPointToTarget(current_target_, &p);
603 return p; 528 return p;
604 } 529 }
605 530
606 gfx::Point EventGenerator::CenterOfWindow(const Window* window) const { 531 gfx::Point EventGenerator::CenterOfWindow(const EventTarget* window) const {
607 gfx::Point center = gfx::Rect(window->bounds().size()).CenterPoint(); 532 return delegate_->CenterOfTarget(window);
608 ConvertPointFromTarget(window, &center);
609 return center;
610 } 533 }
611 534
612 void EventGenerator::DoDispatchEvent(ui::Event* event, bool async) { 535 void EventGenerator::DoDispatchEvent(ui::Event* event, bool async) {
613 if (async) { 536 if (async) {
614 ui::Event* pending_event; 537 ui::Event* pending_event;
615 if (event->IsKeyEvent()) { 538 if (event->IsKeyEvent()) {
616 pending_event = new ui::KeyEvent(*static_cast<ui::KeyEvent*>(event)); 539 pending_event = new ui::KeyEvent(*static_cast<ui::KeyEvent*>(event));
617 } else if (event->IsMouseEvent()) { 540 } else if (event->IsMouseEvent()) {
618 pending_event = new ui::MouseEvent(*static_cast<ui::MouseEvent*>(event)); 541 pending_event = new ui::MouseEvent(*static_cast<ui::MouseEvent*>(event));
619 } else if (event->IsTouchEvent()) { 542 } else if (event->IsTouchEvent()) {
620 pending_event = new ui::TouchEvent(*static_cast<ui::TouchEvent*>(event)); 543 pending_event = new ui::TouchEvent(*static_cast<ui::TouchEvent*>(event));
621 } else if (event->IsScrollEvent()) { 544 } else if (event->IsScrollEvent()) {
622 pending_event = 545 pending_event =
623 new ui::ScrollEvent(*static_cast<ui::ScrollEvent*>(event)); 546 new ui::ScrollEvent(*static_cast<ui::ScrollEvent*>(event));
624 } else { 547 } else {
625 NOTREACHED() << "Invalid event type"; 548 NOTREACHED() << "Invalid event type";
626 return; 549 return;
627 } 550 }
628 if (pending_events_.empty()) { 551 if (pending_events_.empty()) {
629 base::MessageLoopProxy::current()->PostTask( 552 base::MessageLoopProxy::current()->PostTask(
630 FROM_HERE, 553 FROM_HERE,
631 base::Bind(&EventGenerator::DispatchNextPendingEvent, 554 base::Bind(&EventGenerator::DispatchNextPendingEvent,
632 base::Unretained(this))); 555 base::Unretained(this)));
633 } 556 }
634 pending_events_.push_back(pending_event); 557 pending_events_.push_back(pending_event);
635 } else { 558 } else {
636 ui::EventSource* event_source = current_host_->GetEventSource(); 559 ui::EventSource* event_source = delegate_->GetEventSource(current_target_);
637 ui::EventSourceTestApi event_source_test(event_source); 560 ui::EventSourceTestApi event_source_test(event_source);
638 ui::EventDispatchDetails details = 561 ui::EventDispatchDetails details =
639 event_source_test.SendEventToProcessor(event); 562 event_source_test.SendEventToProcessor(event);
640 CHECK(!details.dispatcher_destroyed); 563 CHECK(!details.dispatcher_destroyed);
641 } 564 }
642 } 565 }
643 566
644 void EventGenerator::DispatchNextPendingEvent() { 567 void EventGenerator::DispatchNextPendingEvent() {
645 DCHECK(!pending_events_.empty()); 568 DCHECK(!pending_events_.empty());
646 ui::Event* event = pending_events_.front(); 569 ui::Event* event = pending_events_.front();
647 DoDispatchEvent(event, false); 570 DoDispatchEvent(event, false);
648 pending_events_.pop_front(); 571 pending_events_.pop_front();
649 delete event; 572 delete event;
650 if (!pending_events_.empty()) { 573 if (!pending_events_.empty()) {
651 base::MessageLoopProxy::current()->PostTask( 574 base::MessageLoopProxy::current()->PostTask(
652 FROM_HERE, 575 FROM_HERE,
653 base::Bind(&EventGenerator::DispatchNextPendingEvent, 576 base::Bind(&EventGenerator::DispatchNextPendingEvent,
654 base::Unretained(this))); 577 base::Unretained(this)));
655 } 578 }
656 } 579 }
657 580
658 } // namespace test 581 } // namespace test
659 } // namespace aura 582 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698