Anna Schumaker
1fa31c51a6
We can just look up the playlist instead, and then access the queue variable from there. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
136 lines
4.0 KiB
C
136 lines
4.0 KiB
C
/*
|
|
* Copyright 2016 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/audio.h>
|
|
#include <core/core.h>
|
|
#include <core/idle.h>
|
|
#include <gui/filter.h>
|
|
#include <gui/model.h>
|
|
#include <gui/window.h>
|
|
|
|
void *test_queue_init(struct queue *queue, void *data)
|
|
{ return NULL; }
|
|
void test_queue_deinit(struct queue *queue)
|
|
{ gui_filter_clear_search(queue->q_private); }
|
|
void test_queue_add(struct queue *queue, unsigned int n)
|
|
{ gui_model_add(queue->q_private, n); }
|
|
void test_queue_remove(struct queue *queue, unsigned int n)
|
|
{ gui_model_remove(queue->q_private, n); }
|
|
void test_queue_clear(struct queue *queue, unsigned int n)
|
|
{ gui_model_clear(queue->q_private, n); }
|
|
void test_queue_update(struct queue *queue, unsigned int n)
|
|
{ gui_model_update(queue->q_private, n); }
|
|
|
|
struct queue_ops test_ops = {
|
|
.qop_init = test_queue_init,
|
|
.qop_deinit = test_queue_deinit,
|
|
.qop_added = test_queue_add,
|
|
.qop_removed = test_queue_remove,
|
|
.qop_cleared = test_queue_clear,
|
|
.qop_updated = test_queue_update,
|
|
};
|
|
|
|
void test_on_load(struct track *track) {}
|
|
void test_on_state_change(GstState state) {}
|
|
void test_on_config_pause(int count) {}
|
|
|
|
struct audio_ops test_audio_ops = {
|
|
.on_load = test_on_load,
|
|
.on_state_change = test_on_state_change,
|
|
.on_config_pause = test_on_config_pause,
|
|
};
|
|
|
|
struct core_init_data init_data = {
|
|
.playlist_ops = &test_ops,
|
|
.audio_ops = &test_audio_ops,
|
|
};
|
|
|
|
void test_filter()
|
|
{
|
|
struct track *track;
|
|
GtkEntry *entry;
|
|
GtkTreeModel *model;
|
|
GtkTreePath *path;
|
|
GtkTreeIter iter;
|
|
unsigned int i;
|
|
|
|
g_assert_nonnull(gui_filter_get());
|
|
g_assert_true(GTK_IS_TREE_MODEL_FILTER(gui_filter_get()));
|
|
g_assert(gtk_tree_model_filter_get_model(gui_filter_get()) ==
|
|
GTK_TREE_MODEL(gui_model_get()));
|
|
|
|
entry = GTK_ENTRY(gui_filter_search());
|
|
model = GTK_TREE_MODEL(gui_filter_get());
|
|
playlist_lookup(PL_SYSTEM, "Collection")->pl_queue.q_private =
|
|
playlist_lookup(PL_SYSTEM, "Collection");
|
|
|
|
g_assert_false(gtk_tree_model_get_iter_first(model, &iter));
|
|
gui_filter_set_playlist(playlist_lookup(PL_SYSTEM, "Collection"));
|
|
g_assert_false(gtk_tree_model_get_iter_first(model, &iter));
|
|
|
|
playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony");
|
|
while (idle_run_task()) {};
|
|
g_assert_cmpuint(gtk_tree_model_iter_n_children(model, NULL), ==, 13);
|
|
|
|
for (i = 0; i < 13; i++) {
|
|
path = gui_filter_path_from_index(i);
|
|
g_assert_nonnull(path);
|
|
g_assert_cmpuint(gui_filter_path_get_index(path), ==, i);
|
|
|
|
track = gui_filter_path_get_track(path);
|
|
g_assert_nonnull(track);
|
|
g_assert_cmpuint(track->tr_track, ==, i + 1);
|
|
|
|
gui_filter_path_load_track(path);
|
|
g_assert(audio_cur_track() == track);
|
|
gtk_tree_path_free(path);
|
|
}
|
|
path = gui_filter_path_from_index(i);
|
|
g_assert_null(path);
|
|
|
|
path = gui_filter_path_from_index(12);
|
|
gtk_tree_path_next(path);
|
|
g_assert_null(gui_filter_path_get_track(path));
|
|
gtk_tree_path_free(path);
|
|
|
|
gtk_entry_set_text(entry, "Hyrule");
|
|
g_assert_cmpuint(gtk_tree_model_iter_n_children(model, NULL), ==, 13);
|
|
|
|
gtk_combo_box_set_active(gui_filter_how(), GUI_FILTER_TITLE);
|
|
g_assert_cmpuint(gtk_tree_model_iter_n_children(model, NULL), ==, 2);
|
|
|
|
gui_filter_set_playlist(playlist_lookup(PL_SYSTEM, "Unplayed"));
|
|
g_assert_cmpuint(gtk_tree_model_iter_n_children(model, NULL), ==, 13);
|
|
g_assert_cmpstr(gtk_entry_get_text(entry), ==, "");
|
|
|
|
gui_filter_set_playlist(playlist_lookup(PL_SYSTEM, "Collection"));
|
|
g_assert_cmpuint(gtk_tree_model_iter_n_children(model, NULL), ==, 2);
|
|
g_assert_cmpstr(gtk_entry_get_text(entry), ==, "hyrule");
|
|
|
|
gtk_combo_box_set_active(gui_filter_how(), GUI_FILTER_DEFAULT);
|
|
g_assert_cmpuint(gtk_tree_model_iter_n_children(model, NULL), ==, 13);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int ret;
|
|
|
|
gtk_init(&argc, NULL);
|
|
core_init(&argc, NULL, &init_data);
|
|
gui_builder_init("share/ocarina/ocarina.ui");
|
|
gui_window_init("share/ocarina/ocarina.png");
|
|
gui_model_init();
|
|
gui_filter_init();
|
|
|
|
g_test_init(&argc, &argv, NULL);
|
|
g_test_add_func("/Gui/Filter", test_filter);
|
|
ret = g_test_run();
|
|
|
|
gui_filter_deinit();
|
|
gui_model_deinit();
|
|
gui_window_deinit();
|
|
gui_builder_deinit();
|
|
core_deinit();
|
|
return ret;
|
|
}
|