OLD | NEW |
1 // Copyright 2014 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/events/test/event_generator.h" | 5 #include "ui/events/test/event_generator.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/location.h" | 10 #include "base/location.h" |
9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
10 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
11 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
12 #include "base/time/tick_clock.h" | 14 #include "base/time/tick_clock.h" |
13 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
14 #include "ui/events/event_source.h" | 16 #include "ui/events/event_source.h" |
15 #include "ui/events/event_utils.h" | 17 #include "ui/events/event_utils.h" |
16 #include "ui/events/test/events_test_utils.h" | 18 #include "ui/events/test/events_test_utils.h" |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 | 548 |
547 void EventGenerator::ReleaseKey(ui::KeyboardCode key_code, int flags) { | 549 void EventGenerator::ReleaseKey(ui::KeyboardCode key_code, int flags) { |
548 DispatchKeyEvent(false, key_code, flags); | 550 DispatchKeyEvent(false, key_code, flags); |
549 } | 551 } |
550 | 552 |
551 void EventGenerator::Dispatch(ui::Event* event) { | 553 void EventGenerator::Dispatch(ui::Event* event) { |
552 DoDispatchEvent(event, async_); | 554 DoDispatchEvent(event, async_); |
553 } | 555 } |
554 | 556 |
555 void EventGenerator::SetTickClock(scoped_ptr<base::TickClock> tick_clock) { | 557 void EventGenerator::SetTickClock(scoped_ptr<base::TickClock> tick_clock) { |
556 tick_clock_ = tick_clock.Pass(); | 558 tick_clock_ = std::move(tick_clock); |
557 } | 559 } |
558 | 560 |
559 base::TimeDelta EventGenerator::Now() { | 561 base::TimeDelta EventGenerator::Now() { |
560 // This is the same as what EventTimeForNow() does, but here we do it | 562 // This is the same as what EventTimeForNow() does, but here we do it |
561 // with a tick clock that can be replaced with a simulated clock for tests. | 563 // with a tick clock that can be replaced with a simulated clock for tests. |
562 return base::TimeDelta::FromInternalValue( | 564 return base::TimeDelta::FromInternalValue( |
563 tick_clock_->NowTicks().ToInternalValue()); | 565 tick_clock_->NowTicks().ToInternalValue()); |
564 } | 566 } |
565 | 567 |
566 void EventGenerator::Init(gfx::NativeWindow root_window, | 568 void EventGenerator::Init(gfx::NativeWindow root_window, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 return default_delegate; | 704 return default_delegate; |
703 } | 705 } |
704 | 706 |
705 EventGeneratorDelegate* EventGenerator::delegate() { | 707 EventGeneratorDelegate* EventGenerator::delegate() { |
706 return const_cast<EventGeneratorDelegate*>( | 708 return const_cast<EventGeneratorDelegate*>( |
707 const_cast<const EventGenerator*>(this)->delegate()); | 709 const_cast<const EventGenerator*>(this)->delegate()); |
708 } | 710 } |
709 | 711 |
710 } // namespace test | 712 } // namespace test |
711 } // namespace ui | 713 } // namespace ui |
OLD | NEW |