From 08910bef7cdca1d1e37f9ae8eb15f97aa9275163 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Thu, 31 Dec 2015 09:20:09 -0500 Subject: [PATCH] gui/collection: Add new library paths through the GUI Signed-off-by: Anna Schumaker --- share/ocarina/ocarina6.glade | 43 ++++++++++++++---------------------- tests/gui/collection.c | 39 ++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 26 deletions(-) diff --git a/share/ocarina/ocarina6.glade b/share/ocarina/ocarina6.glade index ac7257d7..c62f8a12 100644 --- a/share/ocarina/ocarina6.glade +++ b/share/ocarina/ocarina6.glade @@ -30,7 +30,6 @@ 5 5 dialog-ok - 3 True @@ -906,7 +905,7 @@ center start - + Add Selected Path True True @@ -1115,6 +1114,7 @@ Manager True False + True False @@ -1122,35 +1122,12 @@ Manager center - False + True True 5 0 - - - True - False - - - True - True - 1 - - - - - True - False - end - - - False - True - 2 - - True @@ -1161,6 +1138,20 @@ Manager False True 5 + end + 1 + + + + + True + False + end + + + False + True + end 3 diff --git a/tests/gui/collection.c b/tests/gui/collection.c index 1774f5af..43cd4138 100644 --- a/tests/gui/collection.c +++ b/tests/gui/collection.c @@ -2,26 +2,48 @@ * Copyright 2015 (c) Anna Schumaker. */ #define TEST_NEED_AUDIO +#include #include #include #include #include +GMainLoop *main_loop; +struct core_init_data init_data; + +static int test_on_idle(gpointer data) +{ + g_main_loop_quit(main_loop); + return G_SOURCE_CONTINUE; +} + static void test_collection_sidebar() { GtkTreeSelection *selection; + GtkProgressBar *progress; + GtkFileChooser *chooser; GtkTreeIter iter, child; GtkNotebook *notebook; GtkTreeView *treeview; GtkTreeModel *model; GtkTreePath *path; + GtkWindow *window; + + struct library *library; int argc = 0; gtk_init(&argc, NULL); gui_builder_init("share/ocarina/ocarina6.glade"); + core_init(&argc, NULL, &init_data); gui_collection_init(); + main_loop = g_main_loop_new(NULL, FALSE); + window = GTK_WINDOW(gui_builder_widget("o_window")); + g_idle_add(test_on_idle, window); + notebook = GTK_NOTEBOOK(gui_builder_widget("o_notebook")); + progress = GTK_PROGRESS_BAR(gui_builder_widget("o_idle_progress")); + chooser = GTK_FILE_CHOOSER(gui_builder_widget("colmgr_chooser")); 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")); @@ -40,6 +62,23 @@ static void test_collection_sidebar() test_equal(gtk_notebook_get_current_page(notebook), gtk_notebook_get_n_pages(notebook) - 1); + gtk_file_chooser_set_filename(chooser, "tests/Music/Hyrule Symphony"); + g_main_loop_run(main_loop); + gtk_button_clicked(GTK_BUTTON(gui_builder_widget("o_collection_add"))); + + gtk_tree_model_get_iter_first(model, &iter); + test_equal(gtk_tree_model_iter_n_children(model, &iter), 2); + gtk_tree_model_iter_nth_child(model, &child, &iter, 0); + gtk_tree_model_get(model, &child, 5, &library, -1); + test_equal((void *)library, (void *)library_get(0)); + + /* Run two idle events to scan the added path. */ + test_equal(gtk_widget_is_visible(GTK_WIDGET(progress)), true); + g_main_loop_run(main_loop); + test_equal((float)gtk_progress_bar_get_fraction(progress), (float)0.5); + g_main_loop_run(main_loop); + test_equal(gtk_widget_is_visible(GTK_WIDGET(progress)), false); + gui_builder_deinit(); }