• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef UI_EVENTS_TEST_EVENTS_TEST_UTILS_H_
6 #define UI_EVENTS_TEST_EVENTS_TEST_UTILS_H_
7 
8 #include "ui/events/event.h"
9 #include "ui/events/event_dispatcher.h"
10 #include "ui/events/event_target.h"
11 
12 namespace ui {
13 
14 class EventSource;
15 
16 class EventTestApi {
17  public:
18   explicit EventTestApi(Event* event);
19   virtual ~EventTestApi();
20 
set_time_stamp(base::TimeDelta time_stamp)21   void set_time_stamp(base::TimeDelta time_stamp) {
22     event_->time_stamp_ = time_stamp;
23   }
24 
set_source_device_id(int source_device_id)25   void set_source_device_id(int source_device_id) {
26     event_->source_device_id_ = source_device_id;
27   }
28 
29  private:
30   EventTestApi();
31 
32   Event* event_;
33 
34   DISALLOW_COPY_AND_ASSIGN(EventTestApi);
35 };
36 
37 class LocatedEventTestApi : public EventTestApi {
38  public:
39   explicit LocatedEventTestApi(LocatedEvent* located_event);
40   virtual ~LocatedEventTestApi();
41 
set_location(const gfx::Point & location)42   void set_location(const gfx::Point& location) {
43     located_event_->location_ = location;
44   }
45 
46  private:
47   LocatedEventTestApi();
48 
49   LocatedEvent* located_event_;
50 
51   DISALLOW_COPY_AND_ASSIGN(LocatedEventTestApi);
52 };
53 
54 class KeyEventTestApi : public EventTestApi {
55  public:
56   explicit KeyEventTestApi(KeyEvent* key_event);
57   virtual ~KeyEventTestApi();
58 
set_is_char(bool is_char)59   void set_is_char(bool is_char) {
60     key_event_->set_is_char(is_char);
61   }
62 
63  private:
64   KeyEventTestApi();
65 
66   KeyEvent* key_event_;
67 
68   DISALLOW_COPY_AND_ASSIGN(KeyEventTestApi);
69 };
70 
71 class EventTargetTestApi {
72  public:
73   explicit EventTargetTestApi(EventTarget* target);
74 
pre_target_handlers()75   const EventHandlerList& pre_target_handlers() {
76     return target_->pre_target_list_;
77   }
78 
79  private:
80   EventTargetTestApi();
81 
82   EventTarget* target_;
83 
84   DISALLOW_COPY_AND_ASSIGN(EventTargetTestApi);
85 };
86 
87 class EventSourceTestApi {
88  public:
89   explicit EventSourceTestApi(EventSource* event_source);
90 
91   EventDispatchDetails SendEventToProcessor(Event* event) WARN_UNUSED_RESULT;
92 
93  private:
94   EventSourceTestApi();
95 
96   EventSource* event_source_;
97 
98   DISALLOW_COPY_AND_ASSIGN(EventSourceTestApi);
99 };
100 
101 }  // namespace ui
102 
103 #endif  // UI_EVENTS_TEST_EVENTS_TEST_UTILS_H_
104