1 /* GLib testing framework examples and tests
3 * Copyright (C) 2008-2010 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: David Zeuthen <davidz@redhat.com>
26 #include "gdbus-tests.h"
28 /* all tests rely on a shared mainloop */
29 static GMainLoop *loop;
31 /* ---------------------------------------------------------------------------------------------------- */
32 /* Test that g_bus_own_name() works correctly */
33 /* ---------------------------------------------------------------------------------------------------- */
38 gboolean expect_null_connection;
39 guint num_bus_acquired;
46 own_name_data_free_func (OwnNameData *data)
48 data->num_free_func++;
49 g_main_loop_quit (loop);
53 bus_acquired_handler (GDBusConnection *connection,
57 OwnNameData *data = user_data;
58 g_dbus_connection_set_exit_on_close (connection, FALSE);
59 data->num_bus_acquired += 1;
60 g_main_loop_quit (loop);
64 name_acquired_handler (GDBusConnection *connection,
68 OwnNameData *data = user_data;
69 data->num_acquired += 1;
70 g_main_loop_quit (loop);
74 name_lost_handler (GDBusConnection *connection,
78 OwnNameData *data = user_data;
79 if (data->expect_null_connection)
81 g_assert (connection == NULL);
85 g_assert (connection != NULL);
86 g_dbus_connection_set_exit_on_close (connection, FALSE);
89 g_main_loop_quit (loop);
93 test_bus_own_name (void)
102 gboolean name_has_owner_reply;
107 name = "org.gtk.GDBus.Name1";
110 * First check that name_lost_handler() is invoked if there is no bus.
112 * Also make sure name_lost_handler() isn't invoked when unowning the name.
114 data.num_bus_acquired = 0;
115 data.num_free_func = 0;
116 data.num_acquired = 0;
118 data.expect_null_connection = TRUE;
119 id = g_bus_own_name (G_BUS_TYPE_SESSION,
121 G_BUS_NAME_OWNER_FLAGS_NONE,
122 bus_acquired_handler,
123 name_acquired_handler,
126 (GDestroyNotify) own_name_data_free_func);
127 g_assert_cmpint (data.num_bus_acquired, ==, 0);
128 g_assert_cmpint (data.num_acquired, ==, 0);
129 g_assert_cmpint (data.num_lost, ==, 0);
130 g_main_loop_run (loop);
131 g_assert_cmpint (data.num_bus_acquired, ==, 0);
132 g_assert_cmpint (data.num_acquired, ==, 0);
133 g_assert_cmpint (data.num_lost, ==, 1);
134 g_bus_unown_name (id);
135 g_assert_cmpint (data.num_acquired, ==, 0);
136 g_assert_cmpint (data.num_lost, ==, 1);
137 g_assert_cmpint (data.num_free_func, ==, 1);
140 * Bring up a bus, then own a name and check bus_acquired_handler() then name_acquired_handler() is invoked.
143 data.num_bus_acquired = 0;
144 data.num_acquired = 0;
146 data.expect_null_connection = FALSE;
147 id = g_bus_own_name (G_BUS_TYPE_SESSION,
149 G_BUS_NAME_OWNER_FLAGS_NONE,
150 bus_acquired_handler,
151 name_acquired_handler,
154 (GDestroyNotify) own_name_data_free_func);
155 g_assert_cmpint (data.num_bus_acquired, ==, 0);
156 g_assert_cmpint (data.num_acquired, ==, 0);
157 g_assert_cmpint (data.num_lost, ==, 0);
158 g_main_loop_run (loop);
159 g_assert_cmpint (data.num_bus_acquired, ==, 1);
160 g_assert_cmpint (data.num_acquired, ==, 0);
161 g_assert_cmpint (data.num_lost, ==, 0);
162 g_main_loop_run (loop);
163 g_assert_cmpint (data.num_bus_acquired, ==, 1);
164 g_assert_cmpint (data.num_acquired, ==, 1);
165 g_assert_cmpint (data.num_lost, ==, 0);
168 * Check that the name was actually acquired.
170 c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
171 g_assert (c != NULL);
172 g_assert (!g_dbus_connection_is_closed (c));
173 result = g_dbus_connection_call_sync (c,
174 "org.freedesktop.DBus", /* bus name */
175 "/org/freedesktop/DBus", /* object path */
176 "org.freedesktop.DBus", /* interface name */
177 "NameHasOwner", /* method name */
178 g_variant_new ("(s)", name),
179 G_VARIANT_TYPE ("(b)"),
180 G_DBUS_CALL_FLAGS_NONE,
184 g_assert_no_error (error);
185 g_assert (result != NULL);
186 g_variant_get (result, "(b)", &name_has_owner_reply);
187 g_assert (name_has_owner_reply);
188 g_variant_unref (result);
191 * Stop owning the name - this should invoke our free func
193 g_bus_unown_name (id);
194 g_assert_cmpint (data.num_free_func, ==, 2);
197 * Check that the name was actually released.
199 result = g_dbus_connection_call_sync (c,
200 "org.freedesktop.DBus", /* bus name */
201 "/org/freedesktop/DBus", /* object path */
202 "org.freedesktop.DBus", /* interface name */
203 "NameHasOwner", /* method name */
204 g_variant_new ("(s)", name),
205 G_VARIANT_TYPE ("(b)"),
206 G_DBUS_CALL_FLAGS_NONE,
210 g_assert_no_error (error);
211 g_assert (result != NULL);
212 g_variant_get (result, "(b)", &name_has_owner_reply);
213 g_assert (!name_has_owner_reply);
214 g_variant_unref (result);
216 /* Now try owning the name and then immediately decide to unown the name */
217 g_assert_cmpint (data.num_bus_acquired, ==, 1);
218 g_assert_cmpint (data.num_acquired, ==, 1);
219 g_assert_cmpint (data.num_lost, ==, 0);
220 g_assert_cmpint (data.num_free_func, ==, 2);
221 id = g_bus_own_name (G_BUS_TYPE_SESSION,
223 G_BUS_NAME_OWNER_FLAGS_NONE,
224 bus_acquired_handler,
225 name_acquired_handler,
228 (GDestroyNotify) own_name_data_free_func);
229 g_assert_cmpint (data.num_bus_acquired, ==, 1);
230 g_assert_cmpint (data.num_acquired, ==, 1);
231 g_assert_cmpint (data.num_lost, ==, 0);
232 g_assert_cmpint (data.num_free_func, ==, 2);
233 g_bus_unown_name (id);
234 g_assert_cmpint (data.num_bus_acquired, ==, 1);
235 g_assert_cmpint (data.num_acquired, ==, 1);
236 g_assert_cmpint (data.num_lost, ==, 0);
237 g_assert_cmpint (data.num_free_func, ==, 2);
238 g_main_loop_run (loop); /* the GDestroyNotify is called in idle because the bus is acquired in idle */
239 g_assert_cmpint (data.num_free_func, ==, 3);
242 * Own the name again.
244 data.num_bus_acquired = 0;
245 data.num_acquired = 0;
247 data.expect_null_connection = FALSE;
248 id = g_bus_own_name_with_closures (G_BUS_TYPE_SESSION,
250 G_BUS_NAME_OWNER_FLAGS_NONE,
251 g_cclosure_new (G_CALLBACK (bus_acquired_handler),
254 g_cclosure_new (G_CALLBACK (name_acquired_handler),
257 g_cclosure_new (G_CALLBACK (name_lost_handler),
259 (GClosureNotify) own_name_data_free_func));
260 g_assert_cmpint (data.num_bus_acquired, ==, 0);
261 g_assert_cmpint (data.num_acquired, ==, 0);
262 g_assert_cmpint (data.num_lost, ==, 0);
263 g_main_loop_run (loop);
264 g_assert_cmpint (data.num_bus_acquired, ==, 1);
265 g_assert_cmpint (data.num_acquired, ==, 0);
266 g_assert_cmpint (data.num_lost, ==, 0);
267 g_main_loop_run (loop);
268 g_assert_cmpint (data.num_bus_acquired, ==, 1);
269 g_assert_cmpint (data.num_acquired, ==, 1);
270 g_assert_cmpint (data.num_lost, ==, 0);
273 * Try owning the name with another object on the same connection - this should
274 * fail because we already own the name.
276 data2.num_free_func = 0;
277 data2.num_bus_acquired = 0;
278 data2.num_acquired = 0;
280 data2.expect_null_connection = FALSE;
281 id2 = g_bus_own_name (G_BUS_TYPE_SESSION,
283 G_BUS_NAME_OWNER_FLAGS_NONE,
284 bus_acquired_handler,
285 name_acquired_handler,
288 (GDestroyNotify) own_name_data_free_func);
289 g_assert_cmpint (data2.num_bus_acquired, ==, 0);
290 g_assert_cmpint (data2.num_acquired, ==, 0);
291 g_assert_cmpint (data2.num_lost, ==, 0);
292 g_main_loop_run (loop);
293 g_assert_cmpint (data2.num_bus_acquired, ==, 1);
294 g_assert_cmpint (data2.num_acquired, ==, 0);
295 g_assert_cmpint (data2.num_lost, ==, 0);
296 g_main_loop_run (loop);
297 g_assert_cmpint (data2.num_bus_acquired, ==, 1);
298 g_assert_cmpint (data2.num_acquired, ==, 0);
299 g_assert_cmpint (data2.num_lost, ==, 1);
300 g_bus_unown_name (id2);
301 g_assert_cmpint (data2.num_bus_acquired, ==, 1);
302 g_assert_cmpint (data2.num_acquired, ==, 0);
303 g_assert_cmpint (data2.num_lost, ==, 1);
304 g_assert_cmpint (data2.num_free_func, ==, 1);
307 * Create a secondary (e.g. private) connection and try owning the name on that
308 * connection. This should fail both with and without _REPLACE because we
309 * didn't specify ALLOW_REPLACEMENT.
311 c2 = _g_bus_get_priv (G_BUS_TYPE_SESSION, NULL, NULL);
312 g_assert (c2 != NULL);
313 g_assert (!g_dbus_connection_is_closed (c2));
314 /* first without _REPLACE */
315 data2.num_bus_acquired = 0;
316 data2.num_acquired = 0;
318 data2.expect_null_connection = FALSE;
319 data2.num_free_func = 0;
320 id2 = g_bus_own_name_on_connection (c2,
322 G_BUS_NAME_OWNER_FLAGS_NONE,
323 name_acquired_handler,
326 (GDestroyNotify) own_name_data_free_func);
327 g_assert_cmpint (data2.num_bus_acquired, ==, 0);
328 g_assert_cmpint (data2.num_acquired, ==, 0);
329 g_assert_cmpint (data2.num_lost, ==, 0);
330 g_main_loop_run (loop);
331 g_assert_cmpint (data2.num_bus_acquired, ==, 0);
332 g_assert_cmpint (data2.num_acquired, ==, 0);
333 g_assert_cmpint (data2.num_lost, ==, 1);
334 g_bus_unown_name (id2);
335 g_assert_cmpint (data2.num_bus_acquired, ==, 0);
336 g_assert_cmpint (data2.num_acquired, ==, 0);
337 g_assert_cmpint (data2.num_lost, ==, 1);
338 g_assert_cmpint (data2.num_free_func, ==, 1);
339 /* then with _REPLACE */
340 data2.num_bus_acquired = 0;
341 data2.num_acquired = 0;
343 data2.expect_null_connection = FALSE;
344 data2.num_free_func = 0;
345 id2 = g_bus_own_name_on_connection (c2,
347 G_BUS_NAME_OWNER_FLAGS_REPLACE,
348 name_acquired_handler,
351 (GDestroyNotify) own_name_data_free_func);
352 g_assert_cmpint (data2.num_bus_acquired, ==, 0);
353 g_assert_cmpint (data2.num_acquired, ==, 0);
354 g_assert_cmpint (data2.num_lost, ==, 0);
355 g_main_loop_run (loop);
356 g_assert_cmpint (data2.num_bus_acquired, ==, 0);
357 g_assert_cmpint (data2.num_acquired, ==, 0);
358 g_assert_cmpint (data2.num_lost, ==, 1);
359 g_bus_unown_name (id2);
360 g_assert_cmpint (data2.num_bus_acquired, ==, 0);
361 g_assert_cmpint (data2.num_acquired, ==, 0);
362 g_assert_cmpint (data2.num_lost, ==, 1);
363 g_assert_cmpint (data2.num_free_func, ==, 1);
366 * Stop owning the name and grab it again with _ALLOW_REPLACEMENT.
368 data.expect_null_connection = FALSE;
369 g_bus_unown_name (id);
370 g_assert_cmpint (data.num_bus_acquired, ==, 1);
371 g_assert_cmpint (data.num_acquired, ==, 1);
372 g_assert_cmpint (data.num_free_func, ==, 4);
374 data.num_bus_acquired = 0;
375 data.num_acquired = 0;
377 data.expect_null_connection = FALSE;
378 id = g_bus_own_name (G_BUS_TYPE_SESSION,
380 G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT,
381 bus_acquired_handler,
382 name_acquired_handler,
385 (GDestroyNotify) own_name_data_free_func);
386 g_assert_cmpint (data.num_bus_acquired, ==, 0);
387 g_assert_cmpint (data.num_acquired, ==, 0);
388 g_assert_cmpint (data.num_lost, ==, 0);
389 g_main_loop_run (loop);
390 g_assert_cmpint (data.num_bus_acquired, ==, 1);
391 g_assert_cmpint (data.num_acquired, ==, 0);
392 g_assert_cmpint (data.num_lost, ==, 0);
393 g_main_loop_run (loop);
394 g_assert_cmpint (data.num_bus_acquired, ==, 1);
395 g_assert_cmpint (data.num_acquired, ==, 1);
396 g_assert_cmpint (data.num_lost, ==, 0);
399 * Now try to grab the name from the secondary connection.
402 /* first without _REPLACE - this won't make us acquire the name */
403 data2.num_bus_acquired = 0;
404 data2.num_acquired = 0;
406 data2.expect_null_connection = FALSE;
407 data2.num_free_func = 0;
408 id2 = g_bus_own_name_on_connection (c2,
410 G_BUS_NAME_OWNER_FLAGS_NONE,
411 name_acquired_handler,
414 (GDestroyNotify) own_name_data_free_func);
415 g_assert_cmpint (data2.num_bus_acquired, ==, 0);
416 g_assert_cmpint (data2.num_acquired, ==, 0);
417 g_assert_cmpint (data2.num_lost, ==, 0);
418 g_main_loop_run (loop);
419 g_assert_cmpint (data2.num_bus_acquired, ==, 0);
420 g_assert_cmpint (data2.num_acquired, ==, 0);
421 g_assert_cmpint (data2.num_lost, ==, 1);
422 g_bus_unown_name (id2);
423 g_assert_cmpint (data2.num_bus_acquired, ==, 0);
424 g_assert_cmpint (data2.num_acquired, ==, 0);
425 g_assert_cmpint (data2.num_lost, ==, 1);
426 g_assert_cmpint (data2.num_free_func, ==, 1);
427 /* then with _REPLACE - here we should acquire the name - e.g. owner should lose it
428 * and owner2 should acquire it */
429 data2.num_bus_acquired = 0;
430 data2.num_acquired = 0;
432 data2.expect_null_connection = FALSE;
433 data2.num_free_func = 0;
434 id2 = g_bus_own_name_on_connection (c2,
436 G_BUS_NAME_OWNER_FLAGS_REPLACE,
437 name_acquired_handler,
440 (GDestroyNotify) own_name_data_free_func);
441 g_assert_cmpint (data.num_acquired, ==, 1);
442 g_assert_cmpint (data.num_lost, ==, 0);
443 g_assert_cmpint (data2.num_acquired, ==, 0);
444 g_assert_cmpint (data2.num_lost, ==, 0);
445 /* wait for handlers for both owner and owner2 to fire */
446 while (data.num_lost == 0 || data2.num_acquired == 0)
447 g_main_loop_run (loop);
448 g_assert_cmpint (data.num_acquired, ==, 1);
449 g_assert_cmpint (data.num_lost, ==, 1);
450 g_assert_cmpint (data2.num_acquired, ==, 1);
451 g_assert_cmpint (data2.num_lost, ==, 0);
452 g_assert_cmpint (data2.num_bus_acquired, ==, 0);
453 /* ok, make owner2 release the name - then wait for owner to automagically reacquire it */
454 g_bus_unown_name (id2);
455 g_assert_cmpint (data2.num_free_func, ==, 1);
456 g_main_loop_run (loop);
457 g_assert_cmpint (data.num_acquired, ==, 2);
458 g_assert_cmpint (data.num_lost, ==, 1);
461 * Finally, nuke the bus and check name_lost_handler() is invoked.
464 data.expect_null_connection = TRUE;
466 while (data.num_lost != 2)
467 g_main_loop_run (loop);
468 g_assert_cmpint (data.num_acquired, ==, 2);
469 g_assert_cmpint (data.num_lost, ==, 2);
470 g_bus_unown_name (id);
471 g_assert_cmpint (data.num_free_func, ==, 5);
479 /* ---------------------------------------------------------------------------------------------------- */
480 /* Test that g_bus_watch_name() works correctly */
481 /* ---------------------------------------------------------------------------------------------------- */
485 gboolean expect_null_connection;
494 watch_name_data_free_func (WatchNameData *data)
496 data->num_free_func++;
497 g_main_loop_quit (loop);
501 w_bus_acquired_handler (GDBusConnection *connection,
508 w_name_acquired_handler (GDBusConnection *connection,
512 WatchNameData *data = user_data;
513 data->num_acquired += 1;
514 g_main_loop_quit (loop);
518 w_name_lost_handler (GDBusConnection *connection,
522 WatchNameData *data = user_data;
524 g_main_loop_quit (loop);
528 name_appeared_handler (GDBusConnection *connection,
530 const gchar *name_owner,
533 WatchNameData *data = user_data;
534 if (data->expect_null_connection)
536 g_assert (connection == NULL);
540 g_assert (connection != NULL);
541 g_dbus_connection_set_exit_on_close (connection, FALSE);
543 data->num_appeared += 1;
544 g_main_loop_quit (loop);
548 name_vanished_handler (GDBusConnection *connection,
552 WatchNameData *data = user_data;
553 if (data->expect_null_connection)
555 g_assert (connection == NULL);
559 g_assert (connection != NULL);
560 g_dbus_connection_set_exit_on_close (connection, FALSE);
562 data->num_vanished += 1;
563 g_main_loop_quit (loop);
567 test_bus_watch_name (void)
572 GDBusConnection *connection;
575 * First check that name_vanished_handler() is invoked if there is no bus.
577 * Also make sure name_vanished_handler() isn't invoked when unwatching the name.
579 data.num_free_func = 0;
580 data.num_appeared = 0;
581 data.num_vanished = 0;
582 data.expect_null_connection = TRUE;
583 id = g_bus_watch_name (G_BUS_TYPE_SESSION,
584 "org.gtk.GDBus.Name1",
585 G_BUS_NAME_WATCHER_FLAGS_NONE,
586 name_appeared_handler,
587 name_vanished_handler,
589 (GDestroyNotify) watch_name_data_free_func);
590 g_assert_cmpint (data.num_appeared, ==, 0);
591 g_assert_cmpint (data.num_vanished, ==, 0);
592 g_main_loop_run (loop);
593 g_assert_cmpint (data.num_appeared, ==, 0);
594 g_assert_cmpint (data.num_vanished, ==, 1);
595 g_bus_unwatch_name (id);
596 g_assert_cmpint (data.num_appeared, ==, 0);
597 g_assert_cmpint (data.num_vanished, ==, 1);
598 g_assert_cmpint (data.num_free_func, ==, 1);
601 * Now bring up a bus, own a name, and then start watching it.
605 data.num_free_func = 0;
606 data.num_acquired = 0;
608 data.expect_null_connection = FALSE;
609 owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
610 "org.gtk.GDBus.Name1",
611 G_BUS_NAME_OWNER_FLAGS_NONE,
612 w_bus_acquired_handler,
613 w_name_acquired_handler,
616 (GDestroyNotify) watch_name_data_free_func);
617 g_main_loop_run (loop);
618 g_assert_cmpint (data.num_acquired, ==, 1);
619 g_assert_cmpint (data.num_lost, ==, 0);
621 connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
622 g_assert (connection != NULL);
624 /* now watch the name */
625 data.num_appeared = 0;
626 data.num_vanished = 0;
627 id = g_bus_watch_name_on_connection (connection,
628 "org.gtk.GDBus.Name1",
629 G_BUS_NAME_WATCHER_FLAGS_NONE,
630 name_appeared_handler,
631 name_vanished_handler,
633 (GDestroyNotify) watch_name_data_free_func);
634 g_assert_cmpint (data.num_appeared, ==, 0);
635 g_assert_cmpint (data.num_vanished, ==, 0);
636 g_main_loop_run (loop);
637 g_assert_cmpint (data.num_appeared, ==, 1);
638 g_assert_cmpint (data.num_vanished, ==, 0);
643 g_bus_unwatch_name (id);
644 g_assert_cmpint (data.num_free_func, ==, 1);
646 g_object_unref (connection);
649 g_bus_unown_name (owner_id);
650 g_assert_cmpint (data.num_acquired, ==, 1);
651 g_assert_cmpint (data.num_free_func, ==, 2);
654 * Create a watcher and then make a name be owned.
656 * This should trigger name_appeared_handler() ...
659 data.num_appeared = 0;
660 data.num_vanished = 0;
661 data.num_free_func = 0;
662 id = g_bus_watch_name_with_closures (G_BUS_TYPE_SESSION,
663 "org.gtk.GDBus.Name1",
664 G_BUS_NAME_WATCHER_FLAGS_NONE,
665 g_cclosure_new (G_CALLBACK (name_appeared_handler),
668 g_cclosure_new (G_CALLBACK (name_vanished_handler),
670 (GClosureNotify) watch_name_data_free_func));
671 g_assert_cmpint (data.num_appeared, ==, 0);
672 g_assert_cmpint (data.num_vanished, ==, 0);
673 g_main_loop_run (loop);
674 g_assert_cmpint (data.num_appeared, ==, 0);
675 g_assert_cmpint (data.num_vanished, ==, 1);
678 data.num_acquired = 0;
680 data.expect_null_connection = FALSE;
681 owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
682 "org.gtk.GDBus.Name1",
683 G_BUS_NAME_OWNER_FLAGS_NONE,
684 w_bus_acquired_handler,
685 w_name_acquired_handler,
688 (GDestroyNotify) watch_name_data_free_func);
689 while (data.num_acquired == 0 || data.num_appeared == 0)
690 g_main_loop_run (loop);
691 g_assert_cmpint (data.num_acquired, ==, 1);
692 g_assert_cmpint (data.num_lost, ==, 0);
693 g_assert_cmpint (data.num_appeared, ==, 1);
694 g_assert_cmpint (data.num_vanished, ==, 1);
697 * Nuke the bus and check that the name vanishes and is lost.
699 data.expect_null_connection = TRUE;
701 g_main_loop_run (loop);
702 g_assert_cmpint (data.num_lost, ==, 1);
703 g_assert_cmpint (data.num_vanished, ==, 2);
705 g_bus_unwatch_name (id);
706 g_assert_cmpint (data.num_free_func, ==, 1);
708 g_bus_unown_name (owner_id);
709 g_assert_cmpint (data.num_free_func, ==, 2);
714 /* ---------------------------------------------------------------------------------------------------- */
717 test_validate_names (void)
727 { 1, 0, 1, "valid.well_known.name"},
728 { 1, 0, 0, "valid.well-known.name"},
729 { 1, 1, 0, ":valid.unique.name"},
730 { 0, 0, 0, "invalid.5well_known.name"},
731 { 0, 0, 0, "4invalid.5well_known.name"},
732 { 1, 1, 0, ":4valid.5unique.name"},
734 { 1, 0, 1, "very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.name1"}, /* 255 */
735 { 0, 0, 0, "very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.very.long.name12"}, /* 256 - too long! */
736 { 0, 0, 0, ".starts.with.a.dot"},
737 { 0, 0, 0, "contains.invalid;.characters"},
738 { 0, 0, 0, "contains.inva/lid.characters"},
739 { 0, 0, 0, "contains.inva[lid.characters"},
740 { 0, 0, 0, "contains.inva]lid.characters"},
741 { 0, 0, 0, "contains.inva_æøå_lid.characters"},
745 for (n = 0; n < G_N_ELEMENTS (names); n++)
748 g_assert (g_dbus_is_name (names[n].string));
750 g_assert (!g_dbus_is_name (names[n].string));
753 g_assert (g_dbus_is_unique_name (names[n].string));
755 g_assert (!g_dbus_is_unique_name (names[n].string));
757 if (names[n].interface)
758 g_assert (g_dbus_is_interface_name (names[n].string));
760 g_assert (!g_dbus_is_interface_name (names[n].string));
764 /* ---------------------------------------------------------------------------------------------------- */
772 g_test_init (&argc, &argv, NULL);
774 loop = g_main_loop_new (NULL, FALSE);
776 g_test_dbus_unset ();
778 g_test_add_func ("/gdbus/validate-names", test_validate_names);
779 g_test_add_func ("/gdbus/bus-own-name", test_bus_own_name);
780 g_test_add_func ("/gdbus/bus-watch-name", test_bus_watch_name);
784 g_main_loop_unref (loop);