Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright (c) 2010-2014, 2018 Red Hat, Inc. | ||
3 | * | ||
4 | * The Control Center is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by the | ||
6 | * Free Software Foundation; either version 2 of the License, or (at your | ||
7 | * option) any later version. | ||
8 | * | ||
9 | * The Control Center is distributed in the hope that it will be useful, but | ||
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
11 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
12 | * for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with the Control Center; if not, write to the Free Software Foundation, | ||
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | * | ||
18 | * Author: Benjamin Berg <bberg@redhat.com> | ||
19 | */ | ||
20 | |||
21 | #define G_LOG_DOMAIN "test-network-panel" | ||
22 | |||
23 | #include "nm-macros-internal.h" | ||
24 | |||
25 | #include <NetworkManager.h> | ||
26 | #include <nm-client.h> | ||
27 | #include <nm-utils.h> | ||
28 | |||
29 | #include "nm-test-libnm-utils.h" | ||
30 | |||
31 | #include <string.h> | ||
32 | #include <sys/types.h> | ||
33 | #include <signal.h> | ||
34 | #include <gtk/gtk.h> | ||
35 | |||
36 | #include "cc-test-window.h" | ||
37 | #include "shell/cc-object-storage.h" | ||
38 | |||
39 | #include "nmtst-helpers.h" | ||
40 | |||
41 | typedef struct { | ||
42 | NMTstcServiceInfo *sinfo; | ||
43 | NMClient *client; | ||
44 | |||
45 | NMDevice *main_ether; | ||
46 | |||
47 | GtkWindow *shell; | ||
48 | CcPanel *panel; | ||
49 | } NetworkPanelFixture; | ||
50 | |||
51 | |||
52 | extern GType cc_network_panel_get_type (void); | ||
53 | |||
54 | static void | ||
55 | 11 | fixture_set_up_empty (NetworkPanelFixture *fixture, | |
56 | gconstpointer user_data) | ||
57 | { | ||
58 | 11 | g_autoptr(GError) error = NULL; | |
59 | |||
60 | 11 | cc_object_storage_initialize (); | |
61 | |||
62 | /* Bring up the libnm service. */ | ||
63 | 11 | fixture->sinfo = nmtstc_service_init (); | |
64 | |||
65 | 11 | fixture->client = nm_client_new (NULL, &error); | |
66 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
|
11 | g_assert_no_error (error); |
67 | |||
68 | /* Insert into object storage so that we see the same events as the panel. */ | ||
69 | 11 | cc_object_storage_add_object (CC_OBJECT_NMCLIENT, fixture->client); | |
70 | |||
71 | 11 | fixture->shell = GTK_WINDOW (cc_test_window_new ()); | |
72 | |||
73 | 11 | fixture->panel = g_object_new (cc_network_panel_get_type (), | |
74 | 11 | "shell", CC_SHELL (fixture->shell), | |
75 | NULL); | ||
76 | |||
77 | 11 | g_object_ref (fixture->panel); | |
78 | 11 | cc_shell_set_active_panel (CC_SHELL (fixture->shell), fixture->panel); | |
79 | |||
80 | 11 | gtk_window_present (fixture->shell); | |
81 | 11 | } | |
82 | |||
83 | static void | ||
84 | 11 | fixture_tear_down (NetworkPanelFixture *fixture, | |
85 | gconstpointer user_data) | ||
86 | { | ||
87 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | g_clear_object (&fixture->panel); |
88 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | g_clear_object (&fixture->client); |
89 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | g_clear_pointer (&fixture->shell, gtk_window_destroy); |
90 | |||
91 | 11 | cc_object_storage_destroy (); | |
92 | |||
93 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | g_clear_pointer (&fixture->sinfo, nmtstc_service_cleanup); |
94 | 11 | } | |
95 | |||
96 | static void | ||
97 | 4 | fixture_set_up_wired (NetworkPanelFixture *fixture, | |
98 | gconstpointer user_data) | ||
99 | { | ||
100 | NMDevice *second; | ||
101 | |||
102 | 4 | fixture_set_up_empty (fixture, user_data); | |
103 | |||
104 | 4 | fixture->main_ether = nmtstc_service_add_wired_device (fixture->sinfo, | |
105 | fixture->client, | ||
106 | "eth1000", | ||
107 | "52:54:00:ab:db:23", | ||
108 | NULL); | ||
109 | |||
110 | /* Add/remove one to catch issues with signal disconnects. */ | ||
111 | 4 | second = nmtstc_service_add_wired_device (fixture->sinfo, | |
112 | fixture->client, | ||
113 | "eth1001", | ||
114 | "52:54:00:ab:db:24", | ||
115 | NULL); | ||
116 | 4 | nmtst_remove_device (fixture->sinfo, fixture->client, second); | |
117 | 4 | } | |
118 | |||
119 | /*****************************************************************************/ | ||
120 | |||
121 | static GtkWidget * | ||
122 | 5237 | find_label (GtkWidget *widget, | |
123 | const gchar *label_pattern) | ||
124 | { | ||
125 | GtkWidget *child; | ||
126 | 5237 | GtkWidget *label = NULL; | |
127 | |||
128 |
6/8✗ Branch 0 not taken.
✓ Branch 1 taken 5237 times.
✓ Branch 2 taken 5237 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 708 times.
✓ Branch 5 taken 4529 times.
✓ Branch 6 taken 708 times.
✓ Branch 7 taken 4529 times.
|
5237 | if (GTK_IS_LABEL (widget)) { |
129 | 708 | const gchar *text = gtk_label_get_text (GTK_LABEL (widget)); | |
130 |
2/2✓ Branch 1 taken 13 times.
✓ Branch 2 taken 695 times.
|
708 | if (g_pattern_match_simple (label_pattern, text)) |
131 | 13 | return widget; | |
132 | } | ||
133 | |||
134 |
2/2✓ Branch 1 taken 109 times.
✓ Branch 2 taken 5115 times.
|
5224 | if (ADW_IS_PREFERENCES_ROW (widget)) { |
135 | 109 | const gchar *text = adw_preferences_row_get_title (ADW_PREFERENCES_ROW (widget)); | |
136 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 2 taken 100 times.
|
109 | if (g_pattern_match_simple (label_pattern, text)) |
137 | 9 | return widget; | |
138 | } | ||
139 | |||
140 |
2/2✓ Branch 1 taken 58 times.
✓ Branch 2 taken 5157 times.
|
5215 | if (ADW_IS_ACTION_ROW (widget)) { |
141 | 58 | const gchar *text = adw_action_row_get_subtitle (ADW_ACTION_ROW (widget)); | |
142 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
|
58 | if (g_pattern_match_simple (label_pattern, text)) |
143 | ✗ | return widget; | |
144 | } | ||
145 | |||
146 | 5215 | for (child = gtk_widget_get_first_child (widget); | |
147 |
2/2✓ Branch 0 taken 5208 times.
✓ Branch 1 taken 4782 times.
|
9990 | child; |
148 | 4775 | child = gtk_widget_get_next_sibling (child)) { | |
149 | 5208 | label = find_label (child, label_pattern); | |
150 |
2/2✓ Branch 0 taken 433 times.
✓ Branch 1 taken 4775 times.
|
5208 | if (label) |
151 | 433 | break; | |
152 | } | ||
153 | |||
154 | 5215 | return label; | |
155 | } | ||
156 | |||
157 | static int | ||
158 | 128 | widget_geo_dist (GtkWidget *a, | |
159 | GtkWidget *b, | ||
160 | GtkWidget *base) | ||
161 | { | ||
162 | GtkAllocation allocation; | ||
163 | graphene_point_t a0, a1, b0, b1; | ||
164 | 128 | graphene_point_t dist = GRAPHENE_POINT_INIT (0, 0); | |
165 | |||
166 | 128 | gtk_widget_get_allocation (a, &allocation); | |
167 |
2/4✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 128 times.
|
256 | if (!gtk_widget_compute_point (a, base, &GRAPHENE_POINT_INIT (0, 0), &a0) || |
168 | 128 | !gtk_widget_compute_point (a, base, &GRAPHENE_POINT_INIT (allocation.width, allocation.height), &a1)) | |
169 | ✗ | return -G_MAXINT; | |
170 | |||
171 | 128 | gtk_widget_get_allocation (b, &allocation); | |
172 |
2/4✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 128 times.
|
256 | if (!gtk_widget_compute_point (b, base, &GRAPHENE_POINT_INIT (0, 0), &b0) || |
173 | 128 | !gtk_widget_compute_point (b, base, &GRAPHENE_POINT_INIT (allocation.width, allocation.height), &b1)) | |
174 | ✗ | return +G_MAXINT; | |
175 | |||
176 |
2/2✓ Branch 0 taken 21 times.
✓ Branch 1 taken 107 times.
|
128 | if (b0.x >= a1.x) |
177 | 21 | graphene_point_distance (&b0, &a1, &dist.x, NULL); | |
178 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
|
107 | else if (a0.x >= b1.x) |
179 | ✗ | graphene_point_distance (&a0, &b1, &dist.x, NULL); | |
180 | |||
181 |
2/2✓ Branch 0 taken 21 times.
✓ Branch 1 taken 107 times.
|
128 | if (b0.y >= a1.y) |
182 | 21 | graphene_point_distance (&b0, &a1, NULL, &dist.y); | |
183 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
|
107 | else if (a0.y >= b1.y) |
184 | ✗ | graphene_point_distance (&a0, &b1, NULL, &dist.y); | |
185 | |||
186 | 128 | return dist.x + dist.y; | |
187 | } | ||
188 | |||
189 | static GList* | ||
190 | 3102 | test_list_descendants (GtkWidget *widget, | |
191 | GType widget_type) | ||
192 | { | ||
193 | GtkWidget *child; | ||
194 | 3102 | GList *results = NULL; | |
195 | |||
196 | 3102 | for (child = gtk_widget_get_first_child (widget); | |
197 |
2/2✓ Branch 0 taken 3104 times.
✓ Branch 1 taken 3102 times.
|
6206 | child; |
198 | 3104 | child = gtk_widget_get_next_sibling (child)) { | |
199 |
4/6✓ Branch 0 taken 3104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3078 times.
✓ Branch 3 taken 26 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3078 times.
|
3104 | if (!widget_type || g_type_is_a (G_OBJECT_TYPE (child), widget_type)) |
200 | 26 | results = g_list_prepend (results, child); | |
201 | else | ||
202 | 3078 | results = g_list_concat (results, test_list_descendants (child, widget_type)); | |
203 | } | ||
204 | |||
205 | 3102 | return results; | |
206 | } | ||
207 | |||
208 | static int | ||
209 | 64 | widget_geo_cmp (gconstpointer a, | |
210 | gconstpointer b, | ||
211 | gpointer user_data) | ||
212 | { | ||
213 | 64 | gpointer *data = user_data; | |
214 | 64 | GtkWidget *wa = (void*) a, *wb = (void*) b, *toplevel = data[0], *base_widget = data[1]; | |
215 | 64 | int adist = widget_geo_dist (wa, base_widget, toplevel); | |
216 | 64 | int bdist = widget_geo_dist (wb, base_widget, toplevel); | |
217 |
4/4✓ Branch 0 taken 56 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 3 times.
|
64 | return adist > bdist ? +1 : adist == bdist ? 0 : -1; |
218 | } | ||
219 | |||
220 | static GtkWidget * | ||
221 | 2 | find_sibling (GtkWidget *widget, | |
222 | GType parent_type, | ||
223 | GType sibling_type) | ||
224 | { | ||
225 | 4 | g_autoptr(GList) siblings = NULL; | |
226 | 2 | GtkWidget *tmpwidget = widget; | |
227 | gpointer data[2]; | ||
228 | |||
229 | /* find all sibling candidates */ | ||
230 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
|
25 | while ((tmpwidget = gtk_widget_get_parent (tmpwidget)) != NULL) |
231 | { | ||
232 | 24 | siblings = g_list_concat (siblings, test_list_descendants (tmpwidget, sibling_type)); | |
233 | |||
234 | /* Stop searching further up if we reached the defined parent */ | ||
235 |
4/6✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
|
24 | if (parent_type && g_type_is_a (G_OBJECT_TYPE (tmpwidget), parent_type)) |
236 | break; | ||
237 | } | ||
238 | |||
239 | /* sort them by distance to base_widget */ | ||
240 | 2 | data[0] = gtk_widget_get_native (widget); | |
241 | 2 | data[1] = widget; | |
242 | 2 | siblings = g_list_sort_with_data (siblings, widget_geo_cmp, data); | |
243 | |||
244 | /* pick nearest != base_widget */ | ||
245 | 2 | siblings = g_list_remove (siblings, widget); | |
246 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | tmpwidget = siblings ? siblings->data : NULL; |
247 | |||
248 | 2 | return tmpwidget; | |
249 | } | ||
250 | |||
251 | /*****************************************************************************/ | ||
252 | |||
253 | #if 0 /* See /network-panel-wired/vpn-sorting note */ | ||
254 | static GtkWidget* | ||
255 | find_parent_of_type(GtkWidget *widget, GType parent) | ||
256 | { | ||
257 | while (widget) { | ||
258 | widget = gtk_widget_get_parent (widget); | ||
259 | if (G_TYPE_CHECK_INSTANCE_TYPE (G_OBJECT (widget), parent)) | ||
260 | return widget; | ||
261 | } | ||
262 | |||
263 | return NULL; | ||
264 | } | ||
265 | #endif | ||
266 | |||
267 | /*****************************************************************************/ | ||
268 | |||
269 | static void | ||
270 | 1 | test_empty_ui (NetworkPanelFixture *fixture, | |
271 | gconstpointer user_data) | ||
272 | { | ||
273 | GtkWidget *bt_header; | ||
274 | GtkWidget *wired_header; | ||
275 | |||
276 | /* There should be no Wired or Bluetooth sections */ | ||
277 | 1 | wired_header = find_label (GTK_WIDGET (fixture->shell), "Wired"); | |
278 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | g_assert_false (wired_header && gtk_widget_is_visible(wired_header)); |
279 | |||
280 | 1 | bt_header = find_label (GTK_WIDGET (fixture->shell), "Bluetooth"); | |
281 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | g_assert_false (bt_header && gtk_widget_is_visible(bt_header)); |
282 | 1 | } | |
283 | |||
284 | /*****************************************************************************/ | ||
285 | |||
286 | static void | ||
287 | 3 | test_device_add (NetworkPanelFixture *fixture, | |
288 | gconstpointer user_data) | ||
289 | { | ||
290 | const gchar *device_path; | ||
291 | |||
292 | /* Tell the test service to add a new device. | ||
293 | * We use some weird numbers so that the devices will not exist on the | ||
294 | * host system. */ | ||
295 | 3 | fixture->main_ether = nmtstc_service_add_wired_device (fixture->sinfo, | |
296 | fixture->client, | ||
297 | "eth1000", | ||
298 | "52:54:00:ab:db:23", | ||
299 | NULL); | ||
300 | 3 | device_path = nm_object_get_path (NM_OBJECT (fixture->main_ether)); | |
301 | 3 | g_debug("Device added: %s\n", device_path); | |
302 | |||
303 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
|
3 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "Wired")); |
304 | 3 | } | |
305 | |||
306 | static void | ||
307 | 1 | test_second_device_add (NetworkPanelFixture *fixture, | |
308 | gconstpointer user_data) | ||
309 | { | ||
310 | NMDevice *device; | ||
311 | const gchar *device_path; | ||
312 | |||
313 | 1 | test_device_add (fixture, user_data); | |
314 | |||
315 | 1 | device = nmtstc_service_add_wired_device (fixture->sinfo, | |
316 | fixture->client, | ||
317 | "eth1001", | ||
318 | "52:54:00:ab:db:24", | ||
319 | NULL); | ||
320 | 1 | device_path = nm_object_get_path (NM_OBJECT (device)); | |
321 | 1 | g_debug("Second device added: %s\n", device_path); | |
322 | |||
323 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_null (find_label (GTK_WIDGET (fixture->shell), "Wired")); |
324 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "Ethernet (eth1000)")); |
325 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "Ethernet (eth1001)")); |
326 | 1 | } | |
327 | |||
328 | static void | ||
329 | 1 | test_second_device_add_remove (NetworkPanelFixture *fixture, | |
330 | gconstpointer user_data) | ||
331 | { | ||
332 | NMDevice *device; | ||
333 | const gchar *device_path; | ||
334 | GtkWidget *bt_header; | ||
335 | |||
336 | 1 | test_device_add (fixture, user_data); | |
337 | |||
338 | 1 | device = nmtstc_service_add_wired_device (fixture->sinfo, | |
339 | fixture->client, | ||
340 | "eth1001", | ||
341 | "52:54:00:ab:db:24", | ||
342 | NULL); | ||
343 | 1 | device_path = nm_object_get_path (NM_OBJECT (device)); | |
344 | 1 | g_debug("Second device added: %s\n", device_path); | |
345 | |||
346 | 1 | nmtst_remove_device (fixture->sinfo, fixture->client, device); | |
347 | 1 | g_debug("Second device removed again\n"); | |
348 | |||
349 | /* eth1000 should be labeled "Wired" again */ | ||
350 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "Wired")); |
351 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_null (find_label (GTK_WIDGET (fixture->shell), "Ethernet (eth1000)")); |
352 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_null (find_label (GTK_WIDGET (fixture->shell), "Ethernet (eth1001)")); |
353 | |||
354 | /* Some more checks for unrelated UI not showing up randomly */ | ||
355 | 1 | bt_header = find_label (GTK_WIDGET (fixture->shell), "Bluetooth"); | |
356 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | g_assert_false (bt_header && gtk_widget_is_visible(bt_header)); |
357 | 1 | } | |
358 | |||
359 | /*****************************************************************************/ | ||
360 | |||
361 | static void | ||
362 | 5 | add_cb (GObject *object, | |
363 | GAsyncResult *result, | ||
364 | gpointer user_data) | ||
365 | { | ||
366 | 5 | NMClient *client = NM_CLIENT (object); | |
367 | 5 | EventWaitInfo *info = user_data; | |
368 | 5 | g_autoptr(GError) error = NULL; | |
369 | |||
370 | 5 | info->rc = nm_client_add_connection_finish (client, result, &error); | |
371 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
|
5 | g_assert_no_error (error); |
372 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
|
5 | g_assert_nonnull (info->rc); |
373 | |||
374 | 5 | info->other_remaining--; | |
375 |
8/16✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 10 taken 5 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 5 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 5 times.
|
5 | WAIT_CHECK_REMAINING() |
376 | 5 | } | |
377 | |||
378 | static void | ||
379 | 1 | delete_cb (GObject *object, | |
380 | GAsyncResult *result, | ||
381 | gpointer user_data) | ||
382 | { | ||
383 | 1 | NMRemoteConnection *connection = NM_REMOTE_CONNECTION (object); | |
384 | 1 | EventWaitInfo *info = user_data; | |
385 | 1 | g_autoptr(GError) error = NULL; | |
386 | |||
387 | 1 | nm_remote_connection_delete_finish (connection, result, &error); | |
388 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | g_assert_no_error (error); |
389 | |||
390 | 1 | info->other_remaining--; | |
391 |
8/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1 times.
|
1 | WAIT_CHECK_REMAINING() |
392 | 1 | } | |
393 | |||
394 | static void | ||
395 | 2 | test_connection_add (NetworkPanelFixture *fixture, | |
396 | gconstpointer user_data) | ||
397 | { | ||
398 | NMConnection *conn; | ||
399 | 2 | g_autoptr(GError) error = NULL; | |
400 | 2 | WAIT_DECL() | |
401 | |||
402 | 2 | conn = nmtst_create_minimal_connection ("test-inactive", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); | |
403 | 2 | nm_device_connection_compatible (fixture->main_ether, conn, &error); | |
404 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | g_assert_no_error (error); |
405 | |||
406 | 2 | nm_client_add_connection_async (fixture->client, conn, TRUE, NULL, add_cb, &info); | |
407 | |||
408 | 2 | info.other_remaining = 1; | |
409 | 2 | WAIT_CLIENT(fixture->client, 2, NM_CLIENT_CONNECTIONS, NM_CLIENT_CONNECTION_ADDED); | |
410 | |||
411 |
3/6✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
|
2 | WAIT_FINISHED(5) |
412 | |||
413 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | g_clear_object (&info.rc); |
414 | 2 | g_object_unref (conn); | |
415 | |||
416 | /* We have one (non-active) connection only, so we get a special case */ | ||
417 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
2 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "Cable unplugged")); |
418 | 2 | } | |
419 | |||
420 | /*****************************************************************************/ | ||
421 | |||
422 | static void | ||
423 | 1 | test_unconnected_carrier_plug (NetworkPanelFixture *fixture, | |
424 | gconstpointer user_data) | ||
425 | { | ||
426 | 1 | nmtst_set_wired_speed (fixture->sinfo, fixture->main_ether, 1234); | |
427 | 1 | nmtst_set_device_state (fixture->sinfo, fixture->main_ether, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_CARRIER); | |
428 | |||
429 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "1*234 Mb/s")); |
430 | 1 | } | |
431 | |||
432 | |||
433 | /*****************************************************************************/ | ||
434 | |||
435 | |||
436 | static void | ||
437 | 1 | test_connection_add_activate (NetworkPanelFixture *fixture, | |
438 | gconstpointer user_data) | ||
439 | { | ||
440 | NMConnection *conn; | ||
441 | 1 | NMActiveConnection *active_conn = NULL; | |
442 | 1 | g_autoptr(GError) error = NULL; | |
443 | GtkWidget *label, *sw; | ||
444 | |||
445 | /* First set us into disconnected state with a carrier. */ | ||
446 | 1 | nmtst_set_wired_speed (fixture->sinfo, fixture->main_ether, 1234); | |
447 | 1 | nmtst_set_device_state (fixture->sinfo, fixture->main_ether, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_CARRIER); | |
448 | |||
449 | 1 | conn = nmtst_create_minimal_connection ("test-active", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); | |
450 | |||
451 | 1 | nm_device_connection_compatible (fixture->main_ether, conn, &error); | |
452 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | g_assert_no_error (error); |
453 | |||
454 | 1 | active_conn = nmtst_add_and_activate_connection (fixture->sinfo, fixture->client, fixture->main_ether, conn); | |
455 | 1 | g_object_unref (active_conn); | |
456 | |||
457 | 1 | label = find_label (GTK_WIDGET (fixture->shell), "1*234 Mb/s"); | |
458 | 1 | sw = find_sibling (label, GTK_TYPE_LIST_BOX_ROW, GTK_TYPE_SWITCH); | |
459 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | g_assert_nonnull (sw); |
460 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_false (gtk_switch_get_state (GTK_SWITCH (sw))); |
461 | |||
462 | /* Now set the state to connected and check the switch state */ | ||
463 | 1 | nmtst_set_device_state (fixture->sinfo, fixture->main_ether, NM_DEVICE_STATE_ACTIVATED, NM_DEVICE_STATE_REASON_NONE); | |
464 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_true (gtk_switch_get_state (GTK_SWITCH (sw))); |
465 | |||
466 | /* Let's toggle the switch back and check we get events */ | ||
467 | 1 | gtk_switch_set_active (GTK_SWITCH (sw), FALSE); | |
468 | |||
469 | /* Only one connection, so a generic label. */ | ||
470 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "Connected - 1*234 Mb/s")); |
471 | 1 | } | |
472 | |||
473 | static void | ||
474 | 1 | test_connection_multi_add_activate (NetworkPanelFixture *fixture, | |
475 | gconstpointer user_data) | ||
476 | { | ||
477 | NMConnection *conn; | ||
478 | GtkWidget *sw, *bt_header; | ||
479 | 1 | g_autoptr(GError) error = NULL; | |
480 | |||
481 | /* Add a single connection (just changing up to other test). */ | ||
482 | 1 | test_connection_add (fixture, user_data); | |
483 | |||
484 | /* Basically same as test_connection_add_activate but with different assertions. */ | ||
485 | 1 | nmtst_set_wired_speed (fixture->sinfo, fixture->main_ether, 1234); | |
486 | 1 | nmtst_set_device_state (fixture->sinfo, fixture->main_ether, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_CARRIER); | |
487 | |||
488 | 1 | conn = nmtst_create_minimal_connection ("test-active", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); | |
489 | |||
490 | 1 | nm_device_connection_compatible (fixture->main_ether, conn, &error); | |
491 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | g_assert_no_error (error); |
492 | |||
493 | 1 | g_object_unref (nmtst_add_and_activate_connection (fixture->sinfo, fixture->client, fixture->main_ether, conn)); | |
494 | |||
495 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "test-inactive")); |
496 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "test-active")); |
497 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_null (find_label (GTK_WIDGET (fixture->shell), "52:54:00:ab:db:23")); |
498 | |||
499 | /* We have no switch if there are multiple connections */ | ||
500 | 1 | sw = find_sibling (find_label (GTK_WIDGET (fixture->shell), "test-active"), GTK_TYPE_LIST_BOX_ROW, GTK_TYPE_SWITCH); | |
501 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (sw) |
502 | ✗ | g_assert_false (gtk_widget_is_visible (sw)); | |
503 | |||
504 | /* Now set the state to connected and check the switch state */ | ||
505 | 1 | nmtst_set_device_state (fixture->sinfo, fixture->main_ether, NM_DEVICE_STATE_ACTIVATED, NM_DEVICE_STATE_REASON_NONE); | |
506 | |||
507 | /* Hardware address is shown at this point */ | ||
508 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "52:54:00:ab:db:23")); |
509 | |||
510 | /* Some more checks for unrelated UI not showing up randomly */ | ||
511 | 1 | bt_header = find_label (GTK_WIDGET (fixture->shell), "Bluetooth"); | |
512 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | g_assert_false (bt_header && gtk_widget_is_visible(bt_header)); |
513 | 1 | } | |
514 | |||
515 | /*****************************************************************************/ | ||
516 | |||
517 | static void | ||
518 | 1 | test_vpn_add (NetworkPanelFixture *fixture, | |
519 | gconstpointer user_data) | ||
520 | { | ||
521 | NMConnection *conn; | ||
522 | NMSettingConnection *connsetting; | ||
523 | NMSettingVpn *setting; | ||
524 | |||
525 | 1 | WAIT_DECL() | |
526 | |||
527 | 1 | conn = nmtst_create_minimal_connection ("test_vpn_a", NULL, NM_SETTING_VPN_SETTING_NAME, &connsetting); | |
528 | 1 | setting = nm_connection_get_setting_vpn (conn); | |
529 | 1 | g_object_set (G_OBJECT (connsetting), NM_SETTING_CONNECTION_ID, "A", NULL); | |
530 | 1 | g_object_set (G_OBJECT (setting), NM_SETTING_VPN_SERVICE_TYPE, "org.freedesktop.NetworkManager.vpnc", NULL); | |
531 | |||
532 | 1 | nm_client_add_connection_async (fixture->client, conn, TRUE, NULL, add_cb, &info); | |
533 | |||
534 | 1 | info.other_remaining = 1; | |
535 | 1 | WAIT_CLIENT(fixture->client, 2, NM_CLIENT_CONNECTIONS, NM_CLIENT_CONNECTION_ADDED); | |
536 | |||
537 | 1 | g_object_unref (conn); | |
538 | |||
539 |
3/6✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
|
1 | WAIT_FINISHED(5) |
540 | |||
541 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | g_clear_object (&info.rc); |
542 | |||
543 | /* Make sure it shows up. */ | ||
544 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "A")); |
545 | 1 | } | |
546 | |||
547 | /*****************************************************************************/ | ||
548 | |||
549 | static void | ||
550 | 1 | test_vpn_add_remove (NetworkPanelFixture *fixture, | |
551 | gconstpointer user_data) | ||
552 | { | ||
553 | NMConnection *conn; | ||
554 | NMSettingConnection *connsetting; | ||
555 | NMSettingVpn *setting; | ||
556 | 1 | WAIT_DECL() | |
557 | |||
558 | 1 | conn = nmtst_create_minimal_connection ("test_vpn_a", NULL, NM_SETTING_VPN_SETTING_NAME, &connsetting); | |
559 | 1 | setting = nm_connection_get_setting_vpn (conn); | |
560 | 1 | g_object_set (G_OBJECT (connsetting), NM_SETTING_CONNECTION_ID, "A", NULL); | |
561 | 1 | g_object_set (G_OBJECT (setting), NM_SETTING_VPN_SERVICE_TYPE, "org.freedesktop.NetworkManager.vpnc", NULL); | |
562 | |||
563 | 1 | nm_client_add_connection_async (fixture->client, conn, TRUE, NULL, add_cb, &info); | |
564 | |||
565 | 1 | info.other_remaining = 1; | |
566 | 1 | WAIT_CLIENT(fixture->client, 2, NM_CLIENT_CONNECTIONS, NM_CLIENT_CONNECTION_ADDED); | |
567 | |||
568 |
3/6✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
|
1 | WAIT_FINISHED(5) |
569 | |||
570 | /* Make sure it shows up. */ | ||
571 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "A")); |
572 | |||
573 | /* And delete again */ | ||
574 | 1 | nm_remote_connection_delete_async (info.rc, NULL, delete_cb, &info); | |
575 | |||
576 | 1 | info.other_remaining = 1; | |
577 | 1 | WAIT_CLIENT(fixture->client, 2, NM_CLIENT_CONNECTIONS, NM_CLIENT_CONNECTION_REMOVED); | |
578 | |||
579 |
3/6✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
|
1 | WAIT_FINISHED(5) |
580 | |||
581 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | g_clear_object (&info.rc); |
582 | 1 | g_object_unref (conn); | |
583 | |||
584 | /* Make sure it does not show up. */ | ||
585 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_null (find_label (GTK_WIDGET (fixture->shell), "A")); |
586 | 1 | } | |
587 | |||
588 | /*****************************************************************************/ | ||
589 | |||
590 | static void | ||
591 | 1 | test_vpn_updating (NetworkPanelFixture *fixture, | |
592 | gconstpointer user_data) | ||
593 | { | ||
594 | NMConnection *conn; | ||
595 | NMSettingConnection *connsetting; | ||
596 | NMSettingVpn *setting; | ||
597 | GVariantBuilder builder; | ||
598 | 1 | WAIT_DECL() | |
599 | |||
600 | 1 | conn = nmtst_create_minimal_connection ("test_vpn_a", NULL, NM_SETTING_VPN_SETTING_NAME, &connsetting); | |
601 | 1 | setting = nm_connection_get_setting_vpn (conn); | |
602 | 1 | g_object_set (G_OBJECT (connsetting), NM_SETTING_CONNECTION_ID, "A", NULL); | |
603 | 1 | g_object_set (G_OBJECT (setting), NM_SETTING_VPN_SERVICE_TYPE, "org.freedesktop.NetworkManager.vpnc", NULL); | |
604 | |||
605 | 1 | nm_client_add_connection_async (fixture->client, conn, TRUE, NULL, add_cb, &info); | |
606 | |||
607 | 1 | info.other_remaining = 1; | |
608 | 1 | WAIT_CLIENT(fixture->client, 2, NM_CLIENT_CONNECTIONS, NM_CLIENT_CONNECTION_ADDED); | |
609 | |||
610 |
3/6✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
|
1 | WAIT_FINISHED(5) |
611 | |||
612 | 1 | g_object_unref (conn); | |
613 | |||
614 | /* Make sure it shows up. */ | ||
615 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "A")); |
616 | |||
617 | /* Rename VPN from A to B */ | ||
618 | 1 | g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sa{sv}}")); | |
619 | |||
620 | 1 | g_variant_builder_open (&builder, G_VARIANT_TYPE ("{sa{sv}}")); | |
621 | 1 | g_variant_builder_add (&builder, "s", "connection"); | |
622 | |||
623 | 1 | g_variant_builder_open (&builder, G_VARIANT_TYPE ("a{sv}")); | |
624 | 1 | g_variant_builder_open (&builder, G_VARIANT_TYPE ("{sv}")); | |
625 | 1 | g_variant_builder_add (&builder, "s", "id"); | |
626 | 1 | g_variant_builder_add (&builder, "v", g_variant_new_string ("B")); | |
627 | 1 | g_variant_builder_close (&builder); | |
628 | |||
629 | 1 | g_variant_builder_open (&builder, G_VARIANT_TYPE ("{sv}")); | |
630 | 1 | g_variant_builder_add (&builder, "s", "type"); | |
631 | 1 | g_variant_builder_add (&builder, "v", g_variant_new_string (nm_connection_get_connection_type (NM_CONNECTION (info.rc)))); | |
632 | 1 | g_variant_builder_close (&builder); | |
633 | |||
634 | 1 | g_variant_builder_open (&builder, G_VARIANT_TYPE ("{sv}")); | |
635 | 1 | g_variant_builder_add (&builder, "s", "uuid"); | |
636 | 1 | g_variant_builder_add (&builder, "v", g_variant_new_string (nm_connection_get_uuid (NM_CONNECTION (info.rc)))); | |
637 | 1 | g_variant_builder_close (&builder); | |
638 | |||
639 | 1 | g_variant_builder_close (&builder); | |
640 | 1 | g_variant_builder_close (&builder); | |
641 | |||
642 | 2 | nmtstc_service_update_connection_variant ( | |
643 | fixture->sinfo, | ||
644 | 1 | nm_object_get_path (NM_OBJECT (info.rc)), | |
645 | g_variant_builder_end (&builder), | ||
646 | FALSE); | ||
647 | 1 | g_variant_builder_clear (&builder); | |
648 | |||
649 | 1 | WAIT_CONNECTION(info.rc, 1, "changed"); | |
650 | |||
651 |
3/6✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
|
1 | WAIT_FINISHED(5) |
652 | |||
653 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | g_clear_object (&info.rc); |
654 | |||
655 | /* Make sure it the label got renamed. */ | ||
656 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_null (find_label (GTK_WIDGET (fixture->shell), "A")); |
657 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "B")); |
658 | 1 | } | |
659 | |||
660 | /*****************************************************************************/ | ||
661 | |||
662 | #if 0 /* See note below, where this test is added */ | ||
663 | static void | ||
664 | test_vpn_sorting (NetworkPanelFixture *fixture, | ||
665 | gconstpointer user_data) | ||
666 | { | ||
667 | NMConnection *conn; | ||
668 | NMSettingConnection *connsetting; | ||
669 | NMSettingVpn *setting; | ||
670 | g_autoptr(GError) error = NULL; | ||
671 | GVariantBuilder builder; | ||
672 | GtkWidget *a, *b, *container; | ||
673 | GList *list; | ||
674 | WAIT_DECL() | ||
675 | |||
676 | conn = nmtst_create_minimal_connection ("test_vpn_a", NULL, NM_SETTING_VPN_SETTING_NAME, &connsetting); | ||
677 | setting = nm_connection_get_setting_vpn (conn); | ||
678 | g_object_set (G_OBJECT (connsetting), NM_SETTING_CONNECTION_ID, "A", NULL); | ||
679 | g_object_set (G_OBJECT (setting), NM_SETTING_VPN_SERVICE_TYPE, "org.freedesktop.NetworkManager.vpnc", NULL); | ||
680 | |||
681 | nm_client_add_connection_async (fixture->client, conn, TRUE, NULL, add_cb, &info); | ||
682 | |||
683 | info.other_remaining = 1; | ||
684 | WAIT_CLIENT(fixture->client, 2, NM_CLIENT_CONNECTIONS, NM_CLIENT_CONNECTION_ADDED); | ||
685 | |||
686 | WAIT_FINISHED(5) | ||
687 | |||
688 | g_object_unref (conn); | ||
689 | g_clear_object (&info.rc); | ||
690 | |||
691 | /* Create a second VPN which should be in front in the list */ | ||
692 | conn = nmtst_create_minimal_connection ("test_vpn_b", NULL, NM_SETTING_VPN_SETTING_NAME, &connsetting); | ||
693 | setting = nm_connection_get_setting_vpn (conn); | ||
694 | g_object_set (G_OBJECT (connsetting), NM_SETTING_CONNECTION_ID, "1", NULL); | ||
695 | g_object_set (G_OBJECT (setting), NM_SETTING_VPN_SERVICE_TYPE, "org.freedesktop.NetworkManager.vpnc", NULL); | ||
696 | |||
697 | nm_client_add_connection_async (fixture->client, conn, TRUE, NULL, add_cb, &info); | ||
698 | |||
699 | info.other_remaining = 1; | ||
700 | WAIT_CLIENT(fixture->client, 2, NM_CLIENT_CONNECTIONS, NM_CLIENT_CONNECTION_ADDED); | ||
701 | |||
702 | WAIT_FINISHED(5) | ||
703 | |||
704 | g_object_unref (conn); | ||
705 | |||
706 | /* Make sure both VPNs are there. */ | ||
707 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "A")); | ||
708 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "1")); | ||
709 | |||
710 | /* And test that A is after 1 */ | ||
711 | a = find_parent_of_type (find_label (GTK_WIDGET (fixture->shell), "A"), GTK_TYPE_STACK); | ||
712 | b = find_parent_of_type (find_label (GTK_WIDGET (fixture->shell), "1"), GTK_TYPE_STACK); | ||
713 | container = gtk_widget_get_parent (a); | ||
714 | list = gtk_container_get_children (GTK_CONTAINER (container)); | ||
715 | g_assert_cmpint (g_list_index (list, a), >, g_list_index (list, b)); | ||
716 | g_list_free (list); | ||
717 | |||
718 | /* Rename VPN from 1 to B */ | ||
719 | g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sa{sv}}")); | ||
720 | |||
721 | g_variant_builder_open (&builder, G_VARIANT_TYPE ("{sa{sv}}")); | ||
722 | g_variant_builder_add (&builder, "s", "connection"); | ||
723 | |||
724 | g_variant_builder_open (&builder, G_VARIANT_TYPE ("a{sv}")); | ||
725 | g_variant_builder_open (&builder, G_VARIANT_TYPE ("{sv}")); | ||
726 | g_variant_builder_add (&builder, "s", "id"); | ||
727 | g_variant_builder_add (&builder, "v", g_variant_new_string ("B")); | ||
728 | g_variant_builder_close (&builder); | ||
729 | |||
730 | g_variant_builder_open (&builder, G_VARIANT_TYPE ("{sv}")); | ||
731 | g_variant_builder_add (&builder, "s", "type"); | ||
732 | g_variant_builder_add (&builder, "v", g_variant_new_string (nm_connection_get_connection_type (NM_CONNECTION (info.rc)))); | ||
733 | g_variant_builder_close (&builder); | ||
734 | |||
735 | g_variant_builder_open (&builder, G_VARIANT_TYPE ("{sv}")); | ||
736 | g_variant_builder_add (&builder, "s", "uuid"); | ||
737 | g_variant_builder_add (&builder, "v", g_variant_new_string (nm_connection_get_uuid (NM_CONNECTION (info.rc)))); | ||
738 | g_variant_builder_close (&builder); | ||
739 | |||
740 | g_variant_builder_close (&builder); | ||
741 | g_variant_builder_close (&builder); | ||
742 | |||
743 | nmtstc_service_update_connection_variant ( | ||
744 | fixture->sinfo, | ||
745 | nm_object_get_path (NM_OBJECT (info.rc)), | ||
746 | g_variant_builder_end (&builder), | ||
747 | FALSE); | ||
748 | g_variant_builder_clear (&builder); | ||
749 | |||
750 | WAIT_CONNECTION(info.rc, 1, "changed"); | ||
751 | |||
752 | WAIT_FINISHED(5) | ||
753 | |||
754 | g_clear_object (&info.rc); | ||
755 | |||
756 | /* Make sure it the label got renamed. */ | ||
757 | g_assert_null (find_label (GTK_WIDGET (fixture->shell), "1")); | ||
758 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "A")); | ||
759 | g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "B")); | ||
760 | |||
761 | /* And test that A is before B */ | ||
762 | a = find_parent_of_type (find_label (GTK_WIDGET (fixture->shell), "A"), GTK_TYPE_STACK); | ||
763 | b = find_parent_of_type (find_label (GTK_WIDGET (fixture->shell), "B"), GTK_TYPE_STACK); | ||
764 | container = gtk_widget_get_parent (a); | ||
765 | list = gtk_container_get_children (GTK_CONTAINER (container)); | ||
766 | g_assert_cmpint (g_list_index (list, a), <, g_list_index (list, b)); | ||
767 | g_list_free (list); | ||
768 | } | ||
769 | #endif | ||
770 | |||
771 | /*****************************************************************************/ | ||
772 | |||
773 | int | ||
774 | 1 | main (int argc, char **argv) | |
775 | { | ||
776 | 1 | g_setenv ("GSETTINGS_BACKEND", "memory", TRUE); | |
777 | 1 | g_setenv ("LIBNM_USE_SESSION_BUS", "1", TRUE); | |
778 | 1 | g_setenv ("LC_ALL", "C", TRUE); | |
779 | |||
780 | 1 | gtk_test_init (&argc, &argv, NULL); | |
781 | 1 | adw_init (); | |
782 | |||
783 | 1 | g_test_add ("/network-panel-wired/empty-ui", | |
784 | NetworkPanelFixture, | ||
785 | NULL, | ||
786 | fixture_set_up_empty, | ||
787 | test_empty_ui, | ||
788 | fixture_tear_down); | ||
789 | |||
790 | 1 | g_test_add ("/network-panel-wired/device-add", | |
791 | NetworkPanelFixture, | ||
792 | NULL, | ||
793 | fixture_set_up_empty, | ||
794 | test_device_add, | ||
795 | fixture_tear_down); | ||
796 | |||
797 | 1 | g_test_add ("/network-panel-wired/second-device-add", | |
798 | NetworkPanelFixture, | ||
799 | NULL, | ||
800 | fixture_set_up_empty, | ||
801 | test_second_device_add, | ||
802 | fixture_tear_down); | ||
803 | |||
804 | 1 | g_test_add ("/network-panel-wired/second-device-add-remove", | |
805 | NetworkPanelFixture, | ||
806 | NULL, | ||
807 | fixture_set_up_empty, | ||
808 | test_second_device_add_remove, | ||
809 | fixture_tear_down); | ||
810 | |||
811 | 1 | g_test_add ("/network-panel-wired/unconnected-carrier-plug", | |
812 | NetworkPanelFixture, | ||
813 | NULL, | ||
814 | fixture_set_up_wired, | ||
815 | test_unconnected_carrier_plug, | ||
816 | fixture_tear_down); | ||
817 | |||
818 | 1 | g_test_add ("/network-panel-wired/connection-add", | |
819 | NetworkPanelFixture, | ||
820 | NULL, | ||
821 | fixture_set_up_wired, | ||
822 | test_connection_add, | ||
823 | fixture_tear_down); | ||
824 | |||
825 | 1 | g_test_add ("/network-panel-wired/connection-add-activate", | |
826 | NetworkPanelFixture, | ||
827 | NULL, | ||
828 | fixture_set_up_wired, | ||
829 | test_connection_add_activate, | ||
830 | fixture_tear_down); | ||
831 | |||
832 | 1 | g_test_add ("/network-panel-wired/connection-multi-add-activate", | |
833 | NetworkPanelFixture, | ||
834 | NULL, | ||
835 | fixture_set_up_wired, | ||
836 | test_connection_multi_add_activate, | ||
837 | fixture_tear_down); | ||
838 | |||
839 | 1 | g_test_add ("/network-panel-wired/vpn-add", | |
840 | NetworkPanelFixture, | ||
841 | NULL, | ||
842 | fixture_set_up_empty, | ||
843 | test_vpn_add, | ||
844 | fixture_tear_down); | ||
845 | |||
846 | 1 | g_test_add ("/network-panel-wired/vpn-add-remove", | |
847 | NetworkPanelFixture, | ||
848 | NULL, | ||
849 | fixture_set_up_empty, | ||
850 | test_vpn_add_remove, | ||
851 | fixture_tear_down); | ||
852 | |||
853 | 1 | g_test_add ("/network-panel-wired/vpn-updating", | |
854 | NetworkPanelFixture, | ||
855 | NULL, | ||
856 | fixture_set_up_empty, | ||
857 | test_vpn_updating, | ||
858 | fixture_tear_down); | ||
859 | |||
860 | #if 0 | ||
861 | /* | ||
862 | * FIXME: Currently broken, so test is disabled. Test will likely need | ||
863 | * updating when this is fixed to look for GTK_TYPE_LIST_BOX_ROW rather | ||
864 | * than GTK_TYPE_STACK. | ||
865 | */ | ||
866 | g_test_add ("/network-panel-wired/vpn-sorting", | ||
867 | NetworkPanelFixture, | ||
868 | NULL, | ||
869 | fixture_set_up_empty, | ||
870 | test_vpn_sorting, | ||
871 | fixture_tear_down); | ||
872 | #endif | ||
873 | |||
874 | 1 | return g_test_run (); | |
875 | } | ||
876 | |||
877 |