| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test_event_processor.h" | 5 #include "ui/events/test/test_event_processor.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ui/events/event_target.h" | 9 #include "ui/events/event_target.h" |
| 10 | 10 |
| 11 namespace ui { | 11 namespace ui { |
| 12 namespace test { | 12 namespace test { |
| 13 | 13 |
| 14 TestEventProcessor::TestEventProcessor() | 14 TestEventProcessor::TestEventProcessor() |
| 15 : should_processing_occur_(true), | 15 : should_processing_occur_(true), |
| 16 num_times_processing_started_(0), | 16 num_times_processing_started_(0), |
| 17 num_times_processing_finished_(0) { | 17 num_times_processing_finished_(0) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 TestEventProcessor::~TestEventProcessor() {} | 20 TestEventProcessor::~TestEventProcessor() {} |
| 21 | 21 |
| 22 EventTarget* TestEventProcessor::GetRoot() { |
| 23 return root_.get(); |
| 24 } |
| 25 |
| 22 void TestEventProcessor::SetRoot(std::unique_ptr<EventTarget> root) { | 26 void TestEventProcessor::SetRoot(std::unique_ptr<EventTarget> root) { |
| 23 root_ = std::move(root); | 27 root_ = std::move(root); |
| 24 } | 28 } |
| 25 | 29 |
| 26 void TestEventProcessor::Reset() { | 30 void TestEventProcessor::Reset() { |
| 27 should_processing_occur_ = true; | 31 should_processing_occur_ = true; |
| 28 num_times_processing_started_ = 0; | 32 num_times_processing_started_ = 0; |
| 29 num_times_processing_finished_ = 0; | 33 num_times_processing_finished_ = 0; |
| 30 } | 34 } |
| 31 | 35 |
| 32 bool TestEventProcessor::CanDispatchToTarget(EventTarget* target) { | 36 bool TestEventProcessor::CanDispatchToTarget(EventTarget* target) { |
| 33 return true; | 37 return true; |
| 34 } | 38 } |
| 35 | 39 |
| 36 EventTarget* TestEventProcessor::GetRootTarget() { | 40 EventTarget* TestEventProcessor::GetRootForEvent(Event* event) { |
| 37 return root_.get(); | 41 return root_.get(); |
| 38 } | 42 } |
| 39 | 43 |
| 44 EventTargeter* TestEventProcessor::GetDefaultEventTargeter() { |
| 45 return root_->GetEventTargeter(); |
| 46 } |
| 47 |
| 40 EventDispatchDetails TestEventProcessor::OnEventFromSource(Event* event) { | 48 EventDispatchDetails TestEventProcessor::OnEventFromSource(Event* event) { |
| 41 return EventProcessor::OnEventFromSource(event); | 49 return EventProcessor::OnEventFromSource(event); |
| 42 } | 50 } |
| 43 | 51 |
| 44 void TestEventProcessor::OnEventProcessingStarted(Event* event) { | 52 void TestEventProcessor::OnEventProcessingStarted(Event* event) { |
| 45 num_times_processing_started_++; | 53 num_times_processing_started_++; |
| 46 if (!should_processing_occur_) | 54 if (!should_processing_occur_) |
| 47 event->SetHandled(); | 55 event->SetHandled(); |
| 48 } | 56 } |
| 49 | 57 |
| 50 void TestEventProcessor::OnEventProcessingFinished(Event* event) { | 58 void TestEventProcessor::OnEventProcessingFinished(Event* event) { |
| 51 num_times_processing_finished_++; | 59 num_times_processing_finished_++; |
| 52 } | 60 } |
| 53 | 61 |
| 54 } // namespace test | 62 } // namespace test |
| 55 } // namespace ui | 63 } // namespace ui |
| OLD | NEW |