tests: Build window test with ctest
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
6a1c27e9a4
commit
4e9c5e0a00
|
@ -9,3 +9,4 @@ gui_unit_test(Settings)
|
||||||
gui_unit_test(Model)
|
gui_unit_test(Model)
|
||||||
gui_unit_test(View)
|
gui_unit_test(View)
|
||||||
gui_unit_test(Queue)
|
gui_unit_test(Queue)
|
||||||
|
gui_unit_test(Window)
|
||||||
|
|
|
@ -29,7 +29,7 @@ gui_objs += [ env.Object("../../gui/settings.c") ]
|
||||||
gui_objs += [ env.Object("../../gui/model.c") ]
|
gui_objs += [ env.Object("../../gui/model.c") ]
|
||||||
gui_objs += [ env.Object("../../gui/view.c") ]
|
gui_objs += [ env.Object("../../gui/view.c") ]
|
||||||
gui_objs += [ env.Object("../../gui/queue.c") ]
|
gui_objs += [ env.Object("../../gui/queue.c") ]
|
||||||
res += [ GuiTest("window") ]
|
gui_objs += [ env.Object("../../gui/window.c") ]
|
||||||
res += [ GuiTest("idle") ]
|
res += [ GuiTest("idle") ]
|
||||||
res += [ GuiTest("sidebar") ]
|
res += [ GuiTest("sidebar") ]
|
||||||
res += [ GuiTest("playlist") ]
|
res += [ GuiTest("playlist") ]
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2015 (c) Anna Schumaker.
|
* Copyright 2015 (c) Anna Schumaker.
|
||||||
*/
|
*/
|
||||||
#define TEST_NEED_AUDIO
|
|
||||||
#define TEST_NEED_SIDEBAR
|
|
||||||
#define TEST_NEED_COLLECTION
|
|
||||||
#define TEST_NEED_PLAYLIST
|
|
||||||
#include <gui/builder.h>
|
#include <gui/builder.h>
|
||||||
#include <gui/settings.h>
|
#include <gui/settings.h>
|
||||||
#include <gui/view.h>
|
#include <gui/view.h>
|
||||||
|
@ -23,7 +19,33 @@ static int test_on_idle(gpointer data)
|
||||||
static void test_window()
|
static void test_window()
|
||||||
{
|
{
|
||||||
GtkWindow *window;
|
GtkWindow *window;
|
||||||
int argc = 0;
|
|
||||||
|
main_loop = g_main_loop_new(NULL, FALSE);
|
||||||
|
window = GTK_WINDOW(gui_builder_widget("o_window"));
|
||||||
|
g_idle_add(test_on_idle, window);
|
||||||
|
|
||||||
|
g_assert_false(gui_settings_has("gui.window.width"));
|
||||||
|
g_assert_false(gui_settings_has("gui.window.height"));
|
||||||
|
g_assert_cmpstr(gtk_window_get_title(window), ==, "Ocarina " CONFIG_VERSION);
|
||||||
|
|
||||||
|
g_main_loop_run(main_loop);
|
||||||
|
g_assert_true(gui_settings_has("gui.window.width"));
|
||||||
|
g_assert_true(gui_settings_has("gui.window.height"));
|
||||||
|
|
||||||
|
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);
|
||||||
|
g_assert_cmpuint(gui_settings_get("gui.window.width"), ==, 800);
|
||||||
|
g_assert_cmpuint(gui_settings_get("gui.window.height"), ==, 600);
|
||||||
|
|
||||||
|
g_main_loop_unref(main_loop);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
gtk_init(&argc, NULL);
|
gtk_init(&argc, NULL);
|
||||||
gui_builder_init("share/ocarina/ocarina6.glade");
|
gui_builder_init("share/ocarina/ocarina6.glade");
|
||||||
|
@ -31,32 +53,12 @@ static void test_window()
|
||||||
gui_view_init();
|
gui_view_init();
|
||||||
gui_window_init("share/ocarina/ocarina.png");
|
gui_window_init("share/ocarina/ocarina.png");
|
||||||
|
|
||||||
main_loop = g_main_loop_new(NULL, FALSE);
|
g_test_init(&argc, &argv, NULL);
|
||||||
window = GTK_WINDOW(gui_builder_widget("o_window"));
|
g_test_add_func("/Gui/Window", test_window);
|
||||||
g_idle_add(test_on_idle, window);
|
ret = g_test_run();
|
||||||
|
|
||||||
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_window_deinit();
|
||||||
gui_settings_deinit();
|
gui_settings_deinit();
|
||||||
gui_builder_deinit();
|
gui_builder_deinit();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLARE_UNIT_TESTS(
|
|
||||||
UNIT_TEST("GUI Window", test_window),
|
|
||||||
);
|
|
||||||
|
|
Loading…
Reference in New Issue