summaryrefslogtreecommitdiffstats
path: root/subprojects/libhandy/tests/test-view-switcher-bar.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-bar.c
parentInitial commit. (diff)
downloadgnome-control-center-upstream.tar.xz
gnome-control-center-upstream.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-bar.c')
-rw-r--r--subprojects/libhandy/tests/test-view-switcher-bar.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/subprojects/libhandy/tests/test-view-switcher-bar.c b/subprojects/libhandy/tests/test-view-switcher-bar.c
new file mode 100644
index 0000000..54538a6
--- /dev/null
+++ b/subprojects/libhandy/tests/test-view-switcher-bar.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_bar_policy (void)
+{
+ g_autoptr (HdyViewSwitcherBar) bar = NULL;
+
+ bar = g_object_ref_sink (HDY_VIEW_SWITCHER_BAR (hdy_view_switcher_bar_new ()));
+ g_assert_nonnull (bar);
+
+ g_assert_cmpint (hdy_view_switcher_bar_get_policy (bar), ==, HDY_VIEW_SWITCHER_POLICY_NARROW);
+
+ hdy_view_switcher_bar_set_policy (bar, HDY_VIEW_SWITCHER_POLICY_AUTO);
+ g_assert_cmpint (hdy_view_switcher_bar_get_policy (bar), ==, HDY_VIEW_SWITCHER_POLICY_AUTO);
+
+ hdy_view_switcher_bar_set_policy (bar, HDY_VIEW_SWITCHER_POLICY_WIDE);
+ g_assert_cmpint (hdy_view_switcher_bar_get_policy (bar), ==, HDY_VIEW_SWITCHER_POLICY_WIDE);
+
+ hdy_view_switcher_bar_set_policy (bar, HDY_VIEW_SWITCHER_POLICY_NARROW);
+ g_assert_cmpint (hdy_view_switcher_bar_get_policy (bar), ==, HDY_VIEW_SWITCHER_POLICY_NARROW);
+}
+
+
+static void
+test_hdy_view_switcher_bar_stack (void)
+{
+ g_autoptr (HdyViewSwitcherBar) bar = NULL;
+ GtkStack *stack;
+
+ bar = g_object_ref_sink (HDY_VIEW_SWITCHER_BAR (hdy_view_switcher_bar_new ()));
+ g_assert_nonnull (bar);
+
+ stack = GTK_STACK (gtk_stack_new ());
+ g_assert_nonnull (stack);
+
+ g_assert_null (hdy_view_switcher_bar_get_stack (bar));
+
+ hdy_view_switcher_bar_set_stack (bar, stack);
+ g_assert (hdy_view_switcher_bar_get_stack (bar) == stack);
+
+ hdy_view_switcher_bar_set_stack (bar, NULL);
+ g_assert_null (hdy_view_switcher_bar_get_stack (bar));
+}
+
+
+static void
+test_hdy_view_switcher_bar_reveal (void)
+{
+ g_autoptr (HdyViewSwitcherBar) bar = NULL;
+
+ bar = g_object_ref_sink (HDY_VIEW_SWITCHER_BAR (hdy_view_switcher_bar_new ()));
+ g_assert_nonnull (bar);
+
+ g_assert_false (hdy_view_switcher_bar_get_reveal (bar));
+
+ hdy_view_switcher_bar_set_reveal (bar, TRUE);
+ g_assert_true (hdy_view_switcher_bar_get_reveal (bar));
+
+ hdy_view_switcher_bar_set_reveal (bar, FALSE);
+ g_assert_false (hdy_view_switcher_bar_get_reveal (bar));
+}
+
+
+gint
+main (gint argc,
+ gchar *argv[])
+{
+ gtk_test_init (&argc, &argv, NULL);
+ hdy_init ();
+
+ g_test_add_func("/Handy/ViewSwitcherBar/policy", test_hdy_view_switcher_bar_policy);
+ g_test_add_func("/Handy/ViewSwitcherBar/stack", test_hdy_view_switcher_bar_stack);
+ g_test_add_func("/Handy/ViewSwitcherBar/reveal", test_hdy_view_switcher_bar_reveal);
+
+ return g_test_run();
+}