gpointing-device-settings r202 - in trunk: src test



Author: hiikezoe
Date: Wed Mar 11 03:18:55 2009
New Revision: 202
URL: http://svn.gnome.org/viewvc/gpointing-device-settings?rev=202&view=rev

Log:
set format type mismatch error.

Modified:
   trunk/src/gpds-xinput.c
   trunk/src/gpds-xinput.h
   trunk/test/test-xinput.c

Modified: trunk/src/gpds-xinput.c
==============================================================================
--- trunk/src/gpds-xinput.c	(original)
+++ trunk/src/gpds-xinput.c	Wed Mar 11 03:18:55 2009
@@ -600,6 +600,12 @@
     }
 
     if (actual_type != float_atom) {
+        g_set_error(error,
+                    GPDS_XINPUT_ERROR,
+                    GPDS_XINPUT_ERROR_FORMAT_TYPE_MISMATCH,
+                    _("Format type is mismatched.\n%s is specified but %s returns."),
+                    gdk_x11_get_xatom_name(float_atom), 
+                    gdk_x11_get_xatom_name(actual_type));
         XFree(data);
         return FALSE;
     }

Modified: trunk/src/gpds-xinput.h
==============================================================================
--- trunk/src/gpds-xinput.h	(original)
+++ trunk/src/gpds-xinput.h	Wed Mar 11 03:18:55 2009
@@ -36,6 +36,7 @@
 typedef enum
 {
     GPDS_XINPUT_ERROR_NO_REGISTERED_PROPERTY,
+    GPDS_XINPUT_ERROR_FORMAT_TYPE_MISMATCH,
     GPDS_XINPUT_ERROR_X_ERROR
 } GpdsXInputError;
 

Modified: trunk/test/test-xinput.c
==============================================================================
--- trunk/test/test-xinput.c	(original)
+++ trunk/test/test-xinput.c	Wed Mar 11 03:18:55 2009
@@ -6,9 +6,12 @@
 void test_device_name (void);
 void test_set_int_properties_by_name (void);
 void test_set_int_properties (void);
+void test_set_float_properties (void);
 void test_register_property_entries (void);
 void test_set_int_properties_by_name_invalid_format_type (void);
 void test_set_int_properties_invalid_n_values (void);
+void test_set_float_properties_fail (void);
+void test_get_float_properties_fail (void);
 
 static GpdsXInput *xinput;
 static gint *values;
@@ -154,6 +157,45 @@
 }
 
 void
+test_set_float_properties_fail (void)
+{
+    gdouble double_value[1];
+    expected_error = g_error_new(GPDS_XINPUT_ERROR,
+                                 GPDS_XINPUT_ERROR_X_ERROR,
+                                 "An X error occurred. "
+                                 "The error was BadMatch (invalid parameter attributes).");
+
+    cut_trace(test_register_property_entries());
+
+    double_value[0] = 1.1;
+    gpds_xinput_set_float_properties(xinput,
+                                     GPDS_MOUSE_MIDDLE_BUTTON_EMULATION,
+                                     &error,
+                                     double_value,
+                                     1);
+    gcut_assert_equal_error(expected_error, error);
+}
+
+void
+test_get_float_properties_fail (void)
+{
+    gdouble *double_value;
+    expected_error = g_error_new(GPDS_XINPUT_ERROR,
+                                 GPDS_XINPUT_ERROR_FORMAT_TYPE_MISMATCH,
+                                 "Format type is mismatched.\n"
+                                 "FLOAT is specified but INTEGER returns.");
+
+    cut_trace(test_register_property_entries());
+
+    gpds_xinput_get_float_properties(xinput,
+                                     GPDS_MOUSE_MIDDLE_BUTTON_EMULATION,
+                                     &error,
+                                     &double_value,
+                                     &n_values);
+    gcut_assert_equal_error(expected_error, error);
+}
+
+void
 test_set_int_properties_invalid_n_values (void)
 {
     gint invalid_values[2];



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]