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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <tp-account-widgets/tpaw-irc-server.h>
#include "test-helper.h"
#include "test-irc-helper.h"
static void
test_tpaw_irc_server_new (void)
{
TpawIrcServer *server;
server = tpaw_irc_server_new ("test.localhost", 6667, TRUE);
check_server (server, "test.localhost", 6667, TRUE);
g_object_unref (server);
}
static void
test_property_change (void)
{
TpawIrcServer *server;
server = tpaw_irc_server_new ("test.localhost", 6667, TRUE);
g_assert (server != NULL);
g_object_set (server,
"address", "test2.localhost",
"port", 6668,
"ssl", FALSE,
NULL);
check_server (server, "test2.localhost", 6668, FALSE);
g_object_unref (server);
}
static gboolean modified = FALSE;
static void
modified_cb (TpawIrcServer *server,
gpointer unused)
{
modified = TRUE;
}
static void
test_modified_signal (void)
{
TpawIrcServer *server;
server = tpaw_irc_server_new ("test.localhost", 6667, TRUE);
g_assert (server != NULL);
g_signal_connect (server, "modified", G_CALLBACK (modified_cb), NULL);
/* address */
g_object_set (server, "address", "test2.localhost", NULL);
g_assert (modified);
modified = FALSE;
g_object_set (server, "address", "test2.localhost", NULL);
g_assert (!modified);
/* port */
g_object_set (server, "port", 6668, NULL);
g_assert (modified);
modified = FALSE;
g_object_set (server, "port", 6668, NULL);
g_assert (!modified);
/* ssl */
g_object_set (server, "ssl", FALSE, NULL);
g_assert (modified);
modified = FALSE;
g_object_set (server, "ssl", FALSE, NULL);
g_assert (!modified);
g_object_unref (server);
}
int
main (int argc,
char **argv)
{
int result;
test_init (argc, argv);
g_test_add_func ("/irc-server/new", test_tpaw_irc_server_new);
g_test_add_func ("/irc-server/property-change", test_property_change);
g_test_add_func ("/irc-server/modified-signal", test_modified_signal);
result = g_test_run ();
test_deinit ();
return result;
}
|