/*
 * 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_protocol_manager_new(void) {
	PurpleProtocolManager *manager = NULL;

	manager = g_object_new(PURPLE_TYPE_PROTOCOL_MANAGER, NULL);

	g_assert_true(PURPLE_IS_PROTOCOL_MANAGER(manager));
	g_assert_true(G_IS_LIST_MODEL(manager));

	g_assert_finalize_object(manager);
}

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

	manager = g_object_new(PURPLE_TYPE_PROTOCOL_MANAGER, NULL);

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

	g_assert_true(item_type == PURPLE_TYPE_PROTOCOL);

	/* While there aren't any items here, this just helps us verify that the
	 * property exists.
	 */
	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("/protocol-manager/new", test_purple_protocol_manager_new);
	g_test_add_func("/protocol-manager/properties",
	                test_purple_protocol_manager_properties);

	return g_test_run();
}
