tests: Rename gui.h -> loop.h

I want to run a main loop during the audio tests, which aren't in gui/.
Let's rename this file to make me feel better about using it :)

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2017-04-05 15:38:56 -04:00
parent 36349e9890
commit d95c693db2
5 changed files with 44 additions and 44 deletions

View File

@ -1,30 +0,0 @@
/*
* Copyright 2016 (c) Anna Schumaker.
*/
#ifndef OCARINA_TESTS_GUI_H
#define OCARINA_TESTS_GUI_H
static GMainLoop *__gui_test_main_loop;
static int __gui_test_on_idle(gpointer data)
{
g_main_loop_quit(__gui_test_main_loop);
return G_SOURCE_CONTINUE;
}
static void gui_test_init()
{
__gui_test_main_loop = g_main_loop_new(NULL, FALSE);
g_idle_add(__gui_test_on_idle, NULL);
}
static void gui_test_deinit()
{
g_main_loop_unref(__gui_test_main_loop);
}
static void gui_test_main_loop()
{
g_main_loop_run(__gui_test_main_loop);
}
#endif /* OCARINA_TESTS_GUI_H */

30
include/tests/loop.h Normal file
View File

@ -0,0 +1,30 @@
/*
* Copyright 2016 (c) Anna Schumaker.
*/
#ifndef OCARINA_TESTS_LOOP_H
#define OCARINA_TESTS_LOOP_H
static GMainLoop *__test_main_loop;
static int __test_loop_on_idle(gpointer data)
{
g_main_loop_quit(__test_main_loop);
return G_SOURCE_CONTINUE;
}
static void test_loop_init()
{
__test_main_loop = g_main_loop_new(NULL, FALSE);
g_idle_add(__test_loop_on_idle, NULL);
}
static void test_loop_deinit()
{
g_main_loop_unref(__test_main_loop);
}
static void test_main_loop()
{
g_main_loop_run(__test_main_loop);
}
#endif /* OCARINA_TESTS_LOOP_H */

View File

@ -4,7 +4,7 @@
#include <core/core.h>
#include <gui/idle.h>
#include <tests/test.h>
#include <tests/gui.h>
#include <tests/loop.h>
static const unsigned int N = 100;
static unsigned int cur = -1;
@ -28,14 +28,14 @@ static void test_idle()
g_assert_false(gtk_widget_is_visible(GTK_WIDGET(progress)));
for (i = 0; i < (N - 1); i++) {
gui_test_main_loop();
test_main_loop();
g_assert_true(gtk_widget_is_visible(GTK_WIDGET(progress)));
g_assert_cmpfloat(idle_progress(), ==, (float)(i + 1) / N);
g_assert_cmpfloat(gtk_progress_bar_get_fraction(progress),
==, (float)(i + 1) / N);
}
gui_test_main_loop();
test_main_loop();
g_assert_false(gtk_widget_is_visible(GTK_WIDGET(progress)));
}
@ -46,14 +46,14 @@ int main(int argc, char **argv)
gtk_init(&argc, NULL);
core_init(&argc, NULL, NULL, NULL, IDLE_SYNC);
gui_builder_init("share/ocarina/ocarina.ui");
gui_test_init();
test_loop_init();
while (idle_run_task()) {}
g_test_init(&argc, &argv, NULL);
g_test_add_func("/Gui/Idle", test_idle);
ret = g_test_run();
gui_test_deinit();
test_loop_deinit();
gui_builder_deinit();
core_deinit();
return ret;

View File

@ -6,7 +6,7 @@
#include <gui/model.h>
#include <gui/treeview.h>
#include <tests/test.h>
#include <tests/gui.h>
#include <tests/loop.h>
const gchar *GUI_COL_SETTINGS[GUI_MODEL_N_COLUMNS] = {
[GUI_MODEL_TRACK_NR] = "gui.queue.track",
@ -199,7 +199,7 @@ void test_treeview_columns()
gtk_tree_view_column_set_fixed_width(col, (i + 2) * 10);
}
gui_test_main_loop();
test_main_loop();
for (i = 0; i < GUI_MODEL_N_COLUMNS; i++) {
col = gtk_tree_view_get_column(gui_treeview(), i);
if (!col || (i == GUI_MODEL_LAST_PLAY))
@ -221,7 +221,7 @@ int main(int argc, char **argv)
gui_model_init();
gui_filter_init();
gui_treeview_init();
gui_test_init();
test_loop_init();
playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony");
while (idle_run_task()) {}
@ -234,7 +234,7 @@ int main(int argc, char **argv)
ret = g_test_run();
core_deinit();
gui_test_deinit();
test_loop_deinit();
gui_treeview_deinit();
gui_filter_deinit();
gui_model_deinit();

View File

@ -3,7 +3,7 @@
*/
#include <core/settings.h>
#include <gui/window.h>
#include <tests/gui.h>
#include <tests/loop.h>
#include <tests/test.h>
static void test_window()
@ -16,7 +16,7 @@ static void test_window()
g_assert_false(settings_has("gui.window.y"));
g_assert_cmpstr(gtk_window_get_title(window), ==, "Ocarina " CONFIG_VERSION);
gui_test_main_loop();
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"));
@ -28,7 +28,7 @@ static void test_window()
settings_set("gui.window.y", 42);
gui_window_init("share/ocarina/ocarina.png");
gui_test_main_loop();
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);
@ -43,13 +43,13 @@ int main(int argc, char **argv)
gtk_init(&argc, NULL);
gui_builder_init("share/ocarina/ocarina.ui");
gui_window_init("share/ocarina/ocarina.png");
gui_test_init();
test_loop_init();
g_test_init(&argc, &argv, NULL);
g_test_add_func("/Gui/Window", test_window);
ret = g_test_run();
gui_test_deinit();
test_loop_deinit();
gui_window_deinit();
gui_builder_deinit();
settings_deinit();