1 /* Test support for shortening connection service names.
2 *
3 * Copyright (C) 2007-2009 Collabora Ltd. <http://www.collabora.co.uk/>
4 * Copyright (C) 2007-2009 Nokia Corporation
5 *
6 * Copying and distribution of this file, with or without modification,
7 * are permitted in any medium without royalty provided the copyright
8 * notice and this notice are preserved.
9 */
10
11 #include "config.h"
12
13 #include <string.h>
14
15 #include <telepathy-glib/channel.h>
16 #include <telepathy-glib/connection.h>
17 #include <telepathy-glib/dbus.h>
18 #include <telepathy-glib/debug.h>
19 #include <telepathy-glib/gtypes.h>
20 #include <telepathy-glib/interfaces.h>
21
22 #include "tests/lib/echo-chan.h"
23 #include "tests/lib/echo-conn.h"
24 #include "tests/lib/myassert.h"
25 #include "tests/lib/util.h"
26
27 /* 256 characters */
28 #define LONG_ACCOUNT_IS_LONG \
29 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
30 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
31 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
32 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
33
34 int
main(int argc,char ** argv)35 main (int argc,
36 char **argv)
37 {
38 TpDBusDaemon *dbus;
39 TpTestsEchoConnection *service_conn;
40 TpBaseConnection *service_conn_as_base;
41 GError *error = NULL;
42 gchar *name;
43 gchar *conn_path;
44
45 tp_tests_abort_after (10);
46 dbus = tp_tests_dbus_daemon_dup_or_die ();
47
48 MYASSERT (strlen (LONG_ACCOUNT_IS_LONG) == 256, "");
49 service_conn = TP_TESTS_ECHO_CONNECTION (tp_tests_object_new_static_class (
50 TP_TESTS_TYPE_ECHO_CONNECTION,
51 "account", LONG_ACCOUNT_IS_LONG,
52 "protocol", "example",
53 NULL));
54 service_conn_as_base = TP_BASE_CONNECTION (service_conn);
55 MYASSERT (service_conn != NULL, "");
56 MYASSERT (service_conn_as_base != NULL, "");
57
58 MYASSERT (tp_base_connection_register (service_conn_as_base, "example",
59 &name, &conn_path, &error), "");
60 g_assert_no_error (error);
61 /* Name is too long to be used unmodified; check that it's shortened to 255
62 * characters.
63 */
64 MYASSERT (strlen (name) == 255, "");
65
66 g_object_unref (service_conn);
67 g_object_unref (dbus);
68 g_free (name);
69 g_free (conn_path);
70 return 0;
71 }
72