ocarina/tests/gui/playlist.c

66 lines
1.8 KiB
C

/*
* Copyright 2016 (c) Anna Schumaker.
*/
#define TEST_NEED_AUDIO
#include <core/core.h>
#include <gui/builder.h>
#include <gui/playlist.h>
#include <tests/gui.h>
#include <tests/test.h>
struct core_init_data init_data;
static void test_playlist_sidebar()
{
GtkTreeSelection *selection;
GtkTreeView *treeview;
GtkTreeModel *model;
GtkTreePath *path;
GtkTreeIter iter;
int argc = 0;
gtk_init(&argc, NULL);
gui_builder_init("share/ocarina/ocarina6.glade");
core_init(&argc, NULL, &init_data);
gui_playlist_init();
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);
test_equal(gtk_tree_model_iter_next(model, &iter), true);
test_equal(gtk_tree_model_iter_n_children(model, &iter), 5);
path = gtk_tree_model_get_path(model, &iter);
gtk_tree_selection_select_path(selection, path);
test_equal(gtk_tree_selection_count_selected_rows(selection), 0);
gtk_tree_path_down(path);
gtk_tree_selection_select_path(selection, path);
test_equal(gui_playlist_cur(), PL_FAVORITED);
gtk_tree_path_next(path);
gtk_tree_selection_select_path(selection, path);
test_equal(gui_playlist_cur(), PL_HIDDEN);
gtk_tree_path_next(path);
gtk_tree_selection_select_path(selection, path);
test_equal(gui_playlist_cur(), PL_MOST_PLAYED);
gtk_tree_path_next(path);
gtk_tree_selection_select_path(selection, path);
test_equal(gui_playlist_cur(), PL_LEAST_PLAYED);
gtk_tree_path_next(path);
gtk_tree_selection_select_path(selection, path);
test_equal(gui_playlist_cur(), PL_UNPLAYED);
gtk_tree_path_free(path);
gui_builder_deinit();
}
DECLARE_UNIT_TESTS(
UNIT_TEST("Playlist Sidebar", test_playlist_sidebar),
);