X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Ftests%2Fgdbus-test-codegen.c;h=62c17e08d987211530b2038c1cef3de57b37b14b;hb=2a53b4d0e2c98a14aedf31e38f0ad1fb2e8fe26f;hp=5eb175f7cd26d615fd7e7a2655587fe11581a466;hpb=415a8d81f6fc52d7314517f36bd03f0cbad27dd5;p=platform%2Fupstream%2Fglib.git diff --git a/gio/tests/gdbus-test-codegen.c b/gio/tests/gdbus-test-codegen.c index 5eb175f..62c17e0 100644 --- a/gio/tests/gdbus-test-codegen.c +++ b/gio/tests/gdbus-test-codegen.c @@ -13,9 +13,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. + * Public License along with this library; if not, see . * * Author: David Zeuthen */ @@ -93,7 +91,7 @@ on_handle_hello_world (FooiGenBar *object, gpointer user_data) { gchar *response; - response = g_strdup_printf ("Word! You said `%s'. I'm Skeleton, btw!", greeting); + response = g_strdup_printf ("Word! You said '%s'. I'm Skeleton, btw!", greeting); foo_igen_bar_complete_hello_world (object, invocation, response); g_free (response); return TRUE; @@ -120,7 +118,7 @@ on_handle_test_primitive_types (FooiGenBar *object, gchar *s1; gchar *s2; gchar *s3; - s1 = g_strdup_printf ("Word! You said `%s'. Rock'n'roll!", val_string); + s1 = g_strdup_printf ("Word! You said '%s'. Rock'n'roll!", val_string); s2 = g_strdup_printf ("/modified%s", val_objpath); s3 = g_strdup_printf ("assgit%s", val_signature); foo_igen_bar_complete_test_primitive_types (object, @@ -699,6 +697,10 @@ static void check_bar_proxy (FooiGenBar *proxy, GMainLoop *thread_loop) { + const gchar *array_of_strings[3] = {"one", "two", NULL}; + const gchar *array_of_strings_2[3] = {"one2", "two2", NULL}; + const gchar *array_of_objpaths[3] = {"/one", "/one/two", NULL}; + const gchar *array_of_bytestrings[3] = {"one\xff", "two\xff", NULL}; guchar ret_val_byte; gboolean ret_val_boolean; gint16 ret_val_int16; @@ -744,6 +746,9 @@ check_bar_proxy (FooiGenBar *proxy, gchar *val_finally_normal_name; GVariant *v; gchar *s; + const gchar *const *read_as; + const gchar *const *read_as2; + const gchar *const *read_as3; data = g_new0 (ClientData, 1); data->thread_loop = thread_loop; @@ -838,10 +843,6 @@ check_bar_proxy (FooiGenBar *proxy, /* Try setting properties that requires memory management. This * is to exercise the paths that frees the references. */ - const gchar *array_of_strings[3] = {"one", "two", NULL}; - const gchar *array_of_strings_2[3] = {"one2", "two2", NULL}; - const gchar *array_of_objpaths[3] = {"/one", "/one/two", NULL}; - const gchar *array_of_bytestrings[3] = {"one\xff", "two\xff", NULL}; g_object_set (proxy, "s", "a string", @@ -939,9 +940,6 @@ check_bar_proxy (FooiGenBar *proxy, * updates on them works as well (See comment for "property vfuncs" * in gio/gdbus-codegen/codegen.py for details) */ - const gchar *const *read_as; - const gchar *const *read_as2; - const gchar *const *read_as3; read_as = foo_igen_bar_get_as (proxy); read_as2 = foo_igen_bar_get_as (proxy); g_assert_cmpint (g_strv_length ((gchar **) read_as), ==, 2); @@ -964,7 +962,7 @@ check_bar_proxy (FooiGenBar *proxy, * properties. * * On the first reception, y and i should both be increased by - * two. On the the second reception, only by one. The signal handler + * two. On the second reception, only by one. The signal handler * checks this. * * This also checks that _drain_notify() works. @@ -1730,10 +1728,23 @@ on_object_proxy_removed (GDBusObjectManagerClient *manager, } static void +property_d_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data) +{ + gboolean *changed = user_data; + + *changed = TRUE; +} + +static void om_check_property_and_signal_emission (GMainLoop *loop, FooiGenBar *skeleton, FooiGenBar *proxy) { + gboolean d_changed = FALSE; + guint handler; + /* First PropertiesChanged */ g_assert_cmpint (foo_igen_bar_get_i (skeleton), ==, 0); g_assert_cmpint (foo_igen_bar_get_i (proxy), ==, 0); @@ -1742,6 +1753,24 @@ om_check_property_and_signal_emission (GMainLoop *loop, g_assert_cmpint (foo_igen_bar_get_i (skeleton), ==, 1); g_assert_cmpint (foo_igen_bar_get_i (proxy), ==, 1); + /* Double-check the gdouble case */ + g_assert_cmpfloat (foo_igen_bar_get_d (skeleton), ==, 0.0); + g_assert_cmpfloat (foo_igen_bar_get_d (proxy), ==, 0.0); + foo_igen_bar_set_d (skeleton, 1.0); + _g_assert_property_notify (proxy, "d"); + + /* Verify that re-setting it to the same value doesn't cause a + * notify on the proxy, by taking advantage of the fact that + * notifications are serialized. + */ + handler = g_signal_connect (proxy, "notify::d", + G_CALLBACK (property_d_changed), &d_changed); + foo_igen_bar_set_d (skeleton, 1.0); + foo_igen_bar_set_i (skeleton, 2); + _g_assert_property_notify (proxy, "i"); + g_assert (d_changed == FALSE); + g_signal_handler_disconnect (proxy, handler); + /* Then just a regular signal */ foo_igen_bar_emit_another_signal (skeleton, "word"); _g_assert_signal_received (proxy, "another-signal"); @@ -1837,7 +1866,7 @@ check_object_manager (void) om_check_get_all (c, loop, "(@a{oa{sa{sv}}} {},)"); - /* Now try to create the the proxy manager again - this time it should work */ + /* Now try to create the proxy manager again - this time it should work */ error = NULL; foo_igen_object_manager_client_new (c, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, @@ -2290,25 +2319,43 @@ test_interface_stability (void) /* ---------------------------------------------------------------------------------------------------- */ +/* property naming + * + * - check that a property with name "Type" is mapped into g-name "type" + * with C accessors get_type_ (to avoid clashing with the GType accessor) + * and set_type_ (for symmetri) + * (see https://bugzilla.gnome.org/show_bug.cgi?id=679473 for details) + * + * - (could add more tests here) + */ + +static void +test_property_naming (void) +{ + gpointer c_getter_name = foo_igen_naming_get_type_; + gpointer c_setter_name = foo_igen_naming_set_type_; + FooiGenNaming *skel; + + (void) c_getter_name; + (void) c_setter_name; + + skel = foo_igen_naming_skeleton_new (); + g_assert (g_object_class_find_property (G_OBJECT_GET_CLASS (skel), "type") != NULL); + g_object_unref (skel); +} + +/* ---------------------------------------------------------------------------------------------------- */ + int main (int argc, char *argv[]) { - gint ret; - - g_type_init (); g_test_init (&argc, &argv, NULL); - session_bus_up (); - g_test_add_func ("/gdbus/codegen/annotations", test_annotations); g_test_add_func ("/gdbus/codegen/interface_stability", test_interface_stability); g_test_add_func ("/gdbus/codegen/object-manager", test_object_manager); + g_test_add_func ("/gdbus/codegen/property-naming", test_property_naming); - ret = g_test_run(); - - /* tear down bus */ - session_bus_down (); - - return ret; + return session_bus_run (); }