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 void 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 in our override of OnEventProcessingStarted(). If this value is |
| 42 // false, mark incoming events as handled. |
| 43 bool should_processing_occur_; |
| 44 |
| 45 // Counts the number of times OnEventProcessingStarted() has been called. |
| 46 int num_times_processing_started_; |
| 47 |
35 // Counts the number of times OnEventProcessingFinished() has been called. | 48 // Counts the number of times OnEventProcessingFinished() has been called. |
36 int num_times_processing_finished_; | 49 int num_times_processing_finished_; |
37 | 50 |
38 DISALLOW_COPY_AND_ASSIGN(TestEventProcessor); | 51 DISALLOW_COPY_AND_ASSIGN(TestEventProcessor); |
39 }; | 52 }; |
40 | 53 |
41 } // namespace test | 54 } // namespace test |
42 } // namespace ui | 55 } // namespace ui |
43 | 56 |
44 #endif // UI_EVENTS_TEST_TEST_EVENT_PROCESSOR_H_ | 57 #endif // UI_EVENTS_TEST_TEST_EVENT_PROCESSOR_H_ |
OLD | NEW |