71 lines
1.9 KiB
C
71 lines
1.9 KiB
C
/*
|
|
* Copyright 2016 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/core.h>
|
|
#include <core/idle.h>
|
|
#include <gui/builder.h>
|
|
#include <gui/filter.h>
|
|
#include <gui/model.h>
|
|
#include <gui/playlist.h>
|
|
#include <gui/sidebar.h>
|
|
#include <gui/treeview.h>
|
|
|
|
struct core_init_data init_data = {
|
|
.playlist_ops = &playlist_ops,
|
|
};
|
|
|
|
static void test_library()
|
|
{
|
|
GtkTreeModel *model = gui_sidebar_model();
|
|
struct playlist *playlist;
|
|
GtkTreeIter iter;
|
|
|
|
gui_sidebar_iter_first(&iter);
|
|
gui_sidebar_iter_find(&iter, "Library", PL_MAX_TYPE);
|
|
g_assert_false(gtk_tree_model_iter_has_child(model, &iter));
|
|
|
|
g_assert_cmpuint(library_db_get()->db_size, ==, 0);
|
|
g_assert_null(playlist_get(PL_LIBRARY, "tests/Music/Hyrule Symphony"));
|
|
|
|
g_assert_true(gui_pl_library_add("tests/Music/Hyrule Symphony"));
|
|
playlist = playlist_get(PL_LIBRARY, "tests/Music/Hyrule Symphony");
|
|
g_assert_cmpuint(library_db_get()->db_size, ==, 1);
|
|
g_assert_cmpuint(playlist_size(playlist->pl_type,
|
|
playlist->pl_name), ==, 0);
|
|
g_assert_true(gtk_tree_model_iter_has_child(model, &iter));
|
|
g_assert_cmpuint(gtk_tree_model_iter_n_children(model, &iter), ==, 1);
|
|
|
|
while (idle_run_task()) {}
|
|
g_assert_cmpuint(library_db_get()->db_size, ==, 1);
|
|
g_assert_cmpuint(playlist_size(playlist->pl_type,
|
|
playlist->pl_name), ==, 13);
|
|
g_assert_true(gtk_tree_model_iter_has_child(model, &iter));
|
|
g_assert_cmpuint(gtk_tree_model_iter_n_children(model, &iter), ==, 1);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int ret;
|
|
|
|
gtk_init(&argc, NULL);
|
|
core_init(&argc, &argv, &init_data);
|
|
gui_builder_init("share/ocarina/ocarina.ui");
|
|
gui_model_init();
|
|
gui_filter_init();
|
|
gui_treeview_init();
|
|
gui_sidebar_init();
|
|
gui_playlist_init();
|
|
while (idle_run_task()) {}
|
|
|
|
g_test_init(&argc, &argv, NULL);
|
|
g_test_add_func("/Gui/Playlists/Library", test_library);
|
|
ret = g_test_run();
|
|
|
|
core_deinit();
|
|
gui_treeview_deinit();
|
|
gui_filter_deinit();
|
|
gui_model_deinit();
|
|
gui_builder_deinit();
|
|
return ret;
|
|
}
|