ocarina/tests/gui/window.c

59 lines
1.5 KiB
C

/*
* Copyright 2015 (c) Anna Schumaker.
*/
#define TEST_NEED_AUDIO
#define TEST_NEED_SIDEBAR
#include <gui/builder.h>
#include <gui/settings.h>
#include <gui/window.h>
#include <tests/gui.h>
#include <tests/test.h>
GMainLoop *main_loop;
static int test_on_idle(gpointer data)
{
g_main_loop_quit(main_loop);
return G_SOURCE_CONTINUE;
}
static void test_window()
{
GtkWindow *window;
int argc = 0;
gtk_init(&argc, NULL);
gui_builder_init("share/ocarina/ocarina6.glade");
gui_settings_init();
gui_window_init("share/ocarina/ocarina.png");
main_loop = g_main_loop_new(NULL, FALSE);
window = GTK_WINDOW(gui_builder_widget("o_window"));
g_idle_add(test_on_idle, window);
test_equal(gui_settings_has("gui.window.width"), (bool)false);
test_equal(gui_settings_has("gui.window.height"), (bool)false);
test_equal(gtk_window_get_title(window), "Ocarina " CONFIG_VERSION);
g_main_loop_run(main_loop);
test_equal(gui_settings_has("gui.window.width"), (bool)true);
test_equal(gui_settings_has("gui.window.height"), (bool)true);
gui_settings_set("gui.window.width", 800);
gui_settings_set("gui.window.height", 600);
gui_window_init("share/ocarina/ocarina.png");
g_main_loop_run(main_loop);
test_equal(gui_settings_get("gui.window.width"), 800);
test_equal(gui_settings_get("gui.window.height"), 600);
g_main_loop_unref(main_loop);
gui_window_deinit();
gui_settings_deinit();
gui_builder_deinit();
}
DECLARE_UNIT_TESTS(
UNIT_TEST("GUI Window", test_window),
);