summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2015-02-13 21:21:46 +0100
committerBenjamin Otte <otte@redhat.com>2015-03-18 15:23:31 +0100
commit6c00eba7fbad4b4ee8a295e9826541bef48c29aa (patch)
tree84c9385e64dd3c022cf8e43389de1a87c3f05ee4 /testsuite
parentd3471508a0fbca2ebfbf8be6c71da5d4ecda2dbe (diff)
downloadgtk+-6c00eba7fbad4b4ee8a295e9826541bef48c29aa.tar.gz
testsuite: Add another random stylecontext test
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/gtk/stylecontext.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/testsuite/gtk/stylecontext.c b/testsuite/gtk/stylecontext.c
index 9ed3b58f1e..fcbc0a1612 100644
--- a/testsuite/gtk/stylecontext.c
+++ b/testsuite/gtk/stylecontext.c
@@ -307,6 +307,51 @@ G_GNUC_END_IGNORE_DEPRECATIONS
gtk_widget_destroy (window);
}
+void
+test_set_widget_path_saved (void)
+{
+ GtkWidgetPath *path;
+ GtkCssProvider *provider;
+ GtkStyleContext *context;
+ GtkBorder padding;
+
+ context = gtk_style_context_new ();
+
+ provider = gtk_css_provider_new ();
+ gtk_style_context_add_provider (context,
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_USER);
+ gtk_css_provider_load_from_data (provider,
+ "GtkWindow * { padding: 1px; }\n"
+ ".foo * { padding: 2px; }\n",
+ -1,
+ NULL);
+
+ path = gtk_widget_path_new ();
+ gtk_widget_path_append_type (path, GTK_TYPE_WINDOW);
+ gtk_style_context_set_path (context, path);
+
+ gtk_style_context_get_padding (context, gtk_style_context_get_state (context), &padding);
+ g_assert_cmpint (padding.top, ==, 0);
+
+ gtk_style_context_save (context);
+ gtk_style_context_get_padding (context, gtk_style_context_get_state (context), &padding);
+ g_assert_cmpint (padding.top, ==, 1);
+
+ gtk_widget_path_iter_add_class (path, -1, "foo");
+ gtk_style_context_set_path (context, path);
+ gtk_style_context_get_padding (context, gtk_style_context_get_state (context), &padding);
+ g_assert_cmpint (padding.top, ==, 2);
+
+ gtk_style_context_restore (context);
+ gtk_style_context_get_padding (context, gtk_style_context_get_state (context), &padding);
+ g_assert_cmpint (padding.top, ==, 0);
+
+ gtk_widget_path_free (path);
+ g_object_unref (provider);
+ g_object_unref (context);
+}
+
int
main (int argc, char *argv[])
{
@@ -318,6 +363,7 @@ main (int argc, char *argv[])
g_test_add_func ("/style/match", test_match);
g_test_add_func ("/style/basic", test_basic_properties);
g_test_add_func ("/style/invalidate-saved", test_invalidate_saved);
+ g_test_add_func ("/style/set-widget-path-saved", test_set_widget_path_saved);
return g_test_run ();
}