2
* Gtest test suite for GEIS v1 attributes.
4
* Copyright 2012 Canonical Ltd.
9
#include "gtest_evemu_device.h"
10
#include "gtest_geis1_fixture.h"
11
#include <gtest/gtest.h>
13
#include <sys/select.h>
20
const std::string TEST_DEVICE_PROP_FILE(TEST_ROOT_DIR "recordings/apple_magic_trackpad/device.prop");
21
const std::string TEST_DEVICE_EVENTS_FILE(TEST_ROOT_DIR "recordings/apple_magic_trackpad/four_tap.record");
24
* Fixture for testing expected attributes. This has to be a separate class
25
* because of the way Java reflection is used in jUnit.
27
class Geis1AttributeTests
28
: public GTestGeis1Fixture
32
: evemu_device_(TEST_DEVICE_PROP_FILE),
36
void GestureUpdate(GeisGestureType type, GeisGestureId id, GeisSize count,
37
GeisGestureAttr* attrs);
40
Testsuite::EvemuDevice evemu_device_;
44
void gesture_begin(void* cookie, GeisGestureType type, GeisGestureId id,
45
GeisSize count, GeisGestureAttr* attrs) {
46
FAIL() << "received unexpected gesture begin event";
49
void gesture_update(void* cookie, GeisGestureType type, GeisGestureId id,
50
GeisSize count, GeisGestureAttr* attrs) {
51
Geis1AttributeTests* fixture = reinterpret_cast<Geis1AttributeTests*>(cookie);
52
fixture->GestureUpdate(type, id, count, attrs);
55
void gesture_end(void* cookie, GeisGestureType type, GeisGestureId id,
56
GeisSize count, GeisGestureAttr* attrs) {
57
FAIL() << "received unexpected gesture end event";
60
void gesture_null_func(void* cookie, GeisGestureType type, GeisGestureId id,
61
GeisSize count, GeisGestureAttr* attrs) {
64
void Geis1AttributeTests::GestureUpdate(GeisGestureType type, GeisGestureId id,
66
GeisGestureAttr* attrs) {
67
EXPECT_EQ(GEIS_GESTURE_PRIMITIVE_TAP, type);
69
EXPECT_FALSE(saw_four_tap);
71
for (int i = 0; i < count; i++) {
72
GeisGestureAttr attr = attrs[i];
73
if (strcmp(attr.name, GEIS_GESTURE_ATTRIBUTE_TOUCHES) == 0) {
74
ASSERT_EQ(4, attr.integer_val);
82
* Regression test for lp:957331, lp:957334, and lp:957344: geis v1 tap handling
84
* A geis v1 four tap system subscription is created, and a four tap gesture is
85
* replayed on a touchpad device.
87
* Expected: One four touch tap gesture update event is received. No other
88
* events should be seen.
90
TEST_F(Geis1AttributeTests, tap_touch_count)
92
static const char* gestures[] = {
93
GEIS_GESTURE_TYPE_TAP4,
94
GEIS_GESTURE_TYPE_SYSTEM,
97
static GeisGestureFuncs callbacks = {
105
ASSERT_EQ(GEIS_STATUS_SUCCESS,
106
geis_subscribe(geis(), GEIS_ALL_INPUT_DEVICES, gestures, &callbacks,
109
evemu_device_.play(TEST_DEVICE_EVENTS_FILE);
114
FD_SET(geis_fd(), &read_fds);
115
timeval tmo = { 1, 0 };
116
int sstat = select(geis_fd() + 1, &read_fds, NULL, NULL, &tmo);
117
EXPECT_GT(sstat, -1) << "error in select";
120
ASSERT_EQ(GEIS_STATUS_SUCCESS, geis_event_dispatch(geis()));
123
EXPECT_TRUE(saw_four_tap);
126
} // anonymous namespace