Anna Schumaker
3286b61dcf
Artist and library playlists are allocated manually, so there should be generic functions that both can use to get a playlist pointer and free it when we're done. I also add a callback for telling the UI when new playlists have been allocated. This isn't needed for Library playlists, but this is the only way the UI can know about new Artists. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
69 lines
1.9 KiB
C
69 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>
|
|
#include <tests/test.h>
|
|
|
|
struct core_init_data init_data = {
|
|
.playlist_cb = &playlist_cb,
|
|
};
|
|
|
|
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, &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/Artist", test_artist);
|
|
ret = g_test_run();
|
|
|
|
core_deinit();
|
|
gui_treeview_deinit();
|
|
gui_filter_deinit();
|
|
gui_model_deinit();
|
|
gui_builder_deinit();
|
|
return ret;
|
|
}
|