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>
97 lines
2.7 KiB
C
97 lines
2.7 KiB
C
/*
|
|
* Copyright 2016 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/core.h>
|
|
#include <gui/artwork.h>
|
|
#include <gui/filter.h>
|
|
#include <gui/model.h>
|
|
#include <gui/playlist.h>
|
|
#include <gui/sidebar.h>
|
|
#include <gui/treeview.h>
|
|
|
|
static void test_audio_load(struct track *track)
|
|
{ gui_artwork_set_cover(); }
|
|
static void test_change_state(GstState state) { }
|
|
static void test_config_pause(int n) { }
|
|
|
|
static struct audio_callbacks test_audio_cb = {
|
|
.audio_cb_load = test_audio_load,
|
|
.audio_cb_state_change = test_change_state,
|
|
.audio_cb_config_pause = test_config_pause,
|
|
};
|
|
|
|
#ifdef CONFIG_ALBUM_ART_TEST
|
|
enum idle_sync_t test_sync = IDLE_ASYNC;
|
|
#else /* CONFIG_ALBUM_ART_TEST */
|
|
enum idle_sync_t test_sync = IDLE_SYNC;
|
|
#endif /* CONFIG_ALBUM_ART_TEST */
|
|
|
|
|
|
static void test_artwork(void)
|
|
{
|
|
const gchar *name;
|
|
GtkIconSize size;
|
|
gchar *path;
|
|
|
|
g_assert_true(GTK_IS_IMAGE(gui_artwork()));
|
|
|
|
gtk_image_get_icon_name(gui_artwork(), &name, &size);
|
|
g_assert_cmpuint(gtk_image_get_storage_type(gui_artwork()), ==,
|
|
GTK_IMAGE_ICON_NAME);
|
|
g_assert_cmpstr(name, ==, "image-missing");
|
|
g_assert_cmpuint(size, ==, GTK_ICON_SIZE_DIALOG);
|
|
g_assert_false(gtk_widget_is_sensitive(GTK_WIDGET(gui_artwork())));
|
|
|
|
#ifdef CONFIG_ALBUM_ART_TEST
|
|
audio_load(track_get(0));
|
|
g_assert_cmpuint(gtk_image_get_storage_type(gui_artwork()), ==,
|
|
GTK_IMAGE_SURFACE);
|
|
#endif /* CONFIG_ALBUM_ART_TEST */
|
|
|
|
track_get(1)->tr_album = album_find(artist_find("Koji Kondo"),
|
|
genre_find("Video Game Music"),
|
|
"Hyrule Symphony 2", 1999);
|
|
audio_load(track_get(1));
|
|
gtk_image_get_icon_name(gui_artwork(), &name, &size);
|
|
g_assert_cmpuint(gtk_image_get_storage_type(gui_artwork()), ==,
|
|
GTK_IMAGE_ICON_NAME);
|
|
g_assert_cmpstr(name, ==, "image-missing");
|
|
g_assert_cmpuint(size, ==, GTK_ICON_SIZE_DIALOG);
|
|
g_assert_false(gtk_widget_is_sensitive(GTK_WIDGET(gui_artwork())));
|
|
|
|
path = album_artwork_path(track_get(0)->tr_album);
|
|
#ifdef CONFIG_ALBUM_ART_TEST
|
|
gui_artwork_import(track_get(1), path);
|
|
g_assert_cmpuint(gtk_image_get_storage_type(gui_artwork()), ==,
|
|
GTK_IMAGE_SURFACE);
|
|
#endif /* CONFIG_ALBUM_ART_TEST */
|
|
g_free(path);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int ret;
|
|
|
|
gtk_init(&argc, NULL);
|
|
core_init(&argc, NULL, NULL, &test_audio_cb, test_sync);
|
|
gui_builder_init("share/ocarina/ocarina.ui");
|
|
gui_model_init();
|
|
gui_filter_init();
|
|
gui_treeview_init();
|
|
gui_sidebar_init();
|
|
gui_playlist_init();
|
|
gui_pl_library_add("tests/Music/Hyrule Symphony");
|
|
while (idle_run_task()) {}
|
|
|
|
g_test_init(&argc, &argv, NULL);
|
|
g_test_add_func("/Gui/Artwork", test_artwork);
|
|
ret = g_test_run();
|
|
|
|
core_deinit();
|
|
gui_treeview_deinit();
|
|
gui_filter_deinit();
|
|
gui_model_deinit();
|
|
gui_builder_deinit();
|
|
return ret;
|
|
}
|