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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "test-helper.h"
#include "empathy-chatroom.h"
#if 0
static EmpathyChatroom *
create_chatroom (void)
{
EmpathyAccount *account;
EmpathyChatroom *chatroom;
account = get_test_account ();
chatroom = empathy_chatroom_new (account);
fail_if (chatroom == NULL);
return chatroom;
}
START_TEST (test_empathy_chatroom_new)
{
EmpathyChatroom *chatroom;
gboolean auto_connect, favorite;
chatroom = create_chatroom ();
fail_if (empathy_chatroom_get_auto_connect (chatroom));
g_object_get (chatroom,
"auto_connect", &auto_connect,
"favorite", &favorite,
NULL);
fail_if (auto_connect);
fail_if (favorite);
g_object_unref (empathy_chatroom_get_account (chatroom));
g_object_unref (chatroom);
}
END_TEST
START_TEST (test_favorite_and_auto_connect)
{
/* auto connect implies favorite */
EmpathyChatroom *chatroom;
gboolean auto_connect, favorite;
chatroom = create_chatroom ();
/* set auto_connect so favorite as a side effect */
empathy_chatroom_set_auto_connect (chatroom, TRUE);
fail_if (!empathy_chatroom_get_auto_connect (chatroom));
g_object_get (chatroom,
"auto_connect", &auto_connect,
"favorite", &favorite,
NULL);
fail_if (!auto_connect);
fail_if (!favorite);
/* Remove auto_connect. Chatroom is still favorite */
empathy_chatroom_set_auto_connect (chatroom, FALSE);
fail_if (empathy_chatroom_get_auto_connect (chatroom));
g_object_get (chatroom,
"auto_connect", &auto_connect,
"favorite", &favorite,
NULL);
fail_if (auto_connect);
fail_if (!favorite);
/* Remove favorite too now */
g_object_set (chatroom, "favorite", FALSE, NULL);
fail_if (empathy_chatroom_get_auto_connect (chatroom));
g_object_get (chatroom,
"auto_connect", &auto_connect,
"favorite", &favorite,
NULL);
fail_if (auto_connect);
fail_if (favorite);
/* Just add favorite but not auto-connect */
g_object_set (chatroom, "favorite", TRUE, NULL);
fail_if (empathy_chatroom_get_auto_connect (chatroom));
g_object_get (chatroom,
"auto_connect", &auto_connect,
"favorite", &favorite,
NULL);
fail_if (auto_connect);
fail_if (!favorite);
/* ... and re-add auto_connect */
g_object_set (chatroom, "auto_connect", TRUE, NULL);
fail_if (!empathy_chatroom_get_auto_connect (chatroom));
g_object_get (chatroom,
"auto_connect", &auto_connect,
"favorite", &favorite,
NULL);
fail_if (!auto_connect);
fail_if (!favorite);
/* Remove favorite remove auto_connect too */
g_object_set (chatroom, "favorite", FALSE, NULL);
fail_if (empathy_chatroom_get_auto_connect (chatroom));
g_object_get (chatroom,
"auto_connect", &auto_connect,
"favorite", &favorite,
NULL);
fail_if (auto_connect);
fail_if (favorite);
g_object_unref (empathy_chatroom_get_account (chatroom));
g_object_unref (chatroom);
}
END_TEST
static void
favorite_changed (EmpathyChatroom *chatroom,
GParamSpec *spec,
gboolean *changed)
{
*changed = TRUE;
}
START_TEST (test_change_favorite)
{
EmpathyChatroom *chatroom;
gboolean changed = FALSE;
chatroom = create_chatroom ();
g_signal_connect (chatroom, "notify::favorite", G_CALLBACK (favorite_changed),
&changed);
/* change favorite to TRUE */
g_object_set (chatroom, "favorite", TRUE, NULL);
fail_if (!changed);
changed = FALSE;
/* change favorite to FALSE */
g_object_set (chatroom, "favorite", FALSE, NULL);
fail_if (!changed);
}
END_TEST
#endif
int
main (int argc,
char **argv)
{
int result;
test_init (argc, argv);
#if 0
g_test_add_func ("/chatroom/new", test_empathy_chatroom_new);
g_test_add_func ("/chatroom/favorite-and-auto-connect",
test_favorite_and_auto_connect);
g_test_add_func ("/chatroom/change-favorite", test_change_favorite);
#endif
result = g_test_run ();
test_deinit ();
return result;
}
|