| 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 #ifndef UI_EVENTS_TEST_TEST_EVENT_PROCESSOR_H_ | 5 #ifndef UI_EVENTS_TEST_TEST_EVENT_PROCESSOR_H_ |
| 6 #define UI_EVENTS_TEST_TEST_EVENT_PROCESSOR_H_ | 6 #define UI_EVENTS_TEST_TEST_EVENT_PROCESSOR_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "ui/events/event_processor.h" | 11 #include "ui/events/event_processor.h" |
| 11 | 12 |
| 12 namespace ui { | 13 namespace ui { |
| 13 namespace test { | 14 namespace test { |
| 14 | 15 |
| 15 class TestEventProcessor : public EventProcessor { | 16 class TestEventProcessor : public EventProcessor { |
| 16 public: | 17 public: |
| 17 TestEventProcessor(); | 18 TestEventProcessor(); |
| 18 ~TestEventProcessor() override; | 19 ~TestEventProcessor() override; |
| 19 | 20 |
| 20 int num_times_processing_started() const { | 21 int num_times_processing_started() const { |
| 21 return num_times_processing_started_; | 22 return num_times_processing_started_; |
| 22 } | 23 } |
| 23 | 24 |
| 24 int num_times_processing_finished() const { | 25 int num_times_processing_finished() const { |
| 25 return num_times_processing_finished_; | 26 return num_times_processing_finished_; |
| 26 } | 27 } |
| 27 | 28 |
| 28 void set_should_processing_occur(bool occur) { | 29 void set_should_processing_occur(bool occur) { |
| 29 should_processing_occur_ = occur; | 30 should_processing_occur_ = occur; |
| 30 } | 31 } |
| 31 | 32 |
| 32 void SetRoot(scoped_ptr<EventTarget> root); | 33 void SetRoot(std::unique_ptr<EventTarget> root); |
| 33 void Reset(); | 34 void Reset(); |
| 34 | 35 |
| 35 // EventProcessor: | 36 // EventProcessor: |
| 36 bool CanDispatchToTarget(EventTarget* target) override; | 37 bool CanDispatchToTarget(EventTarget* target) override; |
| 37 EventTarget* GetRootTarget() override; | 38 EventTarget* GetRootTarget() override; |
| 38 EventDispatchDetails OnEventFromSource(Event* event) override; | 39 EventDispatchDetails OnEventFromSource(Event* event) override; |
| 39 void OnEventProcessingStarted(Event* event) override; | 40 void OnEventProcessingStarted(Event* event) override; |
| 40 void OnEventProcessingFinished(Event* event) override; | 41 void OnEventProcessingFinished(Event* event) override; |
| 41 | 42 |
| 42 private: | 43 private: |
| 43 scoped_ptr<EventTarget> root_; | 44 std::unique_ptr<EventTarget> root_; |
| 44 | 45 |
| 45 // Used in our override of OnEventProcessingStarted(). If this value is | 46 // Used in our override of OnEventProcessingStarted(). If this value is |
| 46 // false, mark incoming events as handled. | 47 // false, mark incoming events as handled. |
| 47 bool should_processing_occur_; | 48 bool should_processing_occur_; |
| 48 | 49 |
| 49 // Counts the number of times OnEventProcessingStarted() has been called. | 50 // Counts the number of times OnEventProcessingStarted() has been called. |
| 50 int num_times_processing_started_; | 51 int num_times_processing_started_; |
| 51 | 52 |
| 52 // Counts the number of times OnEventProcessingFinished() has been called. | 53 // Counts the number of times OnEventProcessingFinished() has been called. |
| 53 int num_times_processing_finished_; | 54 int num_times_processing_finished_; |
| 54 | 55 |
| 55 DISALLOW_COPY_AND_ASSIGN(TestEventProcessor); | 56 DISALLOW_COPY_AND_ASSIGN(TestEventProcessor); |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 } // namespace test | 59 } // namespace test |
| 59 } // namespace ui | 60 } // namespace ui |
| 60 | 61 |
| 61 #endif // UI_EVENTS_TEST_TEST_EVENT_PROCESSOR_H_ | 62 #endif // UI_EVENTS_TEST_TEST_EVENT_PROCESSOR_H_ |
| OLD | NEW |