libpurple/tests/test_whiteboard_manager.c

Sun, 03 Nov 2024 00:08:34 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Sun, 03 Nov 2024 00:08:34 -0500
changeset 43047
4c23faf5dfb5
parent 42872
93d8e1772e4e
permissions
-rw-r--r--

Add calls to Gio.ListModel.items_changed in Purple.WhiteboardManager

Also added tests for the Gio.ListModel properties and some other random clean
ups.

Testing Done:
Ran the tests under valgrind and called in the turtles for the rest.

Reviewed at https://reviews.imfreedom.org/r/3639/

/*
 * Purple - Internet Messaging Library
 * Copyright (C) Pidgin Developers <devel@pidgin.im>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
 */

#include <glib.h>

#include <purple.h>

/******************************************************************************
 * Tests
 *****************************************************************************/
static void
test_purple_whiteboard_manager_new(void) {
	PurpleWhiteboardManager *manager = NULL;

	manager = g_object_new(PURPLE_TYPE_WHITEBOARD_MANAGER, NULL);

	g_assert_true(PURPLE_IS_WHITEBOARD_MANAGER(manager));
	g_assert_true(G_IS_LIST_MODEL(manager));

	g_assert_finalize_object(manager);
}

static void
test_purple_whiteboard_manager_properties(void) {
	PurpleWhiteboardManager *manager = NULL;
	GType item_type = G_TYPE_INVALID;
	guint n_items = 0;

	manager = g_object_new(PURPLE_TYPE_WHITEBOARD_MANAGER, NULL);

	g_object_get(
		G_OBJECT(manager),
		"item-type", &item_type,
		"n_items", &n_items,
		NULL);

	g_assert_true(item_type == PURPLE_TYPE_WHITEBOARD);

	g_assert_cmpuint(n_items, ==, 0);

	g_assert_finalize_object(manager);
}

/******************************************************************************
 * Main
 *****************************************************************************/
int
main(int argc, char *argv[]) {
	g_test_init(&argc, &argv, NULL);
	g_test_set_nonfatal_assertions();

	g_test_add_func("/whiteboard-manager/new",
	                test_purple_whiteboard_manager_new);
	g_test_add_func("/whiteboard-manager/properties",
	                test_purple_whiteboard_manager_properties);

	return g_test_run();
}

mercurial