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 virtual ~TestEventProcessor(); |
18 | 18 |
| 19 int num_times_processing_started() const { |
| 20 return num_times_processing_started_; |
| 21 } |
| 22 |
19 int num_times_processing_finished() const { | 23 int num_times_processing_finished() const { |
20 return num_times_processing_finished_; | 24 return num_times_processing_finished_; |
21 } | 25 } |
22 | 26 |
23 void SetRoot(scoped_ptr<EventTarget> root); | 27 void SetRoot(scoped_ptr<EventTarget> root); |
24 void ResetCounts(); | 28 void SetShouldProcessingOccur(bool occur); |
| 29 void Reset(); |
25 | 30 |
26 // EventProcessor: | 31 // EventProcessor: |
27 virtual bool CanDispatchToTarget(EventTarget* target) OVERRIDE; | 32 virtual bool CanDispatchToTarget(EventTarget* target) OVERRIDE; |
28 virtual EventTarget* GetRootTarget() OVERRIDE; | 33 virtual EventTarget* GetRootTarget() OVERRIDE; |
29 virtual EventDispatchDetails OnEventFromSource(Event* event) OVERRIDE; | 34 virtual EventDispatchDetails OnEventFromSource(Event* event) OVERRIDE; |
| 35 virtual bool OnEventProcessingStarted(Event* event) OVERRIDE; |
30 virtual void OnEventProcessingFinished(Event* event) OVERRIDE; | 36 virtual void OnEventProcessingFinished(Event* event) OVERRIDE; |
31 | 37 |
32 private: | 38 private: |
33 scoped_ptr<EventTarget> root_; | 39 scoped_ptr<EventTarget> root_; |
34 | 40 |
| 41 // Used as the return value for OnEventProcessingStarted(). |
| 42 bool should_processing_occur_; |
| 43 |
| 44 // Counts the number of times OnEventProcessingStarted() has been called. |
| 45 int num_times_processing_started_; |
| 46 |
35 // Counts the number of times OnEventProcessingFinished() has been called. | 47 // Counts the number of times OnEventProcessingFinished() has been called. |
36 int num_times_processing_finished_; | 48 int num_times_processing_finished_; |
37 | 49 |
38 DISALLOW_COPY_AND_ASSIGN(TestEventProcessor); | 50 DISALLOW_COPY_AND_ASSIGN(TestEventProcessor); |
39 }; | 51 }; |
40 | 52 |
41 } // namespace test | 53 } // namespace test |
42 } // namespace ui | 54 } // namespace ui |
43 | 55 |
44 #endif // UI_EVENTS_TEST_TEST_EVENT_PROCESSOR_H_ | 56 #endif // UI_EVENTS_TEST_TEST_EVENT_PROCESSOR_H_ |
OLD | NEW |