Fix search results being clipped in app list.
[chromium-blink-merge.git] / ui / events / test / test_event_handler.h
blob64759c7ef4e79ccf632f3562b3205f9641496dda
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_
8 #include <string>
9 #include <vector>
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;
17 namespace ui {
18 namespace test {
20 // A simple EventHandler that keeps track of the number of key events that it's
21 // seen.
22 class TestEventHandler : public EventHandler {
23 public:
24 TestEventHandler();
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_; }
33 void Reset();
35 void set_recorder(HandlerSequenceRecorder* recorder) {
36 recorder_ = 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;
49 private:
50 // How many events have been received of each type?
51 int num_key_events_;
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);
63 } // namespace test
64 } // namespace ui
66 #endif // UI_EVENTS_TEST_TEST_EVENT_HANDLER_H_