mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 14:10:30 +00:00
testsuite: Check more property notification
Handle more value types.
This commit is contained in:
parent
fdce10fb96
commit
4e17900b9a
@ -264,6 +264,26 @@ check_property (GObject *instance, GParamSpec *pspec)
|
|||||||
g_free (value);
|
g_free (value);
|
||||||
g_free (new_value);
|
g_free (new_value);
|
||||||
|
|
||||||
|
g_signal_handler_disconnect (instance, id);
|
||||||
|
}
|
||||||
|
else if (pspec->value_type == G_TYPE_STRV)
|
||||||
|
{
|
||||||
|
NotifyData data;
|
||||||
|
gulong id;
|
||||||
|
const char *value[] = { "bla", "bla", NULL };
|
||||||
|
|
||||||
|
data.name = pspec->name;
|
||||||
|
data.count = 0;
|
||||||
|
id = g_signal_connect (instance, "notify", G_CALLBACK (count_notify), &data);
|
||||||
|
|
||||||
|
g_object_set (instance, pspec->name, value, NULL);
|
||||||
|
assert_notifies (instance, pspec->name, data.count, 1);
|
||||||
|
|
||||||
|
value[1] = "foo";
|
||||||
|
|
||||||
|
g_object_set (instance, pspec->name, value, NULL);
|
||||||
|
assert_notifies (instance, pspec->name, data.count, 2);
|
||||||
|
|
||||||
g_signal_handler_disconnect (instance, id);
|
g_signal_handler_disconnect (instance, id);
|
||||||
}
|
}
|
||||||
else if (pspec->value_type == G_TYPE_DOUBLE)
|
else if (pspec->value_type == G_TYPE_DOUBLE)
|
||||||
@ -340,6 +360,57 @@ check_property (GObject *instance, GParamSpec *pspec)
|
|||||||
assert_notifies (instance, pspec->name, data.count, current_count);
|
assert_notifies (instance, pspec->name, data.count, current_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_signal_handler_disconnect (instance, id);
|
||||||
|
}
|
||||||
|
else if (pspec->value_type == G_TYPE_LIST_MODEL)
|
||||||
|
{
|
||||||
|
NotifyData data;
|
||||||
|
gulong id;
|
||||||
|
GListStore *value;
|
||||||
|
|
||||||
|
data.name = pspec->name;
|
||||||
|
data.count = 0;
|
||||||
|
id = g_signal_connect (instance, "notify", G_CALLBACK (count_notify), &data);
|
||||||
|
|
||||||
|
value = g_list_store_new (GTK_TYPE_WIDGET);
|
||||||
|
|
||||||
|
g_object_set (instance, pspec->name, value, NULL);
|
||||||
|
assert_notifies (instance, pspec->name, data.count, 1);
|
||||||
|
|
||||||
|
g_object_set (instance, pspec->name, value, NULL);
|
||||||
|
assert_notifies (instance, pspec->name, data.count, 1);
|
||||||
|
|
||||||
|
g_object_set (instance, pspec->name, NULL, NULL);
|
||||||
|
assert_notifies (instance, pspec->name, data.count, 2);
|
||||||
|
|
||||||
|
g_object_unref (value);
|
||||||
|
|
||||||
|
g_signal_handler_disconnect (instance, id);
|
||||||
|
}
|
||||||
|
else if (pspec->value_type == GTK_TYPE_ADJUSTMENT)
|
||||||
|
{
|
||||||
|
NotifyData data;
|
||||||
|
gulong id;
|
||||||
|
GtkAdjustment *value;
|
||||||
|
|
||||||
|
data.name = pspec->name;
|
||||||
|
data.count = 0;
|
||||||
|
id = g_signal_connect (instance, "notify", G_CALLBACK (count_notify), &data);
|
||||||
|
|
||||||
|
value = gtk_adjustment_new (100, 0, 200, 1, 1, 10);
|
||||||
|
g_object_ref_sink (value);
|
||||||
|
|
||||||
|
g_object_set (instance, pspec->name, value, NULL);
|
||||||
|
assert_notifies (instance, pspec->name, data.count, 1);
|
||||||
|
|
||||||
|
g_object_set (instance, pspec->name, value, NULL);
|
||||||
|
assert_notifies (instance, pspec->name, data.count, 1);
|
||||||
|
|
||||||
|
g_object_set (instance, pspec->name, NULL, NULL);
|
||||||
|
assert_notifies (instance, pspec->name, data.count, 2);
|
||||||
|
|
||||||
|
g_object_unref (value);
|
||||||
|
|
||||||
g_signal_handler_disconnect (instance, id);
|
g_signal_handler_disconnect (instance, id);
|
||||||
}
|
}
|
||||||
else if (pspec->value_type == GTK_TYPE_WIDGET)
|
else if (pspec->value_type == GTK_TYPE_WIDGET)
|
||||||
@ -353,6 +424,7 @@ check_property (GObject *instance, GParamSpec *pspec)
|
|||||||
id = g_signal_connect (instance, "notify", G_CALLBACK (count_notify), &data);
|
id = g_signal_connect (instance, "notify", G_CALLBACK (count_notify), &data);
|
||||||
|
|
||||||
value = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
value = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||||
|
g_object_ref_sink (value);
|
||||||
|
|
||||||
g_object_set (instance, pspec->name, value, NULL);
|
g_object_set (instance, pspec->name, value, NULL);
|
||||||
assert_notifies (instance, pspec->name, data.count, 1);
|
assert_notifies (instance, pspec->name, data.count, 1);
|
||||||
@ -363,6 +435,8 @@ check_property (GObject *instance, GParamSpec *pspec)
|
|||||||
g_object_set (instance, pspec->name, NULL, NULL);
|
g_object_set (instance, pspec->name, NULL, NULL);
|
||||||
assert_notifies (instance, pspec->name, data.count, 2);
|
assert_notifies (instance, pspec->name, data.count, 2);
|
||||||
|
|
||||||
|
g_object_unref (value);
|
||||||
|
|
||||||
g_signal_handler_disconnect (instance, id);
|
g_signal_handler_disconnect (instance, id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -536,6 +610,7 @@ test_type (gconstpointer data)
|
|||||||
if (g_type_is_a (pspec->owner_type, GTK_TYPE_WIDGET) &&
|
if (g_type_is_a (pspec->owner_type, GTK_TYPE_WIDGET) &&
|
||||||
(g_str_equal (pspec->name, "has-focus") ||
|
(g_str_equal (pspec->name, "has-focus") ||
|
||||||
g_str_equal (pspec->name, "has-default") ||
|
g_str_equal (pspec->name, "has-default") ||
|
||||||
|
g_str_equal (pspec->name, "focus-widget") ||
|
||||||
g_str_equal (pspec->name, "is-focus") ||
|
g_str_equal (pspec->name, "is-focus") ||
|
||||||
g_str_equal (pspec->name, "hexpand") ||
|
g_str_equal (pspec->name, "hexpand") ||
|
||||||
g_str_equal (pspec->name, "vexpand") ||
|
g_str_equal (pspec->name, "vexpand") ||
|
||||||
@ -566,12 +641,12 @@ test_type (gconstpointer data)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Too many special cases involving -set properties */
|
/* Too many special cases involving -set properties */
|
||||||
if (g_str_equal (g_type_name (pspec->owner_type), "GtkCellRendererText") ||
|
if (pspec->owner_type == GTK_TYPE_CELL_RENDERER_TEXT ||
|
||||||
g_str_equal (g_type_name (pspec->owner_type), "GtkTextTag"))
|
pspec->owner_type == GTK_TYPE_TEXT_TAG)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Most things assume a model is set */
|
/* Most things assume a model is set */
|
||||||
if (g_str_equal (g_type_name (pspec->owner_type), "GtkComboBox"))
|
if (pspec->owner_type == GTK_TYPE_COMBO_BOX)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Can only be set on unmapped windows */
|
/* Can only be set on unmapped windows */
|
||||||
@ -579,13 +654,6 @@ test_type (gconstpointer data)
|
|||||||
g_str_equal (pspec->name, "type-hint"))
|
g_str_equal (pspec->name, "type-hint"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Special restrictions on allowed values */
|
|
||||||
if (pspec->owner_type == GTK_TYPE_COMBO_BOX &&
|
|
||||||
(g_str_equal (pspec->name, "id-column") ||
|
|
||||||
g_str_equal (pspec->name, "active-id") ||
|
|
||||||
g_str_equal (pspec->name, "entry-text-column")))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (pspec->owner_type == GTK_TYPE_ENTRY_COMPLETION &&
|
if (pspec->owner_type == GTK_TYPE_ENTRY_COMPLETION &&
|
||||||
g_str_equal (pspec->name, "text-column"))
|
g_str_equal (pspec->name, "text-column"))
|
||||||
continue;
|
continue;
|
||||||
@ -681,14 +749,21 @@ test_type (gconstpointer data)
|
|||||||
g_str_equal (pspec->name, "position"))
|
g_str_equal (pspec->name, "position"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* This one is special */
|
|
||||||
if (g_str_equal (pspec->name, "focus-widget"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (pspec->owner_type == GTK_TYPE_TREE_VIEW_COLUMN &&
|
if (pspec->owner_type == GTK_TYPE_TREE_VIEW_COLUMN &&
|
||||||
g_str_equal (pspec->name, "widget"))
|
g_str_equal (pspec->name, "widget"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* Interface does not do explicit notify, so we can't fix it */
|
||||||
|
if (pspec->owner_type == GTK_TYPE_SCROLLABLE &&
|
||||||
|
(g_str_equal (pspec->name, "hadjustment") ||
|
||||||
|
g_str_equal (pspec->name, "vadjustment")))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* deprecated, not getting fixed */
|
||||||
|
if (pspec->owner_type == GTK_TYPE_CELL_RENDERER_SPIN &&
|
||||||
|
g_str_equal (pspec->name, "adjustment"))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (g_test_verbose ())
|
if (g_test_verbose ())
|
||||||
g_print ("Property %s.%s\n", g_type_name (pspec->owner_type), pspec->name);
|
g_print ("Property %s.%s\n", g_type_name (pspec->owner_type), pspec->name);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user