File: test-css.c

package info (click to toggle)
phosh 0.52.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,732 kB
  • sloc: ansic: 82,495; xml: 3,912; python: 717; sh: 456; makefile: 34; lisp: 22; javascript: 6
file content (54 lines) | stat: -rw-r--r-- 1,318 bytes parent folder | download | duplicates (2)
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
/*
 * Copyright (C) 2022 Purism SPC
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Author: Guido Günther <agx@sigxcpu.org>
 */

#include "style-manager.h"

/* Load the stylesheets to catch CSS parser warnings */

static const char *
load_theme (const char *theme_name)
{
  const char *style;
  g_autoptr (GtkCssProvider) provider = gtk_css_provider_new ();

  g_debug ("GTK theme: %s", theme_name);

  style = phosh_style_manager_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_phosh_css_default(void)
{
  g_assert_cmpstr (load_theme ("Adwaita"), ==, "/mobi/phosh/stylesheet/adwaita-dark.css");
}


static void
test_phosh_css_highcontrast(void)
{
  g_assert_cmpstr (load_theme ("HighContrast"), ==, "/mobi/phosh/stylesheet/adwaita-hc-light.css");
}


int
main (int   argc,
      char *argv[])
{
  gtk_test_init (&argc, &argv, NULL);

  g_test_add_func("/phosh/css/default", test_phosh_css_default);
  g_test_add_func("/phosh/css/highcontrast", test_phosh_css_highcontrast);
  return g_test_run();
}