File: x11-accept-touch.cpp

package info (click to toggle)
frame 2.5.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,540 kB
  • sloc: sh: 11,090; cpp: 3,815; ansic: 745; makefile: 288
file content (86 lines) | stat: -rw-r--r-- 2,172 bytes parent folder | download | duplicates (3)
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
#include "frame-x11-fixture.h"
#include "x11_mocks.h"

class X11TouchAcceptance : public FrameX11Fixture
{
};

/*
 Calls frame_accept_touch and check if the corresponding X11 call is made
 */
TEST_F(X11TouchAcceptance, Accept)
{
  UFStatus status;
  UFDevice device;

  xmock_server_time = 1234;

  CreateXMockTouchScreenDevice();

  Display *display = XOpenDisplay(NULL);

  status = frame_x11_new(display, &frame_handle);
  ASSERT_EQ(UFStatusSuccess, status);

  FetchDeviceAddedEvent(&device);
  AssertNoMoreEvents();

  SendTouchEvent(XI_TouchBegin, 1, 10.0f, 10.0f);
  SendTouchOwnershipEvent(1);

  UFWindowId frame_window_id = frame_x11_create_window_id(DefaultRootWindow(display));
  status = frame_accept_touch(device, frame_window_id, 1);
  ASSERT_EQ(UFStatusSuccess, status);

  ASSERT_EQ(XIAcceptTouch,
            xmock_get_touch_acceptance(xmock_devices[0].attachment /* device id */,
                                       1 /* touch id */,
                                       DefaultRootWindow(display)));

  frame_x11_delete(frame_handle);
  frame_handle = nullptr;

  XCloseDisplay(display);

  DestroyXMockDevices();
}

/*
 Calls frame_reject_touch and check if the corresponding X11 call is made
 */
TEST_F(X11TouchAcceptance, Reject)
{
  UFStatus status;
  UFDevice device;

  xmock_server_time = 1234;

  CreateXMockTouchScreenDevice();

  Display *display = XOpenDisplay(NULL);

  status = frame_x11_new(display, &frame_handle);
  ASSERT_EQ(UFStatusSuccess, status);

  FetchDeviceAddedEvent(&device);
  AssertNoMoreEvents();

  SendTouchEvent(XI_TouchBegin, 1, 10.0f, 10.0f);
  SendTouchOwnershipEvent(1);

  UFWindowId frame_window_id = frame_x11_create_window_id(DefaultRootWindow(display));
  status = frame_reject_touch(device, frame_window_id, 1);
  ASSERT_EQ(UFStatusSuccess, status);

  ASSERT_EQ(XIRejectTouch,
            xmock_get_touch_acceptance(xmock_devices[0].attachment /* device id */,
                                       1 /* touch id */,
                                       DefaultRootWindow(display)));

  frame_x11_delete(frame_handle);
  frame_handle = nullptr;

  XCloseDisplay(display);

  DestroyXMockDevices();
}