1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
/*
* Copyright (C) 2022 Purism SPC
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Author: Guido Günther <agx@sigxcpu.org>
*/
#include "util.h"
/* Load the stylesheets to catch CSS parser warnings */
static const char *
load_theme (const char *theme_name)
{
const char *style;
g_autofree char *name = NULL;
g_autoptr (GtkCssProvider) provider = gtk_css_provider_new ();
g_debug ("GTK theme: %s", theme_name);
style = phog_util_get_stylesheet (theme_name);
gtk_css_provider_load_from_resource (provider, style);
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
return style;
}
static void
test_phog_css_default(void)
{
g_assert_cmpstr (load_theme ("Adwaita"), ==, "/org/mobian/phog/stylesheet/adwaita-dark.css");
}
static void
test_phog_css_highcontrast(void)
{
g_assert_cmpstr (load_theme ("HighContrast"), ==, "/org/mobian/phog/stylesheet/adwaita-hc-light.css");
}
int
main (int argc,
char *argv[])
{
gtk_test_init (&argc, &argv, NULL);
g_test_add_func("/phog/css/default", test_phog_css_default);
g_test_add_func("/phog/css/highcontrast", test_phog_css_highcontrast);
return g_test_run();
}
|