| 88 &items_changed_counter); |
88 &items_changed_counter); |
| 89 g_signal_connect(attachments, "notify::n-items", |
89 g_signal_connect(attachments, "notify::n-items", |
| 90 G_CALLBACK(test_purple_attachments_notify), |
90 G_CALLBACK(test_purple_attachments_notify), |
| 91 &n_items_counter); |
91 &n_items_counter); |
| 92 |
92 |
| 93 attachment = purple_attachment_new(1337lu, "text/plain"); |
93 attachment = purple_attachment_new("1337", "text/plain"); |
| 94 |
94 |
| 95 /* The first add. */ |
95 /* The first add. */ |
| 96 items_changed_counter = 0; |
96 items_changed_counter = 0; |
| 97 n_items_counter = 0; |
97 n_items_counter = 0; |
| 98 success = purple_attachments_add_attachment(attachments, attachment); |
98 success = purple_attachments_add_attachment(attachments, attachment); |
| 126 &items_changed_counter); |
126 &items_changed_counter); |
| 127 g_signal_connect(attachments, "notify::n-items", |
127 g_signal_connect(attachments, "notify::n-items", |
| 128 G_CALLBACK(test_purple_attachments_notify), |
128 G_CALLBACK(test_purple_attachments_notify), |
| 129 &n_items_counter); |
129 &n_items_counter); |
| 130 |
130 |
| 131 attachment = purple_attachment_new(1337lu, "text/plain"); |
131 attachment = purple_attachment_new("1337", "text/plain"); |
| 132 |
132 |
| 133 /* The first add. */ |
133 /* The first add. */ |
| 134 items_changed_counter = 0; |
134 items_changed_counter = 0; |
| 135 n_items_counter = 0; |
135 n_items_counter = 0; |
| 136 success = purple_attachments_add_attachment(attachments, attachment); |
136 success = purple_attachments_add_attachment(attachments, attachment); |
| 165 PurpleAttachments *attachments = NULL; |
165 PurpleAttachments *attachments = NULL; |
| 166 |
166 |
| 167 attachments = purple_attachments_new(); |
167 attachments = purple_attachments_new(); |
| 168 |
168 |
| 169 /* Search on the empty collection. */ |
169 /* Search on the empty collection. */ |
| 170 found = purple_attachments_find_with_id(attachments, 1337lu); |
170 found = purple_attachments_find_with_id(attachments, "1337"); |
| 171 g_assert_null(found); |
171 g_assert_null(found); |
| 172 |
172 |
| 173 /* Create an attachment and add it. */ |
173 /* Create an attachment and add it. */ |
| 174 attachment = purple_attachment_new(1337lu, "text/plain"); |
174 attachment = purple_attachment_new("1337", "text/plain"); |
| 175 purple_attachments_add_attachment(attachments, attachment); |
175 purple_attachments_add_attachment(attachments, attachment); |
| 176 |
176 |
| 177 found = purple_attachments_find_with_id(attachments, 1337lu); |
177 found = purple_attachments_find_with_id(attachments, "1337"); |
| 178 g_assert_true(PURPLE_IS_ATTACHMENT(found)); |
178 g_assert_true(PURPLE_IS_ATTACHMENT(found)); |
| 179 g_assert_true(found == attachment); |
179 g_assert_true(found == attachment); |
| 180 |
180 |
| 181 /* Search for an attachment that doesn't exist. */ |
181 /* Search for an attachment that doesn't exist. */ |
| 182 found = purple_attachments_find_with_id(attachments, 42lu); |
182 found = purple_attachments_find_with_id(attachments, "42"); |
| 183 g_assert_null(found); |
183 g_assert_null(found); |
| 184 |
184 |
| 185 g_assert_finalize_object(attachments); |
185 g_assert_finalize_object(attachments); |
| 186 g_assert_finalize_object(attachment); |
186 g_assert_finalize_object(attachment); |
| 187 } |
187 } |