tests: Build gui playlist test with ctest

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2016-03-25 13:55:52 -04:00 committed by Anna Schumaker
parent dd268a24fe
commit 59839547e2
3 changed files with 41 additions and 33 deletions

View File

@ -12,3 +12,4 @@ gui_unit_test(Queue)
gui_unit_test(Window)
gui_unit_test(Idle)
gui_unit_test(Sidebar)
gui_unit_test(Playlist)

View File

@ -32,7 +32,7 @@ gui_objs += [ env.Object("../../gui/queue.c") ]
gui_objs += [ env.Object("../../gui/window.c") ]
gui_objs += [ env.Object("../../gui/idle.c") ]
gui_objs += [ env.Object("../../gui/sidebar.c") ]
res += [ GuiTest("playlist") ]
gui_objs += [ env.Object("../../gui/playlist.c") ]
gui_objs += [ env.Object("../../gui/collection.c") ]
gui_objs += [ env.Object("../../gui/artwork.c") ]
res += [ GuiTest("audio") ]

View File

@ -1,13 +1,12 @@
/*
* Copyright 2016 (c) Anna Schumaker.
*/
#define TEST_NEED_AUDIO
#define TEST_NEED_COLLECTION
#include <core/core.h>
#include <core/idle.h>
#include <gui/builder.h>
#include <gui/model.h>
#include <gui/playlist.h>
#include <gui/view.h>
#include <tests/gui.h>
#include <tests/test.h>
@ -20,70 +19,78 @@ static void test_playlist_sidebar()
GtkTreeModel *model;
GtkTreePath *path;
GtkTreeIter iter;
int argc = 0;
gtk_init(&argc, NULL);
gui_builder_init("share/ocarina/ocarina6.glade");
gui_queue_model_init();
core_init(&argc, NULL, &init_data);
gui_playlist_init();
while (idle_run_task()) {}
test_equal(GTK_IS_TREE_VIEW(GTK_TREE_VIEW(gui_builder_widget("o_playlist_view"))), true);
g_assert_true(GTK_IS_TREE_VIEW(GTK_TREE_VIEW(gui_builder_widget("o_playlist_view"))));
treeview = GTK_TREE_VIEW(gui_builder_widget("o_playlist_view"));
selection = gtk_tree_view_get_selection(treeview);
model = GTK_TREE_MODEL(gui_builder_object("o_playlist_store"));
test_equal(gtk_tree_model_get_iter_first(model, &iter), true);
g_assert_true(gtk_tree_model_get_iter_first(model, &iter));
path = gtk_tree_model_get_path(model, &iter);
gtk_tree_selection_select_path(selection, path);
test_equal(gtk_tree_selection_count_selected_rows(selection), 1);
test_equal(gui_playlist_cur(), "Collection");
g_assert_cmpuint(gtk_tree_selection_count_selected_rows(selection), ==, 1);
g_assert_cmpstr(gui_playlist_cur(), ==, "Collection");
gtk_tree_path_next(path);
gtk_tree_selection_select_path(selection, path);
test_equal(gtk_tree_selection_count_selected_rows(selection), 1);
g_assert_cmpuint(gtk_tree_selection_count_selected_rows(selection), ==, 1);
gtk_tree_selection_unselect_all(selection);
test_equal(gui_playlist_cur(), "History");
g_assert_cmpstr(gui_playlist_cur(), ==, "History");
gtk_tree_path_next(path);
gtk_tree_selection_select_path(selection, path);
test_equal(gtk_tree_selection_count_selected_rows(selection), 0);
g_assert_cmpuint(gtk_tree_selection_count_selected_rows(selection), ==, 0);
gtk_tree_path_next(path);
gtk_tree_selection_select_path(selection, path);
test_equal(gtk_tree_selection_count_selected_rows(selection), 0);
g_assert_cmpuint(gtk_tree_selection_count_selected_rows(selection), ==, 0);
gtk_tree_path_down(path);
gtk_tree_selection_select_path(selection, path);
test_equal(gtk_tree_selection_count_selected_rows(selection), 1);
test_equal(gui_playlist_cur(), "Favorites");
g_assert_cmpuint(gtk_tree_selection_count_selected_rows(selection), ==, 1);
g_assert_cmpstr(gui_playlist_cur(), ==, "Favorites");
gtk_tree_path_next(path);
gtk_tree_selection_select_path(selection, path);
test_equal(gtk_tree_selection_count_selected_rows(selection), 1);
test_equal(gui_playlist_cur(), "Hidden");
g_assert_cmpuint(gtk_tree_selection_count_selected_rows(selection), ==, 1);
g_assert_cmpstr(gui_playlist_cur(), ==, "Hidden");
gtk_tree_path_next(path);
gtk_tree_selection_select_path(selection, path);
test_equal(gtk_tree_selection_count_selected_rows(selection), 1);
test_equal(gui_playlist_cur(), "Most Played");
g_assert_cmpuint(gtk_tree_selection_count_selected_rows(selection), ==, 1);
g_assert_cmpstr(gui_playlist_cur(), ==, "Most Played");
gtk_tree_path_next(path);
gtk_tree_selection_select_path(selection, path);
test_equal(gtk_tree_selection_count_selected_rows(selection), 1);
test_equal(gui_playlist_cur(), "Least Played");
g_assert_cmpuint(gtk_tree_selection_count_selected_rows(selection), ==, 1);
g_assert_cmpstr(gui_playlist_cur(), ==, "Least Played");
gtk_tree_path_next(path);
gtk_tree_selection_select_path(selection, path);
test_equal(gtk_tree_selection_count_selected_rows(selection), 1);
test_equal(gui_playlist_cur(), "Unplayed");
g_assert_cmpuint(gtk_tree_selection_count_selected_rows(selection), ==, 1);
g_assert_cmpstr(gui_playlist_cur(), ==, "Unplayed");
gtk_tree_path_free(path);
gui_builder_deinit();
}
DECLARE_UNIT_TESTS(
UNIT_TEST("Playlist Sidebar", test_playlist_sidebar),
);
int main(int argc, char **argv)
{
int ret;
gtk_init(&argc, NULL);
gui_builder_init("share/ocarina/ocarina6.glade");
gui_queue_model_init();
gui_view_init();
core_init(&argc, NULL, &init_data);
gui_playlist_init();
while (idle_run_task()) {}
g_test_init(&argc, &argv, NULL);
g_test_add_func("/Gui/Playlist/Sidebar", test_playlist_sidebar);
ret = g_test_run();
gui_builder_deinit();
core_deinit();
return ret;
}