Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
client_event_matchers.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Robert Carr <robert.carr@canonical.com>
17  */
18 
19 #include "mir_toolkit/event.h"
20 
21 #include <xkbcommon/xkbcommon.h>
22 #include <xkbcommon/xkbcommon-keysyms.h>
23 
24 #include <gmock/gmock.h>
25 
26 namespace mir
27 {
28 namespace test
29 {
30 
31 MATCHER(KeyDownEvent, "")
32 {
33  if (arg->type != mir_event_type_key)
34  return false;
35  if (arg->key.action != mir_key_action_down) // Key down
36  return false;
37 
38  return true;
39 }
40 MATCHER_P(KeyOfSymbol, keysym, "")
41 {
42  if (static_cast<xkb_keysym_t>(arg->key.key_code) == (uint)keysym)
43  return true;
44  return false;
45 }
46 
47 MATCHER(HoverEnterEvent, "")
48 {
49  if (arg->type != mir_event_type_motion)
50  return false;
51  if (arg->motion.action != mir_motion_action_hover_enter)
52  return false;
53 
54  return true;
55 }
56 MATCHER(HoverExitEvent, "")
57 {
58  if (arg->type != mir_event_type_motion)
59  return false;
60  if (arg->motion.action != mir_motion_action_hover_exit)
61  return false;
62 
63  return true;
64 }
65 
66 MATCHER_P2(ButtonDownEvent, x, y, "")
67 {
68  if (arg->type != mir_event_type_motion)
69  return false;
70  if (arg->motion.action != mir_motion_action_down)
71  return false;
72  if (arg->motion.button_state == 0)
73  return false;
74  if (arg->motion.pointer_coordinates[0].x != x)
75  return false;
76  if (arg->motion.pointer_coordinates[0].y != y)
77  return false;
78  return true;
79 }
80 
81 MATCHER_P2(ButtonUpEvent, x, y, "")
82 {
83  if (arg->type != mir_event_type_motion)
84  return false;
85  if (arg->motion.action != mir_motion_action_up)
86  return false;
87  if (arg->motion.pointer_coordinates[0].x != x)
88  return false;
89  if (arg->motion.pointer_coordinates[0].y != y)
90  return false;
91  return true;
92 }
93 
94 MATCHER_P2(MotionEventWithPosition, x, y, "")
95 {
96  if (arg->type != mir_event_type_motion)
97  return false;
98  if (arg->motion.action != mir_motion_action_move &&
99  arg->motion.action != mir_motion_action_hover_move)
100  return false;
101  if (arg->motion.pointer_coordinates[0].x != x)
102  return false;
103  if (arg->motion.pointer_coordinates[0].y != y)
104  return false;
105  return true;
106 }
107 
108 MATCHER(MovementEvent, "")
109 {
110  if (arg->type != mir_event_type_motion)
111  return false;
112  if (arg->motion.action != mir_motion_action_move &&
113  arg->motion.action != mir_motion_action_hover_move)
114  return false;
115  return true;
116 }
117 
118 }
119 }
Definition: event.h:98
Definition: event.h:47
Definition: event.h:40
Definition: event.h:41
Definition: dimensions.h:35
Definition: event.h:88
Definition: event.h:97
Definition: dimensions.h:35
MATCHER_P2(ButtonDownEvent, x, y,"")
Definition: client_event_matchers.h:66
MATCHER(KeyDownEvent,"")
Definition: client_event_matchers.h:31
Definition: event.h:90
Definition: event.h:95
Definition: event.h:89
MATCHER_P(KeyOfSymbol, keysym,"")
Definition: client_event_matchers.h:40

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Apr 11 21:14:53 UTC 2014