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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
/*
* Copyright (C) 2019 Purism SPC
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#include <handy.h>
static void
test_hdy_squeezer_homogeneous (void)
{
g_autoptr (HdySqueezer) squeezer = NULL;
squeezer = g_object_ref_sink (HDY_SQUEEZER (hdy_squeezer_new ()));
g_assert_nonnull (squeezer);
g_assert_true (hdy_squeezer_get_homogeneous (squeezer));
hdy_squeezer_set_homogeneous (squeezer, FALSE);
g_assert_false (hdy_squeezer_get_homogeneous (squeezer));
hdy_squeezer_set_homogeneous (squeezer, TRUE);
g_assert_true (hdy_squeezer_get_homogeneous (squeezer));
}
static void
test_hdy_squeezer_transition_duration (void)
{
g_autoptr (HdySqueezer) squeezer = NULL;
squeezer = g_object_ref_sink (HDY_SQUEEZER (hdy_squeezer_new ()));
g_assert_nonnull (squeezer);
g_assert_cmpuint (hdy_squeezer_get_transition_duration (squeezer), ==, 200);
hdy_squeezer_set_transition_duration (squeezer, 400);
g_assert_cmpuint (hdy_squeezer_get_transition_duration (squeezer), ==, 400);
hdy_squeezer_set_transition_duration (squeezer, -1);
g_assert_cmpuint (hdy_squeezer_get_transition_duration (squeezer), ==, G_MAXUINT);
}
static void
test_hdy_squeezer_transition_type (void)
{
g_autoptr (HdySqueezer) squeezer = NULL;
squeezer = g_object_ref_sink (HDY_SQUEEZER (hdy_squeezer_new ()));
g_assert_nonnull (squeezer);
g_assert_cmpuint (hdy_squeezer_get_transition_type (squeezer), ==, HDY_SQUEEZER_TRANSITION_TYPE_NONE);
hdy_squeezer_set_transition_type (squeezer, HDY_SQUEEZER_TRANSITION_TYPE_CROSSFADE);
g_assert_cmpuint (hdy_squeezer_get_transition_type (squeezer), ==, HDY_SQUEEZER_TRANSITION_TYPE_CROSSFADE);
hdy_squeezer_set_transition_type (squeezer, HDY_SQUEEZER_TRANSITION_TYPE_NONE);
g_assert_cmpuint (hdy_squeezer_get_transition_type (squeezer), ==, HDY_SQUEEZER_TRANSITION_TYPE_NONE);
}
static void
test_hdy_squeezer_transition_running (void)
{
g_autoptr (HdySqueezer) squeezer = NULL;
squeezer = g_object_ref_sink (HDY_SQUEEZER (hdy_squeezer_new ()));
g_assert_nonnull (squeezer);
g_assert_false (hdy_squeezer_get_transition_running (squeezer));
}
static void
test_hdy_squeezer_show_hide_child (void)
{
g_autoptr (HdySqueezer) squeezer = NULL;
GtkWidget *child;
squeezer = g_object_ref_sink (HDY_SQUEEZER (hdy_squeezer_new ()));
g_assert_nonnull (squeezer);
g_assert_null (hdy_squeezer_get_visible_child (squeezer));
child = gtk_label_new ("");
gtk_container_add (GTK_CONTAINER (squeezer), child);
g_assert_null (hdy_squeezer_get_visible_child (squeezer));
gtk_widget_show (child);
g_assert (hdy_squeezer_get_visible_child (squeezer) == child);
gtk_widget_hide (child);
g_assert_null (hdy_squeezer_get_visible_child (squeezer));
gtk_widget_show (child);
g_assert (hdy_squeezer_get_visible_child (squeezer) == child);
gtk_container_remove (GTK_CONTAINER (squeezer), child);
g_assert_null (hdy_squeezer_get_visible_child (squeezer));
}
static void
test_hdy_squeezer_interpolate_size (void)
{
g_autoptr (HdySqueezer) squeezer = NULL;
squeezer = g_object_ref_sink (HDY_SQUEEZER (hdy_squeezer_new ()));
g_assert_nonnull (squeezer);
g_assert_false (hdy_squeezer_get_interpolate_size (squeezer));
hdy_squeezer_set_interpolate_size (squeezer, TRUE);
g_assert_true (hdy_squeezer_get_interpolate_size (squeezer));
hdy_squeezer_set_interpolate_size (squeezer, FALSE);
g_assert_false (hdy_squeezer_get_interpolate_size (squeezer));
}
static void
test_hdy_squeezer_child_enabled (void)
{
g_autoptr (HdySqueezer) squeezer = NULL;
GtkWidget *child;
squeezer = g_object_ref_sink (HDY_SQUEEZER (hdy_squeezer_new ()));
g_assert_nonnull (squeezer);
child = gtk_label_new ("");
gtk_widget_show (child);
gtk_container_add (GTK_CONTAINER (squeezer), child);
g_assert_true (hdy_squeezer_get_child_enabled (squeezer, child));
hdy_squeezer_set_child_enabled (squeezer, child, FALSE);
g_assert_false (hdy_squeezer_get_child_enabled (squeezer, child));
hdy_squeezer_set_child_enabled (squeezer, child, TRUE);
g_assert_true (hdy_squeezer_get_child_enabled (squeezer, child));
}
gint
main (gint argc,
gchar *argv[])
{
gtk_test_init (&argc, &argv, NULL);
hdy_init ();
g_test_add_func("/Handy/ViewSwitcher/homogeneous", test_hdy_squeezer_homogeneous);
g_test_add_func("/Handy/ViewSwitcher/transition_duration", test_hdy_squeezer_transition_duration);
g_test_add_func("/Handy/ViewSwitcher/transition_type", test_hdy_squeezer_transition_type);
g_test_add_func("/Handy/ViewSwitcher/transition_running", test_hdy_squeezer_transition_running);
g_test_add_func("/Handy/ViewSwitcher/show_hide_child", test_hdy_squeezer_show_hide_child);
g_test_add_func("/Handy/ViewSwitcher/interpolate_size", test_hdy_squeezer_interpolate_size);
g_test_add_func("/Handy/ViewSwitcher/child_enabled", test_hdy_squeezer_child_enabled);
return g_test_run();
}
|