summaryrefslogtreecommitdiffstats
path: root/subprojects/libhandy/tests/test-view-switcher.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 14:36:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 14:36:24 +0000
commit9b6d8e63db85c30007b463e91f91a791969fa83f (patch)
tree0899af51d73c1bf986f73ae39a03c4436083018a /subprojects/libhandy/tests/test-view-switcher.c
parentInitial commit. (diff)
downloadgnome-control-center-9b6d8e63db85c30007b463e91f91a791969fa83f.tar.xz
gnome-control-center-9b6d8e63db85c30007b463e91f91a791969fa83f.zip
Adding upstream version 1:3.38.4.upstream/1%3.38.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'subprojects/libhandy/tests/test-view-switcher.c')
-rw-r--r--subprojects/libhandy/tests/test-view-switcher.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/subprojects/libhandy/tests/test-view-switcher.c b/subprojects/libhandy/tests/test-view-switcher.c
new file mode 100644
index 0000000..2f6c89d
--- /dev/null
+++ b/subprojects/libhandy/tests/test-view-switcher.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2019 Purism SPC
+ *
+ * SPDX-License-Identifier: LGPL-2.1+
+ */
+
+#include <handy.h>
+
+
+static void
+test_hdy_view_switcher_policy (void)
+{
+ g_autoptr (HdyViewSwitcher) view_switcher = NULL;
+
+ view_switcher = g_object_ref_sink (HDY_VIEW_SWITCHER (hdy_view_switcher_new ()));
+ g_assert_nonnull (view_switcher);
+
+ g_assert_cmpint (hdy_view_switcher_get_policy (view_switcher), ==, HDY_VIEW_SWITCHER_POLICY_AUTO);
+
+ hdy_view_switcher_set_policy (view_switcher, HDY_VIEW_SWITCHER_POLICY_NARROW);
+ g_assert_cmpint (hdy_view_switcher_get_policy (view_switcher), ==, HDY_VIEW_SWITCHER_POLICY_NARROW);
+
+ hdy_view_switcher_set_policy (view_switcher, HDY_VIEW_SWITCHER_POLICY_WIDE);
+ g_assert_cmpint (hdy_view_switcher_get_policy (view_switcher), ==, HDY_VIEW_SWITCHER_POLICY_WIDE);
+
+ hdy_view_switcher_set_policy (view_switcher, HDY_VIEW_SWITCHER_POLICY_AUTO);
+ g_assert_cmpint (hdy_view_switcher_get_policy (view_switcher), ==, HDY_VIEW_SWITCHER_POLICY_AUTO);
+}
+
+
+static void
+test_hdy_view_switcher_narrow_ellipsize (void)
+{
+ g_autoptr (HdyViewSwitcher) view_switcher = NULL;
+
+ view_switcher = g_object_ref_sink (HDY_VIEW_SWITCHER (hdy_view_switcher_new ()));
+ g_assert_nonnull (view_switcher);
+
+ g_assert_cmpint (hdy_view_switcher_get_narrow_ellipsize (view_switcher), ==, PANGO_ELLIPSIZE_NONE);
+
+ hdy_view_switcher_set_narrow_ellipsize (view_switcher, PANGO_ELLIPSIZE_END);
+ g_assert_cmpint (hdy_view_switcher_get_narrow_ellipsize (view_switcher), ==, PANGO_ELLIPSIZE_END);
+
+ hdy_view_switcher_set_narrow_ellipsize (view_switcher, PANGO_ELLIPSIZE_NONE);
+ g_assert_cmpint (hdy_view_switcher_get_narrow_ellipsize (view_switcher), ==, PANGO_ELLIPSIZE_NONE);
+}
+
+
+static void
+test_hdy_view_switcher_stack (void)
+{
+ g_autoptr (HdyViewSwitcher) view_switcher = NULL;
+ GtkStack *stack;
+
+ view_switcher = g_object_ref_sink (HDY_VIEW_SWITCHER (hdy_view_switcher_new ()));
+ g_assert_nonnull (view_switcher);
+
+ stack = GTK_STACK (gtk_stack_new ());
+ g_assert_nonnull (stack);
+
+ g_assert_null (hdy_view_switcher_get_stack (view_switcher));
+
+ hdy_view_switcher_set_stack (view_switcher, stack);
+ g_assert (hdy_view_switcher_get_stack (view_switcher) == stack);
+
+ hdy_view_switcher_set_stack (view_switcher, NULL);
+ g_assert_null (hdy_view_switcher_get_stack (view_switcher));
+}
+
+
+gint
+main (gint argc,
+ gchar *argv[])
+{
+ gtk_test_init (&argc, &argv, NULL);
+ hdy_init ();
+
+ g_test_add_func("/Handy/ViewSwitcher/policy", test_hdy_view_switcher_policy);
+ g_test_add_func("/Handy/ViewSwitcher/narrow_ellipsize", test_hdy_view_switcher_narrow_ellipsize);
+ g_test_add_func("/Handy/ViewSwitcher/stack", test_hdy_view_switcher_stack);
+
+ return g_test_run();
+}