82 lines
2.1 KiB
C
82 lines
2.1 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_ops = &playlist_ops,
|
|
};
|
|
|
|
static const gchar *toplevel[3] = { "Queued Tracks", "Collection", "History" };
|
|
static const gchar *playlists[2] = {"Favorites", "Hidden" };
|
|
static const gchar *dynamic[3] = {"Most Played", "Least Played", "Unplayed" };
|
|
|
|
static void test_system()
|
|
{
|
|
GtkTreeIter iter, child;
|
|
unsigned int i;
|
|
|
|
gui_sidebar_iter_first(&iter);
|
|
for (i = 0; i < 3; i++) {
|
|
g_assert_cmpstr_free(gui_sidebar_iter_name(&iter), ==,
|
|
toplevel[i]);
|
|
g_assert_cmpuint(gui_sidebar_iter_type(&iter), ==, PL_SYSTEM);
|
|
gui_sidebar_iter_next(&iter);
|
|
}
|
|
|
|
gui_sidebar_iter_find(&iter, "Playlists", PL_MAX_TYPE);
|
|
gui_sidebar_iter_down(&iter, &child);
|
|
for (i = 0; i < 2; i++) {
|
|
g_assert_cmpstr_free(gui_sidebar_iter_name(&child), ==,
|
|
playlists[i]);
|
|
g_assert_cmpuint(gui_sidebar_iter_type(&child), ==, PL_SYSTEM);
|
|
gui_sidebar_iter_next(&child);
|
|
}
|
|
|
|
gui_sidebar_iter_find(&iter, "Dynamic", PL_MAX_TYPE);
|
|
gui_sidebar_iter_down(&iter, &child);
|
|
for (i = 0; i < 2; i++) {
|
|
g_assert_cmpstr_free(gui_sidebar_iter_name(&child), ==,
|
|
dynamic[i]);
|
|
g_assert_cmpuint(gui_sidebar_iter_type(&child), ==, PL_SYSTEM);
|
|
gui_sidebar_iter_next(&child);
|
|
}
|
|
|
|
g_assert_true(gui_pl_library_add("tests/Music/Hyrule Symphony"));
|
|
while (idle_run_task()) {}
|
|
}
|
|
|
|
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/System", test_system);
|
|
ret = g_test_run();
|
|
|
|
core_deinit();
|
|
gui_treeview_deinit();
|
|
gui_filter_deinit();
|
|
gui_model_deinit();
|
|
gui_builder_deinit();
|
|
return ret;
|
|
}
|