File: test-settings.c

package info (click to toggle)
phoc 0.52.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,052 kB
  • sloc: ansic: 107,165; xml: 3,765; sh: 138; makefile: 33; javascript: 5
file content (82 lines) | stat: -rw-r--r-- 2,094 bytes parent folder | download
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 * Copyright (C) 2023 Phosh.mobi e.V.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Author: Guido Günther <agx@sigxcpu.org>
 */

#include "settings.h"

#include "testlib.h"


static void
test_phoc_config_defaults (void)
{
  g_autoptr (PhocConfig) config = phoc_config_new_from_data ("");

  g_assert_true (config->xwayland);
  g_assert_true (config->xwayland_lazy);
  g_assert_cmpint (g_slist_length (config->outputs), ==, 0);
  g_assert_null (config->config_path);
}


static void
test_phoc_config_output (void)
{
  PhocOutputConfig *oc;

  g_autoptr (PhocConfig) config1 = phoc_config_new_from_data (
    "[output:X11-1]\n"
    "scale = 3\n"
    "adaptive-sync = enabled\n");

  g_autoptr (PhocConfig) config2 = phoc_config_new_from_data (
    "[output:X11-1]\n"
    "scale = 3\n"
    "[output:X11-2]\n"
    "scale = 3\n");

  oc = config1->outputs->data;
  g_assert_cmpint (g_slist_length (config1->outputs), ==, 1);
  g_assert_cmpfloat (oc->scale, ==, 3.0);
  g_assert_cmpint (oc->adaptive_sync, ==, PHOC_OUTPUT_ADAPTIVE_SYNC_ENABLED);
  g_assert_cmpint (g_slist_length (config1->outputs), ==, 1);


  g_assert_cmpint (g_slist_length (config2->outputs), ==, 2);
}


static void
test_phoc_config_modelines (void)
{
  PhocOutputConfig *oc;

  g_autoptr (PhocConfig) config = phoc_config_new_from_data (
    "[output:X11-1]\n"
    "modeline = 87.25  720 776 848 976  1440 1443 1453 1493 -hsync +vsync\n"
    "modeline = 87.25  720 776 848 976  1440 1443 1453 1493 -hsync +vsync\n"
    "scale = 3\n");

  oc = config->outputs->data;
  g_assert_cmpint (g_slist_length (config->outputs), ==, 1);
  g_assert_cmpfloat (oc->scale, ==, 3.0);
  g_assert_cmpint (oc->adaptive_sync, ==, PHOC_OUTPUT_ADAPTIVE_SYNC_NONE);
  g_assert_cmpint (g_slist_length (oc->modes), ==, 2);
}


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

  g_test_add_func ("/phoc/config/simple", test_phoc_config_defaults);
  g_test_add_func ("/phoc/config/output", test_phoc_config_output);
  g_test_add_func ("/phoc/config/modelines", test_phoc_config_modelines);

  return g_test_run ();
}