ocarina/tests/gui/view.c

71 lines
1.7 KiB
C

/*
* Copyright 2016 (c) Anna Schumaker.
*/
#include <core/audio.h>
#include <core/core.h>
#include <core/idle.h>
#include <core/playlist.h>
#include <core/settings.h>
#include <gui/builder.h>
#include <gui/filter.h>
#include <gui/model.h>
#include <gui/treeview.h>
#include <gui/view.h>
#include <tests/test.h>
unsigned int load_count = 0;
static void test_load(struct track *track) { load_count++; }
static void test_state_change(GstState state) {}
static void test_config_pause(int count) {}
struct audio_ops test_audio_ops = {
.on_load = test_load,
.on_state_change = test_state_change,
.on_config_pause = test_config_pause,
};
struct core_init_data init_data = {
.audio_ops = &test_audio_ops,
};
static void test_treeview()
{
GtkTreeView *treeview;
GtkTreeModel *filter;
GtkTreePath *path;
GtkTreeIter iter;
playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony");
while (idle_run_task() == true) {}
gui_filter_set_playlist(playlist_get(PL_SYSTEM, "Collection"));
filter = GTK_TREE_MODEL(gui_filter_get());
treeview = gui_treeview();
g_assert((void *)gtk_tree_view_get_model(treeview) ==
(void *)gui_filter_get());
gtk_tree_model_iter_nth_child(filter, &iter, NULL, 3);
path = gtk_tree_model_get_path(filter, &iter);
gtk_tree_view_row_activated(treeview, path, NULL);
g_assert_cmpuint(load_count, ==, 1);
gtk_tree_path_free(path);
gui_view_set_playlist(NULL);
}
int main(int argc, char **argv)
{
gtk_init(&argc, NULL);
core_init(&argc, NULL, &init_data);
gui_builder_init("share/ocarina/ocarina.ui");
gui_model_init();
gui_view_init();
while (idle_run_task()) {};
g_test_init(&argc, &argv, NULL);
g_test_add_func("/Gui/Treeview", test_treeview);
return g_test_run();
}