58 lines
1.6 KiB
C
58 lines
1.6 KiB
C
/*
|
|
* Copyright 2015 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/settings.h>
|
|
#include <gui/window.h>
|
|
#include <tests/loop.h>
|
|
#include <tests/test.h>
|
|
|
|
static void test_window()
|
|
{
|
|
GtkWindow *window = gui_window();
|
|
|
|
g_assert_false(settings_has("gui.window.width"));
|
|
g_assert_false(settings_has("gui.window.height"));
|
|
g_assert_false(settings_has("gui.window.x"));
|
|
g_assert_false(settings_has("gui.window.y"));
|
|
g_assert_cmpstr(gtk_window_get_title(window), ==, "Ocarina " CONFIG_VERSION);
|
|
|
|
test_main_loop();
|
|
g_assert_true(settings_has("gui.window.width"));
|
|
g_assert_true(settings_has("gui.window.height"));
|
|
g_assert_true(settings_has("gui.window.x"));
|
|
g_assert_true(settings_has("gui.window.y"));
|
|
|
|
settings_set("gui.window.width", 800);
|
|
settings_set("gui.window.height", 600);
|
|
settings_set("gui.window.x", 42);
|
|
settings_set("gui.window.y", 42);
|
|
gui_window_init("share/ocarina/ocarina.png");
|
|
|
|
test_main_loop();
|
|
g_assert_cmpuint(settings_get("gui.window.width"), ==, 800);
|
|
g_assert_cmpuint(settings_get("gui.window.height"), ==, 600);
|
|
g_assert_cmpuint(settings_get("gui.window.x"), ==, 42);
|
|
g_assert_cmpuint(settings_get("gui.window.y"), ==, 42);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int ret;
|
|
|
|
settings_init();
|
|
gtk_init(&argc, NULL);
|
|
gui_builder_init("share/ocarina/ocarina.ui");
|
|
gui_window_init("share/ocarina/ocarina.png");
|
|
test_loop_init();
|
|
|
|
g_test_init(&argc, &argv, NULL);
|
|
g_test_add_func("/Gui/Window", test_window);
|
|
ret = g_test_run();
|
|
|
|
test_loop_deinit();
|
|
gui_window_deinit();
|
|
gui_builder_deinit();
|
|
settings_deinit();
|
|
return ret;
|
|
}
|