ocarina/tests/gui/collection.c

49 lines
1.4 KiB
C

/*
* Copyright 2015 (c) Anna Schumaker.
*/
#define TEST_NEED_AUDIO
#include <gui/builder.h>
#include <gui/collection.h>
#include <tests/gui.h>
#include <tests/test.h>
static void test_collection_sidebar()
{
GtkTreeSelection *selection;
GtkTreeIter iter, child;
GtkNotebook *notebook;
GtkTreeView *treeview;
GtkTreeModel *model;
GtkTreePath *path;
int argc = 0;
gtk_init(&argc, NULL);
gui_builder_init("share/ocarina/ocarina6.glade");
gui_collection_init();
notebook = GTK_NOTEBOOK(gui_builder_widget("o_notebook"));
treeview = GTK_TREE_VIEW(gui_builder_widget("o_collection_view"));
selection = gtk_tree_view_get_selection(treeview);
model = GTK_TREE_MODEL(gui_builder_object("o_collection_store"));
test_equal(gtk_tree_model_get_iter_first(model, &iter), true);
path = gtk_tree_model_get_path(model, &iter);
gtk_tree_view_set_cursor(treeview, path, NULL, false);
gtk_tree_path_free(path);
test_equal(gtk_tree_selection_count_selected_rows(selection), 0);
gtk_tree_model_iter_nth_child(model, &child, &iter, 0);
path = gtk_tree_model_get_path(model, &child);
gtk_tree_view_set_cursor(treeview, path, NULL, false);
gtk_tree_path_free(path);
test_equal(gtk_tree_selection_count_selected_rows(selection), 1);
test_equal(gtk_notebook_get_current_page(notebook),
gtk_notebook_get_n_pages(notebook) - 1);
gui_builder_deinit();
}
DECLARE_UNIT_TESTS(
UNIT_TEST("Collection Sidebar", test_collection_sidebar),
);