20#include <freerdp/client.h>
21#include <freerdp/input.h>
23#include "../../../libfreerdp/core/connection.h"
25static UINT16 g_events[16];
26static size_t g_count = 0;
28static BOOL record_mouse(WINPR_ATTR_UNUSED rdpInput* input, UINT16 flags,
29 WINPR_ATTR_UNUSED UINT16 x, WINPR_ATTR_UNUSED UINT16 y)
31 if (g_count < ARRAYSIZE(g_events))
32 g_events[g_count] = flags;
38static BOOL expect(
const char* what,
const UINT16* want,
size_t count)
40 const UINT16 mask = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1 | PTR_FLAGS_BUTTON2 | PTR_FLAGS_BUTTON3;
41 BOOL ok = (g_count == count);
42 for (
size_t x = 0; ok && (x < count); x++)
43 ok = ((g_events[x] & mask) == want[x]);
46 (void)fprintf(stderr,
"%s: got %" PRIuz
" events:", what, g_count);
47 for (
size_t x = 0; (x < g_count) && (x < ARRAYSIZE(g_events)); x++)
48 (
void)fprintf(stderr,
" 0x%04" PRIx16, (UINT16)(g_events[x] & mask));
49 (void)fprintf(stderr,
", wanted %" PRIuz
":", count);
50 for (
size_t x = 0; x < count; x++)
51 (
void)fprintf(stderr,
" 0x%04" PRIx16, want[x]);
52 (void)fprintf(stderr,
"\n");
58int TestClientTouch(
int argc,
char* argv[])
64 RDP_CLIENT_ENTRY_POINTS entry = WINPR_C_ARRAY_INIT;
65 entry.Version = RDP_CLIENT_INTERFACE_VERSION;
66 entry.Size =
sizeof(entry);
67 entry.ContextSize =
sizeof(rdpClientContext);
69 rdpContext* context = freerdp_client_context_new(&entry);
72 rdpClientContext* cctx = (rdpClientContext*)context;
75 if (!rdp_client_transition_to_state(context->rdp, CONNECTION_STATE_ACTIVE))
77 context->input->MouseEvent = record_mouse;
81 const UINT16 tap[] = { PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, PTR_FLAGS_BUTTON1 };
82 if (!freerdp_client_handle_touch(cctx, FREERDP_TOUCH_DOWN, 1, 0, 100, 200) ||
83 !freerdp_client_handle_touch(cctx, FREERDP_TOUCH_UP, 1, 0, 100, 200) ||
84 !expect(
"one finger", tap, ARRAYSIZE(tap)))
90 const UINT16 two[] = { PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1,
91 PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2, PTR_FLAGS_BUTTON2,
93 if (!freerdp_client_handle_touch(cctx, FREERDP_TOUCH_DOWN, 1, 0, 100, 200) ||
94 !freerdp_client_handle_touch(cctx, FREERDP_TOUCH_DOWN, 2, 0, 150, 200) ||
95 !freerdp_client_handle_touch(cctx, FREERDP_TOUCH_UP, 2, 0, 150, 200) ||
96 !freerdp_client_handle_touch(cctx, FREERDP_TOUCH_UP, 1, 0, 100, 200) ||
97 !expect(
"two fingers", two, ARRAYSIZE(two)))
103 freerdp_client_context_free(context);