| 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" |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 return; | 580 return; |
| 581 } | 581 } |
| 582 if (pending_events_.empty()) { | 582 if (pending_events_.empty()) { |
| 583 base::MessageLoopProxy::current()->PostTask( | 583 base::MessageLoopProxy::current()->PostTask( |
| 584 FROM_HERE, | 584 FROM_HERE, |
| 585 base::Bind(&EventGenerator::DispatchNextPendingEvent, | 585 base::Bind(&EventGenerator::DispatchNextPendingEvent, |
| 586 base::Unretained(this))); | 586 base::Unretained(this))); |
| 587 } | 587 } |
| 588 pending_events_.push_back(pending_event); | 588 pending_events_.push_back(pending_event); |
| 589 } else { | 589 } else { |
| 590 WindowTreeHostDelegate* root_window_host_delegate = | 590 ui::EventDispatchDetails details = current_root_window_->OnEventFromSource( |
| 591 current_root_window_->AsWindowTreeHostDelegate(); | 591 static_cast<ui::KeyEvent*>(event)); |
| 592 if (event->IsKeyEvent()) { | 592 CHECK(!details.dispatcher_destroyed); |
| 593 root_window_host_delegate->OnHostKeyEvent( | |
| 594 static_cast<ui::KeyEvent*>(event)); | |
| 595 } else if (event->IsMouseEvent()) { | |
| 596 root_window_host_delegate->OnHostMouseEvent( | |
| 597 static_cast<ui::MouseEvent*>(event)); | |
| 598 } else if (event->IsTouchEvent()) { | |
| 599 root_window_host_delegate->OnHostTouchEvent( | |
| 600 static_cast<ui::TouchEvent*>(event)); | |
| 601 } else if (event->IsScrollEvent()) { | |
| 602 root_window_host_delegate->OnHostScrollEvent( | |
| 603 static_cast<ui::ScrollEvent*>(event)); | |
| 604 } else { | |
| 605 NOTREACHED() << "Invalid event type"; | |
| 606 } | |
| 607 } | 593 } |
| 608 } | 594 } |
| 609 | 595 |
| 610 void EventGenerator::DispatchNextPendingEvent() { | 596 void EventGenerator::DispatchNextPendingEvent() { |
| 611 DCHECK(!pending_events_.empty()); | 597 DCHECK(!pending_events_.empty()); |
| 612 ui::Event* event = pending_events_.front(); | 598 ui::Event* event = pending_events_.front(); |
| 613 DoDispatchEvent(event, false); | 599 DoDispatchEvent(event, false); |
| 614 pending_events_.pop_front(); | 600 pending_events_.pop_front(); |
| 615 delete event; | 601 delete event; |
| 616 if (!pending_events_.empty()) { | 602 if (!pending_events_.empty()) { |
| 617 base::MessageLoopProxy::current()->PostTask( | 603 base::MessageLoopProxy::current()->PostTask( |
| 618 FROM_HERE, | 604 FROM_HERE, |
| 619 base::Bind(&EventGenerator::DispatchNextPendingEvent, | 605 base::Bind(&EventGenerator::DispatchNextPendingEvent, |
| 620 base::Unretained(this))); | 606 base::Unretained(this))); |
| 621 } | 607 } |
| 622 } | 608 } |
| 623 | 609 |
| 624 | 610 |
| 625 } // namespace test | 611 } // namespace test |
| 626 } // namespace aura | 612 } // namespace aura |
| OLD | NEW |