/* * Copyright 2016 (c) Anna Schumaker. */ #include #include #include #include #include #include #include #include #include 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_ops test_audio_ops = { .on_load = test_audio_load, .on_state_change = test_change_state, .on_config_pause = test_config_pause, }; struct core_init_data init_data = { .playlist_ops = &playlist_ops, .audio_ops = &test_audio_ops, #ifdef CONFIG_ALBUM_ART_TEST .idle_async = true, #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, &init_data); 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; }