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
=== modified file 'libutouch-geis/backend/grail/geis_grail_backend.c'
--- libutouch-geis/backend/grail/geis_grail_backend.c 2012-04-24 16:09:09 +0000
+++ libutouch-geis/backend/grail/geis_grail_backend.c 2012-04-27 16:09:20 +0000
@@ -773,6 +773,67 @@
773773
774774
775/**775/**
776 * Adds the axis exten attributes for a device, if available.
777 */
778static void
779_gbe_add_device_axis_attributes(UFDevice frame_device, GeisDevice geis_device)
780{
781 UFStatus status;
782 GeisFloat fval;
783
784 UFAxis x_axis;
785 status = frame_device_get_axis_by_type(frame_device, UFAxisTypeX, &x_axis);
786 if (status != UFStatusSuccess)
787 {
788 geis_warning("failed to get X axis property from device '%s'",
789 geis_device_name(geis_device));
790 }
791 else
792 {
793 fval = frame_axis_get_minimum(x_axis);
794 geis_device_add_attr(geis_device, geis_attr_new(GEIS_DEVICE_ATTRIBUTE_MIN_X,
795 GEIS_ATTR_TYPE_FLOAT,
796 &fval));
797
798 fval = frame_axis_get_maximum(x_axis);
799 geis_device_add_attr(geis_device, geis_attr_new(GEIS_DEVICE_ATTRIBUTE_MAX_X,
800 GEIS_ATTR_TYPE_FLOAT,
801 &fval));
802
803 fval = frame_axis_get_resolution(x_axis);
804 geis_device_add_attr(geis_device, geis_attr_new(GEIS_DEVICE_ATTRIBUTE_RES_X,
805 GEIS_ATTR_TYPE_FLOAT,
806 &fval));
807 }
808
809 UFAxis y_axis;
810 status = frame_device_get_axis_by_type(frame_device, UFAxisTypeY, &y_axis);
811 if (status != UFStatusSuccess)
812 {
813 geis_warning("failed to get Y axis property from device '%s'",
814 geis_device_name(geis_device));
815 }
816 else
817 {
818 fval = frame_axis_get_minimum(y_axis);
819 geis_device_add_attr(geis_device, geis_attr_new(GEIS_DEVICE_ATTRIBUTE_MIN_Y,
820 GEIS_ATTR_TYPE_FLOAT,
821 &fval));
822
823 fval = frame_axis_get_maximum(y_axis);
824 geis_device_add_attr(geis_device, geis_attr_new(GEIS_DEVICE_ATTRIBUTE_MAX_Y,
825 GEIS_ATTR_TYPE_FLOAT,
826 &fval));
827
828 fval = frame_axis_get_resolution(y_axis);
829 geis_device_add_attr(geis_device, geis_attr_new(GEIS_DEVICE_ATTRIBUTE_RES_Y,
830 GEIS_ATTR_TYPE_FLOAT,
831 &fval));
832 }
833}
834
835
836/**
776 * Reports an X11 device to the front end as a GEIS device.837 * Reports an X11 device to the front end as a GEIS device.
777 */838 */
778static void839static void
@@ -859,6 +920,8 @@
859 geis_device_add_attr(geis_device, attr);920 geis_device_add_attr(geis_device, attr);
860 }921 }
861922
923 _gbe_add_device_axis_attributes(frame_device, geis_device);
924
862 /* Report the device as a filterable entity. */925 /* Report the device as a filterable entity. */
863 static struct GeisFilterableAttribute attrs[] = {926 static struct GeisFilterableAttribute attrs[] = {
864 { GEIS_DEVICE_ATTRIBUTE_NAME, GEIS_ATTR_TYPE_STRING, 0, NULL },927 { GEIS_DEVICE_ATTRIBUTE_NAME, GEIS_ATTR_TYPE_STRING, 0, NULL },
865928
=== modified file 'testsuite/geis2/gtest_devices.cpp'
--- testsuite/geis2/gtest_devices.cpp 2012-04-27 16:09:20 +0000
+++ testsuite/geis2/gtest_devices.cpp 2012-04-27 16:09:20 +0000
@@ -179,4 +179,49 @@
179}179}
180180
181181
182/*
183 * Test case for lp:987539: report X and Y axis extents.
184 *
185 * This test creates a devicve with known X and Y extents and verifies the
186 * extent attributes are reported with the expected values.
187 */
188TEST_F(GeisDeviceTests, deviceAttrs)
189{
190 GeisBoolean off = GEIS_FALSE;
191 geis_set_configuration(geis_, GEIS_CONFIG_DISCARD_DEVICE_MESSAGES, &off);
192
193 Testsuite::EvemuDevice test_device(TEST_DEVICE_PROP_FILE);
194 set_geis_event_handler([&](Geis, GeisEvent event)
195 {
196 if (geis_event_type(event) == GEIS_EVENT_DEVICE_AVAILABLE)
197 {
198 GeisAttr attr = geis_event_attr_by_name(event, GEIS_EVENT_ATTRIBUTE_DEVICE);
199 EXPECT_TRUE(attr != NULL);
200 GeisDevice device = (GeisDevice)geis_attr_value_to_pointer(attr);
201 ASSERT_TRUE(test_device.name() == geis_device_name(device));
202
203 attr = geis_device_attr_by_name(device, GEIS_DEVICE_ATTRIBUTE_MIN_X);
204 ASSERT_TRUE(attr != NULL);
205 EXPECT_FLOAT_EQ(0.0f, geis_attr_value_to_float(attr));
206 attr = geis_device_attr_by_name(device, GEIS_DEVICE_ATTRIBUTE_MAX_X);
207 ASSERT_TRUE(attr != NULL);
208 EXPECT_FLOAT_EQ(9600.0f, geis_attr_value_to_float(attr));
209 attr = geis_device_attr_by_name(device, GEIS_DEVICE_ATTRIBUTE_RES_X);
210 ASSERT_TRUE(attr != NULL);
211 EXPECT_FLOAT_EQ(0.0f, geis_attr_value_to_float(attr));
212 attr = geis_device_attr_by_name(device, GEIS_DEVICE_ATTRIBUTE_MIN_Y);
213 ASSERT_TRUE(attr != NULL);
214 EXPECT_FLOAT_EQ(0.0f, geis_attr_value_to_float(attr));
215 attr = geis_device_attr_by_name(device, GEIS_DEVICE_ATTRIBUTE_MAX_Y);
216 ASSERT_TRUE(attr != NULL);
217 EXPECT_FLOAT_EQ(7200.0f, geis_attr_value_to_float(attr));
218 attr = geis_device_attr_by_name(device, GEIS_DEVICE_ATTRIBUTE_RES_Y);
219 ASSERT_TRUE(attr != NULL);
220 EXPECT_FLOAT_EQ(0.0f, geis_attr_value_to_float(attr));
221 }
222 });
223 geis_dispatch_loop();
224}
225
226
182} // anonymous namespace227} // anonymous namespace

Subscribers

People subscribed via source and target branches