2
* @file check_gesture_attrs.c
3
* @brief Unit tests for GEIS v1 gesture attrs
5
* Copyright 2011 Canonical Ltd.
7
* This library is free software; you can redistribute it and/or modify it under
8
* the terms of the GNU Lesser General Public License as published by the Free
9
* Software Foundation; either version 3 of the License, or (at your option) any
12
* This library is distributed in the hope that it will be useful, but WITHOUT
13
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17
* You should have received a copy of the GNU Lesser General Public License
18
* along with this program; if not, write to the Free Software Foundation, Inc.,
19
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
#include <geis/geis.h>
28
#define GEIS_TEST_WINDOW geis_win_type_str(Test)
30
static const char* s_gestures[] = {
31
GEIS_GESTURE_TYPE_DRAG2, GEIS_GESTURE_TYPE_DRAG3,
32
GEIS_GESTURE_TYPE_PINCH2, GEIS_GESTURE_TYPE_PINCH3,
33
GEIS_GESTURE_TYPE_ROTATE2, GEIS_GESTURE_TYPE_ROTATE3,
34
GEIS_GESTURE_TYPE_TAP2, GEIS_GESTURE_TYPE_TAP3, GEIS_GESTURE_TYPE_TAP4,
45
gesture_added(void *cookie CK_ATTRIBUTE_UNUSED,
46
GeisGestureType gesture_type CK_ATTRIBUTE_UNUSED,
47
GeisGestureId gesture_id CK_ATTRIBUTE_UNUSED,
48
GeisSize attr_count CK_ATTRIBUTE_UNUSED,
49
GeisGestureAttr *attrs CK_ATTRIBUTE_UNUSED)
54
gesture_removed(void *cookie CK_ATTRIBUTE_UNUSED,
55
GeisGestureType gesture_type CK_ATTRIBUTE_UNUSED,
56
GeisGestureId gesture_id CK_ATTRIBUTE_UNUSED,
57
GeisSize attr_count CK_ATTRIBUTE_UNUSED,
58
GeisGestureAttr *attrs CK_ATTRIBUTE_UNUSED)
63
* Checks for special values generated by the mock back end.
66
gesture_start(void *cookie,
67
GeisGestureType gesture_type CK_ATTRIBUTE_UNUSED,
68
GeisGestureId gesture_id CK_ATTRIBUTE_UNUSED,
70
GeisGestureAttr *attrs)
73
struct test_data_t *test_data = (struct test_data_t*)cookie;
75
for (i = 0; i < attr_count; ++i)
77
if (0 == strcmp(attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X)
78
&& fabs(attrs[i].float_val - 123.456) < 0.01)
80
++test_data->count_728606;
82
else if (0 == strcmp(attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y)
83
&& fabs(attrs[i].float_val - 987.654) < 0.01)
85
++test_data->count_728606;
87
else if (0 == strcmp(attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TOUCHES)
88
&& attrs[i].integer_val == 1)
90
++test_data->count_732104;
96
gesture_update(void *cookie CK_ATTRIBUTE_UNUSED,
97
GeisGestureType gesture_type CK_ATTRIBUTE_UNUSED,
98
GeisGestureId gesture_id CK_ATTRIBUTE_UNUSED,
99
GeisSize attr_count CK_ATTRIBUTE_UNUSED,
100
GeisGestureAttr *attrs CK_ATTRIBUTE_UNUSED)
105
gesture_finish(void *cookie CK_ATTRIBUTE_UNUSED,
106
GeisGestureType gesture_type CK_ATTRIBUTE_UNUSED,
107
GeisGestureId gesture_id CK_ATTRIBUTE_UNUSED,
108
GeisSize attr_count CK_ATTRIBUTE_UNUSED,
109
GeisGestureAttr *attrs CK_ATTRIBUTE_UNUSED)
114
GeisGestureFuncs gesture_funcs = {
123
static GeisInstance g_instance;
130
GeisXcbWinInfo x_win_info = {
131
.display_name = NULL,
135
GeisWinInfo win_info = { GEIS_TEST_WINDOW, &x_win_info };
137
status = geis_init(&win_info, &g_instance);
140
/* fixture teardown */
144
geis_finish(g_instance);
147
START_TEST(receive_events)
150
struct test_data_t test_data;
151
memset(&test_data, 0, sizeof(test_data));
153
status = geis_subscribe(g_instance,
154
GEIS_ALL_INPUT_DEVICES,
158
fail_unless(status == GEIS_STATUS_SUCCESS, "subscription failed");
160
while (GEIS_STATUS_CONTINUE == geis_event_dispatch(g_instance))
163
/* Regression test for bug LP: #728606. */
164
fail_unless(test_data.count_728606 == 2,
165
"unexpected count for LP:728606: expected 2, got %d", test_data.count_728606);
166
fail_unless(test_data.count_732104 == 0,
167
"unexpected count for LP:732104: expected 0, got %d", test_data.count_732104);
173
geis1_gesture_attrs_new()
175
Suite *s = suite_create("geis1_gesture_attrs");
178
test = tcase_create("lp728606");
179
tcase_add_checked_fixture(test, construct_instance, destroy_instance);
180
tcase_add_test(test, receive_events);
181
suite_add_tcase(s, test);