summaryrefslogtreecommitdiffstats
path: root/subprojects/libhandy/tests/test-preferences-row.c
blob: c4f176962c8676997402202996848ffb87febc8f (plain)
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
/*
 * Copyright (C) 2019 Purism SPC
 *
 * SPDX-License-Identifier: LGPL-2.1+
 */

#include <handy.h>


static void
test_hdy_preferences_row_title (void)
{
  g_autoptr (HdyPreferencesRow) row = NULL;

  row = g_object_ref_sink (HDY_PREFERENCES_ROW (hdy_preferences_row_new ()));
  g_assert_nonnull (row);

  g_assert_null (hdy_preferences_row_get_title (row));

  hdy_preferences_row_set_title (row, "Dummy title");
  g_assert_cmpstr (hdy_preferences_row_get_title (row), ==, "Dummy title");

  hdy_preferences_row_set_title (row, NULL);
  g_assert_null (hdy_preferences_row_get_title (row));
}


static void
test_hdy_preferences_row_use_undeline (void)
{
  g_autoptr (HdyPreferencesRow) row = NULL;

  row = g_object_ref_sink (HDY_PREFERENCES_ROW (hdy_preferences_row_new ()));
  g_assert_nonnull (row);

  g_assert_false (hdy_preferences_row_get_use_underline (row));

  hdy_preferences_row_set_use_underline (row, TRUE);
  g_assert_true (hdy_preferences_row_get_use_underline (row));

  hdy_preferences_row_set_use_underline (row, FALSE);
  g_assert_false (hdy_preferences_row_get_use_underline (row));
}


gint
main (gint argc,
      gchar *argv[])
{
  gtk_test_init (&argc, &argv, NULL);
  hdy_init ();

  g_test_add_func("/Handy/PreferencesRow/title", test_hdy_preferences_row_title);
  g_test_add_func("/Handy/PreferencesRow/use_underline", test_hdy_preferences_row_use_undeline);

  return g_test_run();
}