tests: Build treeview test with ctest
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
c671c7aefc
commit
b2dbbbaae6
|
@ -7,3 +7,4 @@ endfunction()
|
|||
gui_unit_test(Builder)
|
||||
gui_unit_test(Settings)
|
||||
gui_unit_test(Model)
|
||||
gui_unit_test(View)
|
||||
|
|
|
@ -27,7 +27,7 @@ env.UsePackage("gmodule-export-2.0")
|
|||
gui_objs += [ env.Object("../../gui/builder.c") ]
|
||||
gui_objs += [ env.Object("../../gui/settings.c") ]
|
||||
gui_objs += [ env.Object("../../gui/model.c") ]
|
||||
res += [ GuiTest("view") ]
|
||||
gui_objs += [ env.Object("../../gui/view.c") ]
|
||||
res += [ GuiTest("queue") ]
|
||||
res += [ GuiTest("window") ]
|
||||
res += [ GuiTest("idle") ]
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/*
|
||||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#define TEST_NEED_AUDIO
|
||||
#define TEST_NEED_COLLECTION
|
||||
#define TEST_NEED_PLAYLIST
|
||||
#define TEST_NEED_QUEUE
|
||||
#define TEST_NEED_SIDEBAR
|
||||
#define TEST_NEED_WINDOW
|
||||
#include <core/audio.h>
|
||||
#include <core/core.h>
|
||||
#include <core/idle.h>
|
||||
|
@ -39,14 +33,14 @@ static void test_load(struct track *track) { load_count++; }
|
|||
static void test_state_change(GstState state) {}
|
||||
static void test_config_pause(int count) {}
|
||||
|
||||
struct audio_ops audio_ops = {
|
||||
struct audio_ops test_audio_ops = {
|
||||
.on_load = test_load,
|
||||
.on_state_change = test_state_change,
|
||||
.on_config_pause = test_config_pause,
|
||||
};
|
||||
|
||||
struct core_init_data init_data = {
|
||||
.audio_ops = &audio_ops,
|
||||
.audio_ops = &test_audio_ops,
|
||||
};
|
||||
|
||||
static int test_on_idle(gpointer data)
|
||||
|
@ -82,10 +76,8 @@ static void test_treeview()
|
|||
main_loop = g_main_loop_new(NULL, FALSE);
|
||||
g_idle_add(test_on_idle, NULL);
|
||||
|
||||
for (i = 0; i < Q_MODEL_N_COLUMNS; i++) {
|
||||
test_loop_equal(gui_settings_has(QUEUE_SETTINGS[i]),
|
||||
(bool)false, i);
|
||||
} test_loop_passed();
|
||||
for (i = 0; i < Q_MODEL_N_COLUMNS; i++)
|
||||
g_assert_false(gui_settings_has(QUEUE_SETTINGS[i]));
|
||||
|
||||
for (i = 0; i < Q_MODEL_N_COLUMNS; i++) {
|
||||
if (i == Q_MODEL_FILE_PATH || i == Q_MODEL_FONT)
|
||||
|
@ -97,14 +89,14 @@ static void test_treeview()
|
|||
g_main_loop_run(main_loop);
|
||||
for (i = 0; i < Q_MODEL_N_COLUMNS; i++) {
|
||||
bool has = (i != Q_MODEL_FILE_PATH) && (i != Q_MODEL_FONT);
|
||||
test_loop_equal(gui_settings_has(QUEUE_SETTINGS[i]), has, i);
|
||||
g_assert(gui_settings_has(QUEUE_SETTINGS[i]) == has);
|
||||
/* The "Played" column gets any remaining space. */
|
||||
if (has && i != Q_MODEL_LAST_PLAY)
|
||||
test_loop_equal(gui_settings_get(QUEUE_SETTINGS[i]),
|
||||
(i + 2) * 10, i);
|
||||
} test_loop_passed();
|
||||
test_equal(gui_settings_has("gui.queue.filepath"), (bool)false);
|
||||
test_equal(gui_settings_get("gui.queue.filepath"), 0);
|
||||
g_assert_cmpuint(gui_settings_get(QUEUE_SETTINGS[i]),
|
||||
==, (i + 2) * 10);
|
||||
}
|
||||
g_assert_false(gui_settings_has("gui.queue.filepath"));
|
||||
g_assert_cmpuint(gui_settings_get("gui.queue.filepath"), ==, 0);
|
||||
|
||||
for (i = 0; i < Q_MODEL_LAST_PLAY; i++)
|
||||
gui_settings_set(QUEUE_SETTINGS[i], 42);
|
||||
|
@ -112,21 +104,24 @@ static void test_treeview()
|
|||
gui_view_init();
|
||||
for (i = 0; i < Q_MODEL_LAST_PLAY; i++) {
|
||||
col = gtk_tree_view_get_column(treeview, i);
|
||||
test_loop_equal(gtk_tree_view_column_get_fixed_width(col), 42, i);
|
||||
} test_loop_passed();
|
||||
g_assert_cmpuint(gtk_tree_view_column_get_fixed_width(col), ==, 42);
|
||||
}
|
||||
|
||||
test_equal((void *)gtk_tree_view_get_model(treeview),
|
||||
(void *)gui_view_get_filter());
|
||||
g_assert((void *)gtk_tree_view_get_model(treeview) ==
|
||||
(void *)gui_view_get_filter());
|
||||
|
||||
gtk_tree_model_iter_nth_child(filter, &iter, NULL, 3);
|
||||
path = gtk_tree_model_get_path(filter, &iter);
|
||||
gtk_tree_view_row_activated(treeview, path, NULL);
|
||||
test_equal(load_count, 1);
|
||||
g_assert_cmpuint(load_count, ==, 1);
|
||||
gtk_tree_path_free(path);
|
||||
|
||||
gui_view_set_queue(NULL);
|
||||
}
|
||||
|
||||
DECLARE_UNIT_TESTS(
|
||||
UNIT_TEST("Treeview", test_treeview),
|
||||
);
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
g_test_init(&argc, &argv, NULL);
|
||||
g_test_add_func("/Gui/Treeview", test_treeview);
|
||||
return g_test_run();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue