summaryrefslogtreecommitdiff
path: root/gobject
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2013-05-03 16:44:36 -0700
committerEmmanuele Bassi <ebassi@gnome.org>2013-06-12 11:24:55 +0100
commit910732ea7e6e4eaf42a33c32d25899b10afefa81 (patch)
tree7c4a1ffc5d0507670023f2555ba4ec406c7cf01c /gobject
parentd1959e4faae93bbe22bb95c99850b515611cb578 (diff)
tests/binding: Ensure that the binding goes away
Use weak pointers so that we can check that the GBinding instance goes away when it should. https://bugzilla.gnome.org/show_bug.cgi?id=698018
Diffstat (limited to 'gobject')
-rw-r--r--gobject/tests/binding.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/gobject/tests/binding.c b/gobject/tests/binding.c
index 9eba7b5b0..1b4536702 100644
--- a/gobject/tests/binding.c
+++ b/gobject/tests/binding.c
@@ -290,6 +290,7 @@ binding_default (void)
target, "bar",
G_BINDING_DEFAULT);
+ g_object_add_weak_pointer (G_OBJECT (binding), (gpointer *) &binding);
g_assert ((BindingSource *) g_binding_get_source (binding) == source);
g_assert ((BindingTarget *) g_binding_get_target (binding) == target);
g_assert_cmpstr (g_binding_get_source_property (binding), ==, "foo");
@@ -309,6 +310,7 @@ binding_default (void)
g_object_unref (source);
g_object_unref (target);
+ g_assert (binding == NULL);
}
static void
@@ -321,6 +323,7 @@ binding_bidirectional (void)
binding = g_object_bind_property (source, "foo",
target, "bar",
G_BINDING_BIDIRECTIONAL);
+ g_object_add_weak_pointer (G_OBJECT (binding), (gpointer *) &binding);
g_object_set (source, "foo", 42, NULL);
g_assert_cmpint (source->foo, ==, target->bar);
@@ -335,6 +338,7 @@ binding_bidirectional (void)
g_object_unref (source);
g_object_unref (target);
+ g_assert (binding == NULL);
}
static void
@@ -359,6 +363,8 @@ binding_transform_default (void)
target, "value",
G_BINDING_BIDIRECTIONAL);
+ g_object_add_weak_pointer (G_OBJECT (binding), (gpointer *) &binding);
+
g_object_get (binding,
"source", &src,
"source-property", &src_prop,
@@ -384,6 +390,7 @@ binding_transform_default (void)
g_object_unref (target);
g_object_unref (source);
+ g_assert (binding == NULL);
}
static void
@@ -457,7 +464,10 @@ binding_chain (void)
/* A -> B, B -> C */
binding_1 = g_object_bind_property (a, "foo", b, "foo", G_BINDING_BIDIRECTIONAL);
+ g_object_add_weak_pointer (G_OBJECT (binding_1), (gpointer *) &binding_1);
+
binding_2 = g_object_bind_property (b, "foo", c, "foo", G_BINDING_BIDIRECTIONAL);
+ g_object_add_weak_pointer (G_OBJECT (binding_2), (gpointer *) &binding_2);
/* verify the chain */
g_object_set (a, "foo", 42, NULL);
@@ -466,7 +476,9 @@ binding_chain (void)
/* unbind A -> B and B -> C */
g_object_unref (binding_1);
+ g_assert (binding_1 == NULL);
g_object_unref (binding_2);
+ g_assert (binding_2 == NULL);
/* bind A -> C directly */
binding_2 = g_object_bind_property (a, "foo", c, "foo", G_BINDING_BIDIRECTIONAL);
@@ -554,11 +566,12 @@ binding_same_object (void)
"foo", 100,
"bar", 50,
NULL);
- GBinding *binding G_GNUC_UNUSED;
+ GBinding *binding;
binding = g_object_bind_property (source, "foo",
source, "bar",
G_BINDING_BIDIRECTIONAL);
+ g_object_add_weak_pointer (G_OBJECT (binding), (gpointer *) &binding);
g_object_set (source, "foo", 10, NULL);
g_assert_cmpint (source->foo, ==, 10);
@@ -568,6 +581,7 @@ binding_same_object (void)
g_assert_cmpint (source->bar, ==, 30);
g_object_unref (source);
+ g_assert (binding == NULL);
}
static void
@@ -582,7 +596,6 @@ binding_unbind (void)
G_BINDING_DEFAULT);
g_object_add_weak_pointer (G_OBJECT (binding), (gpointer *) &binding);
-
g_object_set (source, "foo", 42, NULL);
g_assert_cmpint (source->foo, ==, target->bar);