Merge lp:~bregma/geis/lp-987539 into lp:geis

Proposed by Stephen M. Webb
Status: Merged
Merged at revision: 261
Proposed branch: lp:~bregma/geis/lp-987539
Merge into: lp:geis
Prerequisite: lp:~bregma/geis/gtest-refactor
Diff against target: 134 lines (+108/-0)
2 files modified
libutouch-geis/backend/grail/geis_grail_backend.c (+63/-0)
testsuite/geis2/gtest_devices.cpp (+45/-0)
To merge this branch: bzr merge lp:~bregma/geis/lp-987539
Reviewer Review Type Date Requested Status
Daniel d'Andrada (community) Approve
Review via email: mp+103791@code.launchpad.net

Description of the change

Fixes a regression by reporting the X and Y axis extent attributes (if available) for touch devices.

Fixes lp:987539, with test case.

To post a comment you must log in.
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

I think _geis_grail_add_device() function is getting way too long. It would be better put that code into a separate helper function[1] and call it from _geis_grail_add_device().

[1] - e.g. _gbe_add_device_axes_attributes(geis_device, frame_device)

-------

testsuite/geis2/gtest_devices.cpp:185

 * This test creates a devicve with known X and Y extents and verifies the

s/devicve/device
and probably (not a native speaker myself)
s/verifies/verifies that

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

OBS: That particular test could "easily" (you would end up writing more code) use x11_mocks and therefore avoid being an integration test.
(couldn't resist doing some advertising...)

lp:~bregma/geis/lp-987539 updated
263. By Stephen M. Webb

Moved new code into a separate function.

Revision history for this message
Stephen M. Webb (bregma) wrote :

Function refactored as requested.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libutouch-geis/backend/grail/geis_grail_backend.c'
2--- libutouch-geis/backend/grail/geis_grail_backend.c 2012-04-24 16:09:09 +0000
3+++ libutouch-geis/backend/grail/geis_grail_backend.c 2012-04-27 16:09:20 +0000
4@@ -773,6 +773,67 @@
5
6
7 /**
8+ * Adds the axis exten attributes for a device, if available.
9+ */
10+static void
11+_gbe_add_device_axis_attributes(UFDevice frame_device, GeisDevice geis_device)
12+{
13+ UFStatus status;
14+ GeisFloat fval;
15+
16+ UFAxis x_axis;
17+ status = frame_device_get_axis_by_type(frame_device, UFAxisTypeX, &x_axis);
18+ if (status != UFStatusSuccess)
19+ {
20+ geis_warning("failed to get X axis property from device '%s'",
21+ geis_device_name(geis_device));
22+ }
23+ else
24+ {
25+ fval = frame_axis_get_minimum(x_axis);
26+ geis_device_add_attr(geis_device, geis_attr_new(GEIS_DEVICE_ATTRIBUTE_MIN_X,
27+ GEIS_ATTR_TYPE_FLOAT,
28+ &fval));
29+
30+ fval = frame_axis_get_maximum(x_axis);
31+ geis_device_add_attr(geis_device, geis_attr_new(GEIS_DEVICE_ATTRIBUTE_MAX_X,
32+ GEIS_ATTR_TYPE_FLOAT,
33+ &fval));
34+
35+ fval = frame_axis_get_resolution(x_axis);
36+ geis_device_add_attr(geis_device, geis_attr_new(GEIS_DEVICE_ATTRIBUTE_RES_X,
37+ GEIS_ATTR_TYPE_FLOAT,
38+ &fval));
39+ }
40+
41+ UFAxis y_axis;
42+ status = frame_device_get_axis_by_type(frame_device, UFAxisTypeY, &y_axis);
43+ if (status != UFStatusSuccess)
44+ {
45+ geis_warning("failed to get Y axis property from device '%s'",
46+ geis_device_name(geis_device));
47+ }
48+ else
49+ {
50+ fval = frame_axis_get_minimum(y_axis);
51+ geis_device_add_attr(geis_device, geis_attr_new(GEIS_DEVICE_ATTRIBUTE_MIN_Y,
52+ GEIS_ATTR_TYPE_FLOAT,
53+ &fval));
54+
55+ fval = frame_axis_get_maximum(y_axis);
56+ geis_device_add_attr(geis_device, geis_attr_new(GEIS_DEVICE_ATTRIBUTE_MAX_Y,
57+ GEIS_ATTR_TYPE_FLOAT,
58+ &fval));
59+
60+ fval = frame_axis_get_resolution(y_axis);
61+ geis_device_add_attr(geis_device, geis_attr_new(GEIS_DEVICE_ATTRIBUTE_RES_Y,
62+ GEIS_ATTR_TYPE_FLOAT,
63+ &fval));
64+ }
65+}
66+
67+
68+/**
69 * Reports an X11 device to the front end as a GEIS device.
70 */
71 static void
72@@ -859,6 +920,8 @@
73 geis_device_add_attr(geis_device, attr);
74 }
75
76+ _gbe_add_device_axis_attributes(frame_device, geis_device);
77+
78 /* Report the device as a filterable entity. */
79 static struct GeisFilterableAttribute attrs[] = {
80 { GEIS_DEVICE_ATTRIBUTE_NAME, GEIS_ATTR_TYPE_STRING, 0, NULL },
81
82=== modified file 'testsuite/geis2/gtest_devices.cpp'
83--- testsuite/geis2/gtest_devices.cpp 2012-04-27 16:09:20 +0000
84+++ testsuite/geis2/gtest_devices.cpp 2012-04-27 16:09:20 +0000
85@@ -179,4 +179,49 @@
86 }
87
88
89+/*
90+ * Test case for lp:987539: report X and Y axis extents.
91+ *
92+ * This test creates a devicve with known X and Y extents and verifies the
93+ * extent attributes are reported with the expected values.
94+ */
95+TEST_F(GeisDeviceTests, deviceAttrs)
96+{
97+ GeisBoolean off = GEIS_FALSE;
98+ geis_set_configuration(geis_, GEIS_CONFIG_DISCARD_DEVICE_MESSAGES, &off);
99+
100+ Testsuite::EvemuDevice test_device(TEST_DEVICE_PROP_FILE);
101+ set_geis_event_handler([&](Geis, GeisEvent event)
102+ {
103+ if (geis_event_type(event) == GEIS_EVENT_DEVICE_AVAILABLE)
104+ {
105+ GeisAttr attr = geis_event_attr_by_name(event, GEIS_EVENT_ATTRIBUTE_DEVICE);
106+ EXPECT_TRUE(attr != NULL);
107+ GeisDevice device = (GeisDevice)geis_attr_value_to_pointer(attr);
108+ ASSERT_TRUE(test_device.name() == geis_device_name(device));
109+
110+ attr = geis_device_attr_by_name(device, GEIS_DEVICE_ATTRIBUTE_MIN_X);
111+ ASSERT_TRUE(attr != NULL);
112+ EXPECT_FLOAT_EQ(0.0f, geis_attr_value_to_float(attr));
113+ attr = geis_device_attr_by_name(device, GEIS_DEVICE_ATTRIBUTE_MAX_X);
114+ ASSERT_TRUE(attr != NULL);
115+ EXPECT_FLOAT_EQ(9600.0f, geis_attr_value_to_float(attr));
116+ attr = geis_device_attr_by_name(device, GEIS_DEVICE_ATTRIBUTE_RES_X);
117+ ASSERT_TRUE(attr != NULL);
118+ EXPECT_FLOAT_EQ(0.0f, geis_attr_value_to_float(attr));
119+ attr = geis_device_attr_by_name(device, GEIS_DEVICE_ATTRIBUTE_MIN_Y);
120+ ASSERT_TRUE(attr != NULL);
121+ EXPECT_FLOAT_EQ(0.0f, geis_attr_value_to_float(attr));
122+ attr = geis_device_attr_by_name(device, GEIS_DEVICE_ATTRIBUTE_MAX_Y);
123+ ASSERT_TRUE(attr != NULL);
124+ EXPECT_FLOAT_EQ(7200.0f, geis_attr_value_to_float(attr));
125+ attr = geis_device_attr_by_name(device, GEIS_DEVICE_ATTRIBUTE_RES_Y);
126+ ASSERT_TRUE(attr != NULL);
127+ EXPECT_FLOAT_EQ(0.0f, geis_attr_value_to_float(attr));
128+ }
129+ });
130+ geis_dispatch_loop();
131+}
132+
133+
134 } // anonymous namespace

Subscribers

People subscribed via source and target branches