/* * Copyright 2016 (c) Anna Schumaker. */ #define TEST_NEED_AUDIO #define TEST_NEED_COLLECTION #include #include #include #include #include #include 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(); while (idle_run_task()) {} test_equal(GTK_IS_TREE_VIEW(GTK_TREE_VIEW(gui_builder_widget("o_playlist_view"))), true); 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); 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"); gtk_tree_path_next(path); gtk_tree_selection_select_path(selection, path); test_equal(gtk_tree_selection_count_selected_rows(selection), 1); gtk_tree_selection_unselect_all(selection); test_equal(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); gtk_tree_path_next(path); 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(gtk_tree_selection_count_selected_rows(selection), 1); test_equal(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"); 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"); 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"); 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"); gtk_tree_path_free(path); gui_builder_deinit(); } DECLARE_UNIT_TESTS( UNIT_TEST("Playlist Sidebar", test_playlist_sidebar), );