summaryrefslogtreecommitdiff
path: root/tests/wocky-session-test.c
blob: 99b624d122b7bcc6da0398bc823f50c04f9475c1 (plain)
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
#include <stdio.h>
#include <unistd.h>
#include <string.h>

#include <glib.h>

#include <wocky/wocky-session.h>
#include <wocky/wocky-utils.h>

#include "wocky-test-helper.h"

static void
test_instantiation (void)
{
  WockyTestStream *stream;
  WockyXmppConnection *connection;
  WockySession *session;

  stream = g_object_new (WOCKY_TYPE_TEST_STREAM, NULL);
  connection = wocky_xmpp_connection_new (stream->stream0);

  session = wocky_session_new (connection);
  g_assert (session != NULL);
  g_assert (WOCKY_IS_SESSION (session));

  g_object_unref (stream);
  g_object_unref (connection);
  g_object_unref (session);
}

static void
test_get_porter (void)
{
  test_data_t *test = setup_test ();
  WockySession *session;
  WockyPorter *porter;

  session = wocky_session_new (test->in);

  porter = wocky_session_get_porter (session);
  g_assert (WOCKY_IS_PORTER (porter));

  g_object_unref (session);
  teardown_test (test);
}

static void
test_get_contact_factory (void)
{
  test_data_t *test = setup_test ();
  WockySession *session;
  WockyContactFactory *factory;

  session = wocky_session_new (test->in);

  factory = wocky_session_get_contact_factory (session);
  g_assert (WOCKY_IS_CONTACT_FACTORY (factory));

  g_object_unref (session);
  teardown_test (test);
}

int
main (int argc, char **argv)
{
  int result;

  test_init (argc, argv);

  g_test_add_func ("/session/instantiation", test_instantiation);
  g_test_add_func ("/session/get-porter", test_get_porter);
  g_test_add_func ("/session/get-contact-factory", test_get_contact_factory);

  result = g_test_run ();
  test_deinit ();
  return result;
}