summaryrefslogtreecommitdiff
path: root/tests/wocky-session-test.c
blob: 8cca2a59edfe82bd191072f8e119bd8a8b8ceed5 (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_with_connection (connection, "example.com");
  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_with_connection (test->in, "example.com");

  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_with_connection (test->in, "example.com");

  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;
}