1
#include "gtest_grail_backend.h"
5
Check that GEIS_EVENT_ATTRIBUTE_CONSTRUCTION_FINISHED
9
class ConstructionFinishedProperty : public Geis2GrailBackendBase
12
ConstructionFinishedProperty() : _subscription(nullptr),
13
_got_update_with_construction_finished(false) {}
15
void SendFirstBatchOfXInput2Events();
16
void SendSecondBatchOfXInput2Events();
18
virtual void OnEventInitComplete(GeisEvent event);
19
virtual void OnEventGestureBegin(GeisEvent event);
20
virtual void OnEventGestureUpdate(GeisEvent event);
22
GeisSubscription _subscription;
23
bool _got_update_with_construction_finished;
26
void ConstructionFinishedProperty::SendFirstBatchOfXInput2Events()
28
xmock_server_time = 0;
30
SendTouchEvent(XI_TouchBegin, 0, 123.0f, 456.0f);
31
SendTouchEvent(XI_TouchBegin, 1, 222.0f, 456.0f);
33
xmock_server_time = 5;
35
SendTouchOwnershipEvent(0);
36
SendTouchOwnershipEvent(1);
38
SendTouchEvent(XI_TouchUpdate, 0, 123.0f, 466.0f);
39
SendTouchEvent(XI_TouchUpdate, 1, 222.0f, 466.0f);
42
void ConstructionFinishedProperty::SendSecondBatchOfXInput2Events()
44
/* Go past composition time (i.e. time window where new touches can be grouped
45
with existing ones to make new gestures) */
46
xmock_server_time = 70;
48
SendTouchEvent(XI_TouchUpdate, 0, 123.0f, 466.0f);
49
SendTouchEvent(XI_TouchUpdate, 1, 222.0f, 466.0f);
51
xmock_server_time = 80;
53
SendTouchEvent(XI_TouchEnd, 0, 123.0f, 476.0f);
54
SendTouchEvent(XI_TouchEnd, 1, 222.0f, 476.0f);
57
void ConstructionFinishedProperty::OnEventInitComplete(GeisEvent event)
59
_subscription = CreateFilteredSubscription(
60
"My 2-touches Touch", 2, GEIS_GESTURE_TOUCH);
61
ASSERT_NE(nullptr, _subscription);
64
void ConstructionFinishedProperty::OnEventGestureBegin(GeisEvent event)
66
GeisAttr attr = geis_event_attr_by_name(event,
67
GEIS_EVENT_ATTRIBUTE_CONSTRUCTION_FINISHED);
69
GeisBoolean construction_finished = geis_attr_value_to_boolean(attr);
71
ASSERT_EQ(GEIS_FALSE, construction_finished);
74
void ConstructionFinishedProperty::OnEventGestureUpdate(GeisEvent event)
76
GeisAttr attr = geis_event_attr_by_name(event,
77
GEIS_EVENT_ATTRIBUTE_CONSTRUCTION_FINISHED);
79
GeisBoolean construction_finished = geis_attr_value_to_boolean(attr);
81
GeisInteger timestamp;
82
GetGestureTimestampInEvent(×tamp, event);
86
/* below composition time. Construction cannot be finished just yet */
87
ASSERT_EQ(GEIS_FALSE, construction_finished);
91
/* we're past composition time and therefore grail will
92
send a slice with "construction finished" set to true.
93
geis must follow suit. */
94
ASSERT_EQ(GEIS_TRUE, construction_finished);
95
_got_update_with_construction_finished = true;
99
TEST_F(ConstructionFinishedProperty, Test)
101
CreateXMockTouchScreenDevice();
103
_geis = geis_new(GEIS_INIT_GRAIL_BACKEND,
104
GEIS_INIT_NO_ATOMIC_GESTURES,
106
ASSERT_NE(nullptr, _geis);
108
/* geis emits event stating that its initialization has finished */
111
/* begin XInput touches */
112
SendFirstBatchOfXInput2Events();
114
/* geis should receive an XAlarm event. geis updates grail time to 60.
115
grail touches timeout (they get beyond composition time) which
116
causes construction to finish.
120
/* end XInput touches */
121
SendSecondBatchOfXInput2Events();
126
ASSERT_TRUE(_got_update_with_construction_finished);
129
geis_subscription_delete(_subscription);
132
DestroyXMockDevices();