64 lines
1.8 KiB
C
64 lines
1.8 KiB
C
/*
|
|
* Copyright 2016 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/core.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>
|
|
#include <tests/test.h>
|
|
|
|
static void test_artist()
|
|
{
|
|
GtkTreeModel *model = gui_sidebar_model();
|
|
GtkTreeIter iter, child;
|
|
|
|
gui_sidebar_iter_first(&iter);
|
|
gui_sidebar_iter_find(&iter, "Collection", PL_SYSTEM);
|
|
g_assert_false(gtk_tree_model_iter_has_child(model, &iter));
|
|
|
|
g_assert_nonnull(gui_pl_library_add("tests/Music/Hyrule Symphony"));
|
|
g_assert_cmpuint(artist_db_get()->db_size, ==, 0);
|
|
g_assert_null(playlist_lookup(PL_ARTIST, "Koji Kondo"));
|
|
g_assert_false(gtk_tree_model_iter_has_child(model, &iter));
|
|
while (idle_run_task()) {}
|
|
g_assert_cmpuint(artist_db_get()->db_size, ==, 1);
|
|
g_assert_nonnull(playlist_lookup(PL_ARTIST, "Koji Kondo"));
|
|
g_assert_cmpuint(playlist_size(playlist_lookup(PL_ARTIST, "Koji Kondo")),
|
|
==, 13);
|
|
g_assert_true(gtk_tree_model_iter_has_child(model, &iter));
|
|
g_assert_cmpuint(gtk_tree_model_iter_n_children(model, &iter), ==, 1);
|
|
|
|
gui_sidebar_iter_down(&iter, &child);
|
|
g_assert_cmpstr_free(gui_sidebar_iter_name(&child), ==, "Koji Kondo");
|
|
g_assert_cmpuint(gui_sidebar_iter_type(&child), ==, PL_ARTIST);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int ret;
|
|
|
|
gtk_init(&argc, NULL);
|
|
core_init(&argc, &argv, &playlist_cb, NULL, IDLE_SYNC);
|
|
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/Artist", test_artist);
|
|
ret = g_test_run();
|
|
|
|
core_deinit();
|
|
gui_treeview_deinit();
|
|
gui_filter_deinit();
|
|
gui_model_deinit();
|
|
gui_builder_deinit();
|
|
return ret;
|
|
}
|