1
#include "gtest_grail_backend.h"
5
Regression test for bug https://bugs.launchpad.net/geis/+bug/1015775
7
Checks that the following situation doesn't lead to a crash:
8
- Geis processed the end event of a grail gesture
9
- Geis has a number of geis events pending delivery to application
10
- Application accepts that ended grail gesture
13
- While checking the queue of pending events for events that should
14
no longer be delivered due to the gesture acceptance, geis would
15
try to use a struct with information from the ended grail gesture
16
that also no longer exists.
19
class AcceptEndedGesture : public Geis2GrailBackendBase
22
AcceptEndedGesture() : _subscription(nullptr) {}
24
void SendXInput2Events();
26
virtual void OnEventInitComplete(GeisEvent event);
27
virtual void OnEventGestureBegin(GeisEvent event);
29
GeisSubscription _subscription;
32
void AcceptEndedGesture::SendXInput2Events()
34
/* args: event type, touch id, X and Y */
35
SendTouchEvent(XI_TouchBegin, 1, 10.0f, 10.0f);
36
SendTouchEvent(XI_TouchBegin, 2, 20.0f, 10.0f);
38
xmock_server_time += 5;
41
SendTouchOwnershipEvent(1);
42
SendTouchOwnershipEvent(2);
44
xmock_server_time += 5;
46
SendTouchEvent(XI_TouchUpdate, 1, 10.0f, 20.0f);
47
SendTouchEvent(XI_TouchUpdate, 2, 20.0f, 20.0f);
49
xmock_server_time += 5;
51
SendTouchEvent(XI_TouchEnd, 1, 10.0f, 30.0f);
52
SendTouchEvent(XI_TouchEnd, 2, 20.0f, 30.0f);
55
void AcceptEndedGesture::OnEventInitComplete(GeisEvent event)
57
_subscription = CreateFilteredSubscription(
58
"My 2-touches Touch", 2, GEIS_GESTURE_TOUCH);
59
ASSERT_NE(nullptr, _subscription);
64
void AcceptEndedGesture::OnEventGestureBegin(GeisEvent event)
66
AcceptGestureInEvent(event);
69
TEST_F(AcceptEndedGesture, Test)
71
CreateXMockTouchScreenDevice();
73
_geis = geis_new(GEIS_INIT_GRAIL_BACKEND,
74
GEIS_INIT_NO_ATOMIC_GESTURES,
76
ASSERT_NE(nullptr, _geis);
81
geis_subscription_delete(_subscription);
84
DestroyXMockDevices();