Anna Schumaker
432d3e5d62
This way we don't need to keep including the same core libraries in almost every file. Implements #83: Include useful headers in core/core.h Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
78 lines
2.4 KiB
C
78 lines
2.4 KiB
C
/*
|
|
* Copyright 2016 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/core.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_playlist()
|
|
{
|
|
GtkTreeIter iter, child;
|
|
GtkTreePath *path;
|
|
|
|
gui_pl_library_add("tests/Music/Hyrule Symphony");
|
|
while (idle_run_task()) {}
|
|
playlist_add(playlist_lookup(PL_SYSTEM, "Favorites"), track_get(0));
|
|
gtk_tree_model_filter_refilter(gui_sidebar_filter());
|
|
|
|
g_assert_true(gui_sidebar_iter_first(&iter));
|
|
path = gtk_tree_model_get_path(gui_sidebar_model(), &iter);
|
|
gtk_tree_view_row_activated(gui_sidebar_treeview(), path, NULL);
|
|
g_assert_true(playlist_current() == playlist_lookup(PL_SYSTEM, "Collection"));
|
|
gtk_tree_path_free(path);
|
|
|
|
g_assert_false(settings_has("gui.sidebar.expand.Playlists"));
|
|
g_assert_true(gui_sidebar_iter_find(&iter, "Playlists", PL_MAX_TYPE));
|
|
g_assert_true(gtk_tree_model_filter_convert_child_iter_to_iter(
|
|
gui_sidebar_filter(), &child, &iter));
|
|
path = gtk_tree_model_get_path(GTK_TREE_MODEL(gui_sidebar_filter()),
|
|
&child);
|
|
g_assert_nonnull(path);
|
|
g_assert_true(gtk_tree_view_expand_row(gui_sidebar_treeview(), path, false));
|
|
g_assert_true(settings_has("gui.sidebar.expand.Playlists"));
|
|
g_assert_cmpuint(settings_get("gui.sidebar.expand.Playlists"), ==, 1);
|
|
g_assert_true(gtk_tree_view_collapse_row(gui_sidebar_treeview(), path));
|
|
g_assert_cmpuint(settings_get("gui.sidebar.expand.Playlists"), ==, 0);
|
|
gtk_tree_path_free(path);
|
|
|
|
g_assert_true(gui_sidebar_iter_down(&iter, &child));
|
|
g_assert_true(gtk_tree_model_filter_convert_child_iter_to_iter(
|
|
gui_sidebar_filter(), &iter, &child));
|
|
path = gtk_tree_model_get_path(GTK_TREE_MODEL(gui_sidebar_filter()),
|
|
&iter);
|
|
g_assert_nonnull(path);
|
|
gtk_tree_view_row_activated(gui_sidebar_treeview(), path, NULL);
|
|
g_assert_true(playlist_current() == playlist_lookup(PL_SYSTEM, "Favorites"));
|
|
gtk_tree_path_free(path);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int ret;
|
|
|
|
gtk_init(&argc, NULL);
|
|
core_init(&argc, NULL, NULL, 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/Playlist", test_playlist);
|
|
ret = g_test_run();
|
|
|
|
core_deinit();
|
|
gui_treeview_deinit();
|
|
gui_filter_deinit();
|
|
gui_model_deinit();
|
|
gui_builder_deinit();
|
|
return ret;
|
|
}
|