2015-10-28 18:35:23 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
static void
|
|
|
|
assert_section_is_not_null (GtkCssProvider *provider,
|
|
|
|
GtkCssSection *section,
|
|
|
|
const GError *error,
|
|
|
|
gpointer unused)
|
|
|
|
{
|
|
|
|
g_assert (section != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_section_in_load_from_data (void)
|
|
|
|
{
|
|
|
|
GtkCssProvider *provider;
|
|
|
|
|
|
|
|
provider = gtk_css_provider_new ();
|
|
|
|
g_signal_connect (provider, "parsing-error",
|
|
|
|
G_CALLBACK (assert_section_is_not_null), NULL);
|
2016-10-17 14:09:12 +00:00
|
|
|
gtk_css_provider_load_from_data (provider, "random garbage goes here", -1);
|
2015-10-28 18:35:23 +00:00
|
|
|
g_object_unref (provider);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_section_in_style_property (void)
|
|
|
|
{
|
|
|
|
GtkCssProvider *provider;
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
GtkWidgetPath *path;
|
|
|
|
GParamSpec *pspec;
|
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
|
|
|
|
provider = gtk_css_provider_new ();
|
|
|
|
g_signal_connect (provider, "parsing-error",
|
|
|
|
G_CALLBACK (assert_section_is_not_null), NULL);
|
2017-01-08 12:10:43 +00:00
|
|
|
gtk_css_provider_load_from_data (provider, "* { -GtkScrollbar::has-backward-stepper random garbage goes here; }", -1);
|
2015-10-28 18:35:23 +00:00
|
|
|
|
2017-01-08 12:10:43 +00:00
|
|
|
widget_class = g_type_class_ref (GTK_TYPE_SCROLLBAR);
|
|
|
|
pspec = gtk_widget_class_find_style_property (widget_class, "has-backward-stepper");
|
2015-10-28 18:35:23 +00:00
|
|
|
g_assert (pspec);
|
|
|
|
path = gtk_widget_path_new ();
|
2017-01-08 12:10:43 +00:00
|
|
|
gtk_widget_path_append_type (path, GTK_TYPE_SCROLLBAR);
|
2015-10-28 18:35:23 +00:00
|
|
|
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
|
|
|
gtk_style_provider_get_style_property (GTK_STYLE_PROVIDER (provider), path, 0, pspec, &value);
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
|
|
|
|
|
|
|
gtk_widget_path_unref (path);
|
|
|
|
g_type_class_unref (widget_class);
|
|
|
|
g_object_unref (provider);
|
|
|
|
}
|
|
|
|
|
2015-11-16 16:36:50 +00:00
|
|
|
static void
|
|
|
|
test_section_load_nonexisting_file (void)
|
|
|
|
{
|
|
|
|
GtkCssProvider *provider;
|
|
|
|
|
|
|
|
provider = gtk_css_provider_new ();
|
|
|
|
g_signal_connect (provider, "parsing-error",
|
|
|
|
G_CALLBACK (assert_section_is_not_null), NULL);
|
2016-10-17 14:09:12 +00:00
|
|
|
gtk_css_provider_load_from_path (provider, "this/path/does/absolutely/not/exist.css");
|
2015-11-16 16:36:50 +00:00
|
|
|
g_object_unref (provider);
|
|
|
|
}
|
|
|
|
|
2015-10-28 18:35:23 +00:00
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
2016-12-28 13:53:22 +00:00
|
|
|
gtk_init ();
|
2015-10-28 18:35:23 +00:00
|
|
|
g_test_init (&argc, &argv, NULL);
|
|
|
|
|
|
|
|
g_test_add_func ("/cssprovider/section-in-load-from-data", test_section_in_load_from_data);
|
|
|
|
g_test_add_func ("/cssprovider/section-in-style-property", test_section_in_style_property);
|
2015-11-16 16:36:50 +00:00
|
|
|
g_test_add_func ("/cssprovider/load-nonexisting-file", test_section_load_nonexisting_file);
|
2015-10-28 18:35:23 +00:00
|
|
|
|
|
|
|
return g_test_run ();
|
|
|
|
}
|