File: one-touch-gest-finished.cpp

package info (click to toggle)
grail 3.1.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,296 kB
  • sloc: sh: 11,416; cpp: 5,636; ansic: 1,587; makefile: 254
file content (95 lines) | stat: -rw-r--r-- 2,672 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "grail-fixture.h"

class SingleTouchGestureTest : public GrailTest
{
};

/*
 Regression test for bug https://bugs.launchpad.net/grail/+bug/1020315
 */
TEST_F(SingleTouchGestureTest, QuickTapEndsWithConstructionFinished)
{
  UGStatus status;
  fake_window_id = 321;
  uint64_t time = 1234;

  status = grail_new(&grail_handle);
  ASSERT_EQ(UGStatusSuccess, status);

  SendDeviceAddedEvent(time);

  UGSubscription subscription =
    CreateSubscription(1, UGGestureTypeTouch, fake_window_id);
  if (!subscription) return;

  time += 10;
  BeginTouch(1);

  time += 10;
  GiveTouchOwnership(1);

  // There should now be two grail events, corresponding to the frame
  // event that were sent, waiting to be processed.

  // Check first event. A gesture begin.
  UGEvent grail_event;
  status = grail_get_event(grail_handle, &grail_event);
  ASSERT_EQ(UGStatusSuccess, status);

  ASSERT_EQ(UGEventTypeSlice, grail_event_get_type(grail_event));

  UGSlice slice;
  status = grail_event_get_property(grail_event, UGEventPropertySlice, &slice);
  ASSERT_EQ(UGStatusSuccess, status);

  ASSERT_EQ(UGGestureStateBegin, grail_slice_get_state(slice));
  ASSERT_FALSE(grail_slice_get_construction_finished(slice));

  grail_event_unref(grail_event);

  // Check the second event. A gesture update.
  status = grail_get_event(grail_handle, &grail_event);
  ASSERT_EQ(UGStatusSuccess, status);

  ASSERT_EQ(UGEventTypeSlice, grail_event_get_type(grail_event));

  status = grail_event_get_property(grail_event, UGEventPropertySlice, &slice);
  ASSERT_EQ(UGStatusSuccess, status);

  ASSERT_EQ(UGGestureStateUpdate, grail_slice_get_state(slice));
  ASSERT_FALSE(grail_slice_get_construction_finished(slice));

  grail_event_unref(grail_event);

  // now end the touch

  time += 10;
  EndTouch(1);

  // An end event should come and its "construction finished" property should be true

  UGStatus get_event_status;
  do
  {
    get_event_status = grail_get_event(grail_handle, &grail_event);
    if (get_event_status != UGStatusSuccess)
      break;

    ASSERT_EQ(UGEventTypeSlice, grail_event_get_type(grail_event));

    status = grail_event_get_property(grail_event, UGEventPropertySlice, &slice);
    ASSERT_EQ(UGStatusSuccess, status);

    // We ignore any intermediate updates
    if (grail_slice_get_state(slice) == UGGestureStateUpdate)
      continue;

    ASSERT_EQ(UGGestureStateEnd, grail_slice_get_state(slice));
    ASSERT_TRUE(grail_slice_get_construction_finished(slice));

    grail_event_unref(grail_event);
  } while (get_event_status == UGStatusSuccess);
  ASSERT_EQ(UGStatusErrorNoEvent, get_event_status);

  grail_subscription_delete(subscription);
}