~matttbe/ubuntu/raring/geis/lp1077376

« back to all changes in this revision

Viewing changes to testsuite/geis2/gtest_gbe_accept_ended_grail_gesture.cpp

  • Committer: Package Import Robot
  • Author(s): Chase Douglas
  • Date: 2012-07-30 08:51:42 UTC
  • Revision ID: package-import@ubuntu.com-20120730085142-jrc33ygjvt0ob1wl
Tags: upstream-2.2.11
ImportĀ upstreamĀ versionĀ 2.2.11

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "gtest_grail_backend.h"
 
2
#include "x11_mocks.h"
 
3
 
 
4
/*
 
5
  Regression test for bug https://bugs.launchpad.net/geis/+bug/1015775
 
6
 
 
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
 
11
 
 
12
  Cause:
 
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.
 
17
 */
 
18
 
 
19
class AcceptEndedGesture : public Geis2GrailBackendBase
 
20
{
 
21
 protected:
 
22
  AcceptEndedGesture() :  _subscription(nullptr) {}
 
23
 
 
24
  void SendXInput2Events();
 
25
 
 
26
  virtual void OnEventInitComplete(GeisEvent event);
 
27
  virtual void OnEventGestureBegin(GeisEvent event);
 
28
 
 
29
  GeisSubscription _subscription;
 
30
};
 
31
 
 
32
void AcceptEndedGesture::SendXInput2Events()
 
33
{
 
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);
 
37
 
 
38
  xmock_server_time += 5;
 
39
 
 
40
  /* args: touch id  */
 
41
  SendTouchOwnershipEvent(1);
 
42
  SendTouchOwnershipEvent(2);
 
43
 
 
44
  xmock_server_time += 5;
 
45
 
 
46
  SendTouchEvent(XI_TouchUpdate, 1, 10.0f, 20.0f);
 
47
  SendTouchEvent(XI_TouchUpdate, 2, 20.0f, 20.0f);
 
48
 
 
49
  xmock_server_time += 5;
 
50
 
 
51
  SendTouchEvent(XI_TouchEnd, 1, 10.0f, 30.0f);
 
52
  SendTouchEvent(XI_TouchEnd, 2, 20.0f, 30.0f);
 
53
}
 
54
 
 
55
void AcceptEndedGesture::OnEventInitComplete(GeisEvent event)
 
56
{
 
57
  _subscription = CreateFilteredSubscription(
 
58
      "My 2-touches Touch", 2, GEIS_GESTURE_TOUCH);
 
59
  ASSERT_NE(nullptr, _subscription);
 
60
 
 
61
  SendXInput2Events();
 
62
}
 
63
 
 
64
void AcceptEndedGesture::OnEventGestureBegin(GeisEvent event)
 
65
{
 
66
  AcceptGestureInEvent(event);
 
67
}
 
68
 
 
69
TEST_F(AcceptEndedGesture, Test)
 
70
{
 
71
  CreateXMockTouchScreenDevice();
 
72
 
 
73
  _geis = geis_new(GEIS_INIT_GRAIL_BACKEND,
 
74
                       GEIS_INIT_NO_ATOMIC_GESTURES,
 
75
                       nullptr);
 
76
  ASSERT_NE(nullptr, _geis);
 
77
 
 
78
  Run();
 
79
 
 
80
  if (_subscription)
 
81
    geis_subscription_delete(_subscription);
 
82
  geis_delete(_geis);
 
83
 
 
84
  DestroyXMockDevices();
 
85
}