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/test/event_generator.h" | 5 #include "ui/aura/test/event_generator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "ui/aura/client/screen_position_client.h" | 10 #include "ui/aura/client/screen_position_client.h" |
11 #include "ui/aura/window_event_dispatcher.h" | 11 #include "ui/aura/window_event_dispatcher.h" |
12 #include "ui/aura/window_tree_host.h" | 12 #include "ui/aura/window_tree_host.h" |
13 #include "ui/events/event.h" | 13 #include "ui/events/event.h" |
| 14 #include "ui/events/event_source.h" |
14 #include "ui/events/event_utils.h" | 15 #include "ui/events/event_utils.h" |
| 16 #include "ui/events/test/events_test_utils.h" |
15 #include "ui/gfx/vector2d_conversions.h" | 17 #include "ui/gfx/vector2d_conversions.h" |
16 | 18 |
17 #if defined(USE_X11) | 19 #if defined(USE_X11) |
18 #include <X11/Xlib.h> | 20 #include <X11/Xlib.h> |
19 #include "ui/base/x/x11_util.h" | 21 #include "ui/base/x/x11_util.h" |
20 #include "ui/events/event_utils.h" | 22 #include "ui/events/event_utils.h" |
21 #include "ui/events/test/events_test_utils_x11.h" | 23 #include "ui/events/test/events_test_utils_x11.h" |
22 #endif | 24 #endif |
23 | 25 |
24 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 void EventGenerator::MoveTouchId(const gfx::Point& point, int touch_id) { | 223 void EventGenerator::MoveTouchId(const gfx::Point& point, int touch_id) { |
222 current_location_ = point; | 224 current_location_ = point; |
223 TestTouchEvent touchev( | 225 TestTouchEvent touchev( |
224 ui::ET_TOUCH_MOVED, GetLocationInCurrentRoot(), touch_id, flags_); | 226 ui::ET_TOUCH_MOVED, GetLocationInCurrentRoot(), touch_id, flags_); |
225 Dispatch(&touchev); | 227 Dispatch(&touchev); |
226 | 228 |
227 if (!grab_) | 229 if (!grab_) |
228 UpdateCurrentDispatcher(point); | 230 UpdateCurrentDispatcher(point); |
229 } | 231 } |
230 | 232 |
| 233 void EventGenerator::StationaryTouch() { |
| 234 StationaryTouchId(0); |
| 235 } |
| 236 |
| 237 void EventGenerator::StationaryTouchId(int touch_id) { |
| 238 TestTouchEvent touchev( |
| 239 ui::ET_TOUCH_STATIONARY, GetLocationInCurrentRoot(), touch_id, flags_); |
| 240 Dispatch(&touchev); |
| 241 } |
| 242 |
231 void EventGenerator::ReleaseTouch() { | 243 void EventGenerator::ReleaseTouch() { |
232 ReleaseTouchId(0); | 244 ReleaseTouchId(0); |
233 } | 245 } |
234 | 246 |
235 void EventGenerator::ReleaseTouchId(int touch_id) { | 247 void EventGenerator::ReleaseTouchId(int touch_id) { |
236 TestTouchEvent touchev( | 248 TestTouchEvent touchev( |
237 ui::ET_TOUCH_RELEASED, GetLocationInCurrentRoot(), touch_id, flags_); | 249 ui::ET_TOUCH_RELEASED, GetLocationInCurrentRoot(), touch_id, flags_); |
238 Dispatch(&touchev); | 250 Dispatch(&touchev); |
239 } | 251 } |
240 | 252 |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 return; | 612 return; |
601 } | 613 } |
602 if (pending_events_.empty()) { | 614 if (pending_events_.empty()) { |
603 base::MessageLoopProxy::current()->PostTask( | 615 base::MessageLoopProxy::current()->PostTask( |
604 FROM_HERE, | 616 FROM_HERE, |
605 base::Bind(&EventGenerator::DispatchNextPendingEvent, | 617 base::Bind(&EventGenerator::DispatchNextPendingEvent, |
606 base::Unretained(this))); | 618 base::Unretained(this))); |
607 } | 619 } |
608 pending_events_.push_back(pending_event); | 620 pending_events_.push_back(pending_event); |
609 } else { | 621 } else { |
| 622 ui::EventSource* event_source = current_host_->GetEventSource(); |
| 623 ui::EventSourceTestApi event_source_test(event_source); |
610 ui::EventDispatchDetails details = | 624 ui::EventDispatchDetails details = |
611 current_host_->event_processor()->OnEventFromSource(event); | 625 event_source_test.SendEventToProcessor(event); |
612 CHECK(!details.dispatcher_destroyed); | 626 CHECK(!details.dispatcher_destroyed); |
613 } | 627 } |
614 } | 628 } |
615 | 629 |
616 void EventGenerator::DispatchNextPendingEvent() { | 630 void EventGenerator::DispatchNextPendingEvent() { |
617 DCHECK(!pending_events_.empty()); | 631 DCHECK(!pending_events_.empty()); |
618 ui::Event* event = pending_events_.front(); | 632 ui::Event* event = pending_events_.front(); |
619 DoDispatchEvent(event, false); | 633 DoDispatchEvent(event, false); |
620 pending_events_.pop_front(); | 634 pending_events_.pop_front(); |
621 delete event; | 635 delete event; |
622 if (!pending_events_.empty()) { | 636 if (!pending_events_.empty()) { |
623 base::MessageLoopProxy::current()->PostTask( | 637 base::MessageLoopProxy::current()->PostTask( |
624 FROM_HERE, | 638 FROM_HERE, |
625 base::Bind(&EventGenerator::DispatchNextPendingEvent, | 639 base::Bind(&EventGenerator::DispatchNextPendingEvent, |
626 base::Unretained(this))); | 640 base::Unretained(this))); |
627 } | 641 } |
628 } | 642 } |
629 | 643 |
630 | 644 |
631 } // namespace test | 645 } // namespace test |
632 } // namespace aura | 646 } // namespace aura |
OLD | NEW |