libpurple/tests/test_create_conversation_details.c

changeset 42645
3844b333df53
child 42866
4b201e18638f
equal deleted inserted replaced
42644:efe66edc9676 42645:3844b333df53
1 /*
2 * Purple - Internet Messaging Library
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
4 *
5 * Purple is the legal property of its developers, whose names are too numerous
6 * to list here. Please refer to the COPYRIGHT file distributed with this
7 * source distribution.
8 *
9 * This library is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 *
14 * This library is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * this library; if not, see <https://www.gnu.org/licenses/>.
21 */
22
23 #include <glib.h>
24
25 #include <purple.h>
26
27 /******************************************************************************
28 * Tests
29 *****************************************************************************/
30 static void
31 test_purple_create_conversation_details_new(void) {
32 PurpleCreateConversationDetails *details = NULL;
33
34 details = purple_create_conversation_details_new(9);
35 g_assert_true(PURPLE_IS_CREATE_CONVERSATION_DETAILS(details));
36
37 g_assert_finalize_object(details);
38 }
39
40 static void
41 test_purple_create_conversation_details_properties(void) {
42 PurpleCreateConversationDetails *details = NULL;
43 GListStore *store = NULL;
44 GListModel *model = NULL;
45 guint max_participants = 0;
46
47 store = g_list_store_new(PURPLE_TYPE_CONTACT);
48
49 details = g_object_new(
50 PURPLE_TYPE_CREATE_CONVERSATION_DETAILS,
51 "max-participants", 9,
52 "participants", store,
53 NULL);
54
55 g_assert_true(PURPLE_IS_CREATE_CONVERSATION_DETAILS(details));
56
57 g_object_get(
58 G_OBJECT(details),
59 "max-participants", &max_participants,
60 "participants", &model,
61 NULL);
62
63 g_assert_cmpuint(max_participants, ==, 9);
64
65 g_assert_true(G_IS_LIST_MODEL(model));
66 g_assert_true(model == G_LIST_MODEL(store));
67 g_clear_object(&model);
68
69 g_assert_finalize_object(details);
70 g_assert_finalize_object(store);
71 }
72
73 /******************************************************************************
74 * Main
75 *****************************************************************************/
76 int
77 main(int argc, char *argv[]) {
78 g_test_init(&argc, &argv, NULL);
79
80 g_test_add_func("/create-conversation-details/new",
81 test_purple_create_conversation_details_new);
82 g_test_add_func("/create-conversation-details/properties",
83 test_purple_create_conversation_details_properties);
84
85 return g_test_run();
86 }

mercurial