File: long-connection-name.c

package info (click to toggle)
telepathy-glib 0.24.1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 34,628 kB
  • sloc: ansic: 124,643; xml: 34,410; sh: 11,299; python: 3,520; makefile: 1,727; cpp: 16
file content (71 lines) | stat: -rw-r--r-- 2,171 bytes parent folder | download | duplicates (6)
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
/* Test support for shortening connection service names.
 *
 * Copyright (C) 2007-2009 Collabora Ltd. <http://www.collabora.co.uk/>
 * Copyright (C) 2007-2009 Nokia Corporation
 *
 * Copying and distribution of this file, with or without modification,
 * are permitted in any medium without royalty provided the copyright
 * notice and this notice are preserved.
 */

#include "config.h"

#include <string.h>

#include <telepathy-glib/channel.h>
#include <telepathy-glib/connection.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/debug.h>
#include <telepathy-glib/gtypes.h>
#include <telepathy-glib/interfaces.h>

#include "tests/lib/echo-chan.h"
#include "tests/lib/echo-conn.h"
#include "tests/lib/myassert.h"
#include "tests/lib/util.h"

/* 256 characters */
#define LONG_ACCOUNT_IS_LONG \
  "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"

int
main (int argc,
      char **argv)
{
  TpDBusDaemon *dbus;
  TpTestsEchoConnection *service_conn;
  TpBaseConnection *service_conn_as_base;
  GError *error = NULL;
  gchar *name;
  gchar *conn_path;

  tp_tests_abort_after (10);
  dbus = tp_tests_dbus_daemon_dup_or_die ();

  MYASSERT (strlen (LONG_ACCOUNT_IS_LONG) == 256, "");
  service_conn = TP_TESTS_ECHO_CONNECTION (tp_tests_object_new_static_class (
        TP_TESTS_TYPE_ECHO_CONNECTION,
        "account", LONG_ACCOUNT_IS_LONG,
        "protocol", "example",
        NULL));
  service_conn_as_base = TP_BASE_CONNECTION (service_conn);
  MYASSERT (service_conn != NULL, "");
  MYASSERT (service_conn_as_base != NULL, "");

  MYASSERT (tp_base_connection_register (service_conn_as_base, "example",
        &name, &conn_path, &error), "");
  g_assert_no_error (error);
  /* Name is too long to be used unmodified; check that it's shortened to 255
   * characters.
   */
  MYASSERT (strlen (name) == 255, "");

  g_object_unref (service_conn);
  g_object_unref (dbus);
  g_free (name);
  g_free (conn_path);
  return 0;
}