1 #include <gtk/gtk.h>
2 
3 typedef struct {
4   GtkStyleContext *context;
5   GtkCssProvider  *blue_provider;
6   GtkCssProvider  *red_provider;
7   GtkCssProvider  *green_provider;
8 } PrioritiesFixture;
9 
10 static void
test_parse_selectors(void)11 test_parse_selectors (void)
12 {
13   GtkCssProvider *provider;
14   GError *error;
15   gboolean res;
16   gint i;
17   const gchar *valid[] = {
18     "* {}",
19     "E {}",
20     "E F {}",
21     "E > F {}",
22     "E + F {}",
23     "E#id {}",
24     "#id {}",
25     "tab:first-child {}",
26     "tab:last-child {}",
27     "tab:nth-child(first) {}",
28     "tab:nth-child(last) {}",
29     "tab:nth-child(even) {}",
30     "tab:nth-child(odd) {}",
31     "tab:sorted {}",
32     ".some-class {}",
33     ".some-class.another-class {}",
34     ".some-class .another-class {}",
35     "E * {}",
36     "E .class {}",
37     "E > .foo {}",
38     "E > #id {}",
39     "E:active {}",
40     "E:hover {}",
41     "E:selected {}",
42     "E:disabled {}",
43     "E:indeterminate {}",
44     "E:focus {}",
45     "E:active:hover {}",
46     "* > .notebook tab:first-child .label:focus {}",
47     "E, F {}",
48     "E, F /* comment here */ {}",
49     "E,/* comment here */ F {}",
50     "E1.e1_2 #T3_4 {}",
51     "E:first-child {}",
52     "E:last-child {}",
53     "E:nth-child(first) {}",
54     "E:nth-child(last) {}",
55     "E:nth-child(even) {}",
56     "E:nth-child(odd) {}",
57     "E:focus tab {}",
58      NULL
59   };
60 
61   error = NULL;
62   for (i = 0; valid[i]; i++)
63     {
64       provider = gtk_css_provider_new ();
65       res = gtk_css_provider_load_from_data (provider, valid[i], -1, &error);
66       if (error)
67         g_print ("parsing '%s': got unexpected error: %s\n", valid[i], error->message);
68       g_assert_no_error (error);
69       g_assert (res);
70 
71       g_object_unref (provider);
72    }
73 }
74 
75 static void
test_path(void)76 test_path (void)
77 {
78   GtkWidgetPath *path;
79   GtkWidgetPath *path2;
80   gint pos;
81   GtkRegionFlags flags;
82 
83   path = gtk_widget_path_new ();
84   g_assert_cmpint (gtk_widget_path_length (path), ==, 0);
85 
86   pos = gtk_widget_path_append_type (path, GTK_TYPE_WINDOW);
87   g_assert_cmpint (pos, ==, 0);
88   g_assert_cmpint (gtk_widget_path_length (path), ==, 1);
89   g_assert (gtk_widget_path_iter_get_object_type (path, 0) == GTK_TYPE_WINDOW);
90   g_assert (gtk_widget_path_is_type (path, GTK_TYPE_WIDGET));
91   g_assert (gtk_widget_path_iter_get_name (path, 0) == NULL);
92 
93   pos = gtk_widget_path_append_type (path, GTK_TYPE_WIDGET);
94   g_assert_cmpint (pos, ==, 1);
95   g_assert_cmpint (gtk_widget_path_length (path), ==, 2);
96   gtk_widget_path_iter_set_object_type (path, pos, GTK_TYPE_BUTTON);
97   g_assert (gtk_widget_path_is_type (path, GTK_TYPE_BUTTON));
98   g_assert (gtk_widget_path_has_parent (path, GTK_TYPE_WIDGET));
99   g_assert (gtk_widget_path_has_parent (path, GTK_TYPE_WINDOW));
100   g_assert (!gtk_widget_path_has_parent (path, GTK_TYPE_DIALOG));
101   g_assert (gtk_widget_path_iter_get_name (path, 1) == NULL);
102 
103   gtk_widget_path_iter_set_name (path, 1, "name");
104   g_assert (gtk_widget_path_iter_has_name (path, 1, "name"));
105 
106   gtk_widget_path_iter_add_class (path, 1, "class1");
107   gtk_widget_path_iter_add_class (path, 1, "class2");
108   g_assert (gtk_widget_path_iter_has_class (path, 1, "class1"));
109   g_assert (gtk_widget_path_iter_has_class (path, 1, "class2"));
110   g_assert (!gtk_widget_path_iter_has_class (path, 1, "class3"));
111 
112   path2 = gtk_widget_path_copy (path);
113   g_assert (gtk_widget_path_iter_has_class (path2, 1, "class1"));
114   g_assert (gtk_widget_path_iter_has_class (path2, 1, "class2"));
115   g_assert (!gtk_widget_path_iter_has_class (path2, 1, "class3"));
116   gtk_widget_path_free (path2);
117 
118   gtk_widget_path_iter_remove_class (path, 1, "class2");
119   g_assert (gtk_widget_path_iter_has_class (path, 1, "class1"));
120   g_assert (!gtk_widget_path_iter_has_class (path, 1, "class2"));
121   gtk_widget_path_iter_clear_classes (path, 1);
122   g_assert (!gtk_widget_path_iter_has_class (path, 1, "class1"));
123 
124 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
125   gtk_widget_path_iter_add_region (path, 1, "tab", 0);
126   gtk_widget_path_iter_add_region (path, 1, "title", GTK_REGION_EVEN | GTK_REGION_FIRST);
127 
128   g_assert (gtk_widget_path_iter_has_region (path, 1, "tab", &flags) &&
129             flags == 0);
130   g_assert (gtk_widget_path_iter_has_region (path, 1, "title", &flags) &&
131             flags == (GTK_REGION_EVEN | GTK_REGION_FIRST));
132   g_assert (!gtk_widget_path_iter_has_region (path, 1, "extension", NULL));
133 
134   path2 = gtk_widget_path_copy (path);
135   g_assert (gtk_widget_path_iter_has_region (path2, 1, "tab", &flags) &&
136             flags == 0);
137   g_assert (gtk_widget_path_iter_has_region (path2, 1, "title", &flags) &&
138             flags == (GTK_REGION_EVEN | GTK_REGION_FIRST));
139   g_assert (!gtk_widget_path_iter_has_region (path2, 1, "extension", NULL));
140 G_GNUC_END_IGNORE_DEPRECATIONS
141 
142   gtk_widget_path_free (path2);
143 
144   gtk_widget_path_free (path);
145 }
146 
147 static void
test_match(void)148 test_match (void)
149 {
150   GtkStyleContext *context;
151   GtkWidgetPath *path;
152   GtkCssProvider *provider;
153   GError *error;
154   const gchar *data;
155   GdkRGBA color;
156   GdkRGBA expected;
157 
158   error = NULL;
159   provider = gtk_css_provider_new ();
160 
161   gdk_rgba_parse (&expected, "#fff");
162 
163   context = gtk_style_context_new ();
164 
165   path = gtk_widget_path_new ();
166   gtk_widget_path_append_type (path, GTK_TYPE_WINDOW);
167   gtk_widget_path_append_type (path, GTK_TYPE_BOX);
168   gtk_widget_path_append_type (path, GTK_TYPE_BUTTON);
169   gtk_widget_path_iter_set_object_name (path, 0, "window");
170   gtk_widget_path_iter_set_name (path, 0, "mywindow");
171   gtk_widget_path_iter_set_object_name (path, 2, "button");
172   gtk_widget_path_iter_add_class (path, 2, "button");
173   gtk_widget_path_iter_set_state (path, 0, GTK_STATE_FLAG_ACTIVE);
174   gtk_style_context_set_path (context, path);
175   gtk_widget_path_free (path);
176 
177   gtk_style_context_add_provider (context,
178                                   GTK_STYLE_PROVIDER (provider),
179                                   GTK_STYLE_PROVIDER_PRIORITY_USER);
180 
181   data = "* { color: #fff }";
182   gtk_css_provider_load_from_data (provider, data, -1, &error);
183   g_assert_no_error (error);
184   gtk_style_context_get_color (context, gtk_style_context_get_state (context), &color);
185   g_assert (gdk_rgba_equal (&color, &expected));
186 
187   data = "* { color: #f00 }\n"
188          "button { color: #fff }";
189   gtk_css_provider_load_from_data (provider, data, -1, &error);
190   g_assert_no_error (error);
191   gtk_style_context_get_color (context, gtk_style_context_get_state (context), &color);
192   g_assert (gdk_rgba_equal (&color, &expected));
193 
194   data = "* { color: #f00 }\n"
195          "button { color: #fff }\n"
196          "window > button { color: #000 }";
197   gtk_css_provider_load_from_data (provider, data, -1, &error);
198   g_assert_no_error (error);
199   gtk_style_context_get_color (context, gtk_style_context_get_state (context), &color);
200   g_assert (gdk_rgba_equal (&color, &expected));
201 
202   data = "* { color: #f00 }\n"
203          ".button { color: #fff }";
204   gtk_css_provider_load_from_data (provider, data, -1, &error);
205   g_assert_no_error (error);
206   gtk_style_context_get_color (context, gtk_style_context_get_state (context), &color);
207   g_assert (gdk_rgba_equal (&color, &expected));
208 
209   data = "* { color: #f00 }\n"
210          "button { color: #000 }\n"
211          ".button { color: #fff }";
212   gtk_css_provider_load_from_data (provider, data, -1, &error);
213   g_assert_no_error (error);
214   gtk_style_context_get_color (context, gtk_style_context_get_state (context), &color);
215   g_assert (gdk_rgba_equal (&color, &expected));
216 
217   data = "* { color: #f00 }\n"
218          "button { color: #000 }\n"
219          "window button { color: #fff }";
220   gtk_css_provider_load_from_data (provider, data, -1, &error);
221   g_assert_no_error (error);
222   gtk_style_context_get_color (context, gtk_style_context_get_state (context), &color);
223   g_assert (gdk_rgba_equal (&color, &expected));
224 
225   data = "* { color: #f00 }\n"
226          ".button { color: #000 }\n"
227          "window .button { color: #fff }";
228   gtk_css_provider_load_from_data (provider, data, -1, &error);
229   g_assert_no_error (error);
230   gtk_style_context_get_color (context, gtk_style_context_get_state (context), &color);
231   g_assert (gdk_rgba_equal (&color, &expected));
232 
233   data = "* { color: #f00 }\n"
234          "* .button { color: #000 }\n"
235          "#mywindow .button { color: #fff }";
236   gtk_css_provider_load_from_data (provider, data, -1, &error);
237   g_assert_no_error (error);
238   gtk_style_context_get_color (context, gtk_style_context_get_state (context), &color);
239   g_assert (gdk_rgba_equal (&color, &expected));
240 
241   data = "* { color: #f00 }\n"
242          "window .button { color: #000 }\n"
243          "window#mywindow .button { color: #fff }";
244   gtk_css_provider_load_from_data (provider, data, -1, &error);
245   g_assert_no_error (error);
246   gtk_style_context_get_color (context, gtk_style_context_get_state (context), &color);
247   g_assert (gdk_rgba_equal (&color, &expected));
248 
249   data = "* { color: #f00 }\n"
250          "window .button { color: #000 }\n"
251          "window button.button { color: #fff }";
252   gtk_css_provider_load_from_data (provider, data, -1, &error);
253   g_assert_no_error (error);
254   gtk_style_context_get_color (context, gtk_style_context_get_state (context), &color);
255   g_assert (gdk_rgba_equal (&color, &expected));
256 
257   data = "* { color: #f00 }\n"
258          "window:backdrop .button { color: #000 }\n"
259          "window .button { color: #111 }\n"
260          "window:active .button { color: #fff }";
261   gtk_css_provider_load_from_data (provider, data, -1, &error);
262   g_assert_no_error (error);
263   gtk_style_context_get_color (context, gtk_style_context_get_state (context), &color);
264   g_assert (gdk_rgba_equal (&color, &expected));
265 
266   g_object_unref (provider);
267   g_object_unref (context);
268 }
269 
270 static void
test_basic_properties(void)271 test_basic_properties (void)
272 {
273   GtkStyleContext *context;
274   GtkWidgetPath *path;
275   GdkRGBA *color;
276   GdkRGBA *bg_color;
277   PangoFontDescription *font;
278 
279   context = gtk_style_context_new ();
280   path = gtk_widget_path_new ();
281   gtk_style_context_set_path (context, path);
282   gtk_widget_path_free (path);
283 
284   gtk_style_context_get (context, gtk_style_context_get_state (context),
285                          "color", &color,
286                          "background-color", &bg_color,
287                          "font", &font,
288                          NULL);
289   g_assert (color != NULL);
290   g_assert (bg_color != NULL);
291   g_assert (font != NULL);
292 
293   gdk_rgba_free (color);
294   gdk_rgba_free (bg_color);
295   pango_font_description_free (font);
296 
297   g_object_unref (context);
298 }
299 
300 void
test_invalidate_saved(void)301 test_invalidate_saved (void)
302 {
303   GtkWidget *window;
304   GtkStyleContext *context;
305 
306   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
307 
308   context = gtk_widget_get_style_context (window);
309   gtk_style_context_save (context);
310 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
311   gtk_style_context_invalidate (context);
312 G_GNUC_END_IGNORE_DEPRECATIONS
313   gtk_style_context_restore (context);
314 
315   gtk_widget_destroy (window);
316 }
317 
318 void
test_widget_path_parent(void)319 test_widget_path_parent (void)
320 {
321   GtkStyleContext *parent, *context;
322 
323   parent = gtk_style_context_new ();
324   context = gtk_style_context_new ();
325 
326   gtk_style_context_set_parent (context, parent);
327 
328   g_object_unref (parent);
329   g_object_unref (context);
330 }
331 
332 static void
test_style_classes(void)333 test_style_classes (void)
334 {
335   GtkStyleContext *context;
336   GList *classes;
337 
338   context = gtk_style_context_new ();
339 
340   classes = gtk_style_context_list_classes (context);
341   g_assert_null (classes);
342 
343   gtk_style_context_add_class (context, "A");
344 
345   classes = gtk_style_context_list_classes (context);
346   g_assert (classes);
347   g_assert_null (classes->next);
348   g_assert_cmpstr (classes->data, ==, "A");
349   g_list_free (classes);
350 
351   gtk_style_context_add_class (context, "B");
352 
353   classes = gtk_style_context_list_classes (context);
354   g_assert (classes);
355   g_assert_cmpstr (classes->data, ==, "A");
356   g_assert (classes->next);
357   g_assert_cmpstr (classes->next->data, ==, "B");
358   g_assert_null (classes->next->next);
359   g_list_free (classes);
360 
361   gtk_style_context_remove_class (context, "A");
362 
363   classes = gtk_style_context_list_classes (context);
364   g_assert (classes);
365   g_assert_null (classes->next);
366   g_assert_cmpstr (classes->data, ==, "B");
367   g_list_free (classes);
368 
369   g_object_unref (context);
370 }
371 
372 static void
test_style_priorities_setup(PrioritiesFixture * f,gconstpointer unused)373 test_style_priorities_setup (PrioritiesFixture *f,
374                              gconstpointer      unused)
375 {
376   GError *error = NULL;
377   GtkWidgetPath *path;
378   f->blue_provider = gtk_css_provider_new ();
379   f->red_provider = gtk_css_provider_new ();
380   f->green_provider = gtk_css_provider_new ();
381   f->context = gtk_style_context_new ();
382   path = gtk_widget_path_new ();
383 
384   gtk_css_provider_load_from_data (f->blue_provider, "* { color: blue; }", -1, &error);
385   g_assert_no_error (error);
386   gtk_css_provider_load_from_data (f->red_provider, "* { color: red; }", -1, &error);
387   g_assert_no_error (error);
388   gtk_css_provider_load_from_data (f->green_provider, "* { color: green; }", -1, &error);
389   g_assert_no_error (error);
390 
391   gtk_widget_path_append_type (path, GTK_TYPE_WINDOW);
392   gtk_style_context_set_path (f->context, path);
393 
394   gtk_widget_path_free (path);
395 }
396 
397 static void
test_style_priorities_teardown(PrioritiesFixture * f,gconstpointer unused)398 test_style_priorities_teardown (PrioritiesFixture *f,
399                                 gconstpointer      unused)
400 {
401   g_object_unref (f->blue_provider);
402   g_object_unref (f->red_provider);
403   g_object_unref (f->green_provider);
404   g_object_unref (f->context);
405 }
406 
407 static void
test_style_priorities_equal(PrioritiesFixture * f,gconstpointer unused)408 test_style_priorities_equal (PrioritiesFixture *f,
409                              gconstpointer      unused)
410 {
411   GdkRGBA color, ref_color;
412 
413   gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
414                                              GTK_STYLE_PROVIDER (f->blue_provider),
415                                              GTK_STYLE_PROVIDER_PRIORITY_USER);
416   gtk_style_context_add_provider (f->context, GTK_STYLE_PROVIDER (f->red_provider),
417                                   GTK_STYLE_PROVIDER_PRIORITY_USER);
418 
419   /* When style providers are added to the screen as well as the style context
420   the one specific to the style context should take priority */
421   gdk_rgba_parse (&ref_color, "red");
422   gtk_style_context_get_color (f->context, gtk_style_context_get_state (f->context),
423                                &color);
424 
425   g_assert_true (gdk_rgba_equal (&ref_color, &color));
426 }
427 
428 static void
test_style_priorities_screen_only(PrioritiesFixture * f,gconstpointer unused)429 test_style_priorities_screen_only (PrioritiesFixture *f,
430                                    gconstpointer      unused)
431 {
432   GdkRGBA color, ref_color;
433 
434   gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
435                                              GTK_STYLE_PROVIDER (f->blue_provider),
436                                              GTK_STYLE_PROVIDER_PRIORITY_USER);
437 
438   gdk_rgba_parse (&ref_color, "blue");
439   gtk_style_context_get_color (f->context, gtk_style_context_get_state (f->context),
440                                &color);
441 
442   g_assert_true (gdk_rgba_equal (&ref_color, &color));
443 }
444 
445 static void
test_style_priorities_context_only(PrioritiesFixture * f,gconstpointer unused)446 test_style_priorities_context_only (PrioritiesFixture *f,
447                                     gconstpointer      unused)
448 {
449   GdkRGBA color, ref_color;
450 
451   gtk_style_context_add_provider (f->context, GTK_STYLE_PROVIDER (f->red_provider),
452                                   GTK_STYLE_PROVIDER_PRIORITY_USER);
453 
454   gdk_rgba_parse (&ref_color, "red");
455   gtk_style_context_get_color (f->context, gtk_style_context_get_state (f->context),
456                                &color);
457 
458   g_assert_true (gdk_rgba_equal (&ref_color, &color));
459 }
460 
461 static void
test_style_priorities_screen_higher(PrioritiesFixture * f,gconstpointer unused)462 test_style_priorities_screen_higher (PrioritiesFixture *f,
463                                      gconstpointer      unused)
464 {
465   GdkRGBA color, ref_color;
466 
467   gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
468                                              GTK_STYLE_PROVIDER (f->blue_provider),
469                                              GTK_STYLE_PROVIDER_PRIORITY_USER + 1);
470   gtk_style_context_add_provider (f->context, GTK_STYLE_PROVIDER (f->red_provider),
471                                   GTK_STYLE_PROVIDER_PRIORITY_USER);
472 
473   gdk_rgba_parse (&ref_color, "blue");
474   gtk_style_context_get_color (f->context, gtk_style_context_get_state (f->context),
475                                &color);
476 
477   g_assert_true (gdk_rgba_equal (&ref_color, &color));
478 }
479 
480 static void
test_style_priorities_context_higher(PrioritiesFixture * f,gconstpointer unused)481 test_style_priorities_context_higher (PrioritiesFixture *f,
482                                       gconstpointer      unused)
483 {
484   GdkRGBA color, ref_color;
485 
486   gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
487                                              GTK_STYLE_PROVIDER (f->blue_provider),
488                                              GTK_STYLE_PROVIDER_PRIORITY_USER);
489   gtk_style_context_add_provider (f->context, GTK_STYLE_PROVIDER (f->red_provider),
490                                   GTK_STYLE_PROVIDER_PRIORITY_USER + 1);
491 
492   gdk_rgba_parse (&ref_color, "red");
493   gtk_style_context_get_color (f->context, gtk_style_context_get_state (f->context),
494                                &color);
495 
496   g_assert_true (gdk_rgba_equal (&ref_color, &color));
497 }
498 
499 static void
test_style_priorities_two_screen(PrioritiesFixture * f,gconstpointer unused)500 test_style_priorities_two_screen (PrioritiesFixture *f,
501                                   gconstpointer      unused)
502 {
503   GdkRGBA color, ref_color;
504 
505   gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
506                                              GTK_STYLE_PROVIDER (f->blue_provider),
507                                              GTK_STYLE_PROVIDER_PRIORITY_USER);
508   gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
509                                              GTK_STYLE_PROVIDER (f->red_provider),
510                                              GTK_STYLE_PROVIDER_PRIORITY_USER + 1);
511 
512   gdk_rgba_parse (&ref_color, "red");
513   gtk_style_context_get_color (f->context, gtk_style_context_get_state (f->context),
514                                &color);
515 
516   g_assert_true (gdk_rgba_equal (&ref_color, &color));
517 }
518 
519 static void
test_style_priorities_two_context(PrioritiesFixture * f,gconstpointer unused)520 test_style_priorities_two_context (PrioritiesFixture *f,
521                                    gconstpointer      unused)
522 {
523   GdkRGBA color, ref_color;
524 
525   gtk_style_context_add_provider (f->context, GTK_STYLE_PROVIDER (f->blue_provider),
526                                   GTK_STYLE_PROVIDER_PRIORITY_USER);
527   gtk_style_context_add_provider (f->context, GTK_STYLE_PROVIDER (f->red_provider),
528                                   GTK_STYLE_PROVIDER_PRIORITY_USER + 1);
529 
530   gdk_rgba_parse (&ref_color, "red");
531   gtk_style_context_get_color (f->context, gtk_style_context_get_state (f->context),
532                                &color);
533 
534   g_assert_true (gdk_rgba_equal (&ref_color, &color));
535 }
536 
537 static void
test_style_priorities_three_screen_higher(PrioritiesFixture * f,gconstpointer unused)538 test_style_priorities_three_screen_higher (PrioritiesFixture *f,
539                                            gconstpointer      unused)
540 {
541   GdkRGBA color, ref_color;
542 
543   gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
544                                              GTK_STYLE_PROVIDER (f->blue_provider),
545                                              GTK_STYLE_PROVIDER_PRIORITY_USER);
546   gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
547                                              GTK_STYLE_PROVIDER (f->green_provider),
548                                              GTK_STYLE_PROVIDER_PRIORITY_USER + 1);
549   gtk_style_context_add_provider (f->context, GTK_STYLE_PROVIDER (f->red_provider),
550                                   GTK_STYLE_PROVIDER_PRIORITY_USER);
551 
552   gdk_rgba_parse (&ref_color, "green");
553   gtk_style_context_get_color (f->context, gtk_style_context_get_state (f->context),
554                                &color);
555 
556   g_assert_true (gdk_rgba_equal (&ref_color, &color));
557 }
558 
559 static void
test_style_priorities_three_context_higher(PrioritiesFixture * f,gconstpointer unused)560 test_style_priorities_three_context_higher (PrioritiesFixture *f,
561                                             gconstpointer      unused)
562 {
563   GdkRGBA color, ref_color;
564 
565   gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
566                                              GTK_STYLE_PROVIDER (f->blue_provider),
567                                              GTK_STYLE_PROVIDER_PRIORITY_USER);
568   gtk_style_context_add_provider (f->context, GTK_STYLE_PROVIDER (f->red_provider),
569                                   GTK_STYLE_PROVIDER_PRIORITY_USER);
570   gtk_style_context_add_provider (f->context, GTK_STYLE_PROVIDER (f->green_provider),
571                                   GTK_STYLE_PROVIDER_PRIORITY_USER + 1);
572 
573   gdk_rgba_parse (&ref_color, "green");
574   gtk_style_context_get_color (f->context, gtk_style_context_get_state (f->context),
575                                &color);
576 
577   g_assert_true (gdk_rgba_equal (&ref_color, &color));
578 }
579 
580 int
main(int argc,char * argv[])581 main (int argc, char *argv[])
582 {
583   gtk_init (NULL, NULL);
584   g_test_init (&argc, &argv, NULL);
585 
586   g_test_add_func ("/style/parse/selectors", test_parse_selectors);
587   g_test_add_func ("/style/path", test_path);
588   g_test_add_func ("/style/match", test_match);
589   g_test_add_func ("/style/basic", test_basic_properties);
590   g_test_add_func ("/style/invalidate-saved", test_invalidate_saved);
591   g_test_add_func ("/style/widget-path-parent", test_widget_path_parent);
592   g_test_add_func ("/style/classes", test_style_classes);
593 
594 #define ADD_PRIORITIES_TEST(path, func) \
595   g_test_add ("/style/priorities/" path, PrioritiesFixture, NULL, test_style_priorities_setup, \
596               (func), test_style_priorities_teardown)
597 
598   ADD_PRIORITIES_TEST ("equal", test_style_priorities_equal);
599   ADD_PRIORITIES_TEST ("screen-only", test_style_priorities_screen_only);
600   ADD_PRIORITIES_TEST ("context-only", test_style_priorities_context_only);
601   ADD_PRIORITIES_TEST ("screen-higher", test_style_priorities_screen_higher);
602   ADD_PRIORITIES_TEST ("context-higher", test_style_priorities_context_higher);
603   ADD_PRIORITIES_TEST ("two-screen", test_style_priorities_two_screen);
604   ADD_PRIORITIES_TEST ("two-context", test_style_priorities_two_context);
605   ADD_PRIORITIES_TEST ("three-screen-higher", test_style_priorities_three_screen_higher);
606   ADD_PRIORITIES_TEST ("three-context-higher", test_style_priorities_three_context_higher);
607 
608 #undef ADD_PRIORITIES_TEST
609 
610   return g_test_run ();
611 }
612