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