1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_TEST_TEST_EVENT_HANDLER_H_
6 #define UI_EVENTS_TEST_TEST_EVENT_HANDLER_H_
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "ui/events/event_handler.h"
15 typedef std::vector
<std::string
> HandlerSequenceRecorder
;
20 // A simple EventHandler that keeps track of the number of key events that it's
22 class TestEventHandler
: public EventHandler
{
25 ~TestEventHandler() override
;
27 int num_key_events() const { return num_key_events_
; }
28 int num_mouse_events() const { return num_mouse_events_
; }
29 int num_scroll_events() const { return num_scroll_events_
; }
30 int num_touch_events() const { return num_touch_events_
; }
31 int num_gesture_events() const { return num_gesture_events_
; }
35 void set_recorder(HandlerSequenceRecorder
* recorder
) {
38 void set_handler_name(const std::string
& handler_name
) {
39 handler_name_
= handler_name
;
42 // EventHandler overrides:
43 void OnKeyEvent(KeyEvent
* event
) override
;
44 void OnMouseEvent(MouseEvent
* event
) override
;
45 void OnScrollEvent(ScrollEvent
* event
) override
;
46 void OnTouchEvent(TouchEvent
* event
) override
;
47 void OnGestureEvent(GestureEvent
* event
) override
;
50 // How many events have been received of each type?
52 int num_mouse_events_
;
53 int num_scroll_events_
;
54 int num_touch_events_
;
55 int num_gesture_events_
;
57 HandlerSequenceRecorder
* recorder_
;
58 std::string handler_name_
;
60 DISALLOW_COPY_AND_ASSIGN(TestEventHandler
);
66 #endif // UI_EVENTS_TEST_TEST_EVENT_HANDLER_H_