|
|
|
@ -34,6 +34,7 @@ static struct playlist_ops test_ops = {
|
|
|
|
|
.pl_remove = playlist_generic_remove, |
|
|
|
|
.pl_set_random = playlist_generic_set_random, |
|
|
|
|
.pl_sort = playlist_generic_sort, |
|
|
|
|
.pl_rearrange = playlist_generic_rearrange, |
|
|
|
|
}; |
|
|
|
|
static struct playlist_callbacks test_cb = { |
|
|
|
|
.pl_cb_alloc = test_pl_alloc, |
|
|
|
@ -76,6 +77,7 @@ static void test_null()
|
|
|
|
|
g_assert_false(playlist_sort(NULL, COMPARE_TRACK)); |
|
|
|
|
playlist_generic_resort(NULL); |
|
|
|
|
playlist_clear_sort(NULL); |
|
|
|
|
g_assert_false(playlist_rearrange(NULL, 0, 0)); |
|
|
|
|
|
|
|
|
|
playlist_set_search(NULL, NULL); |
|
|
|
|
|
|
|
|
@ -280,6 +282,43 @@ static void test_sorting()
|
|
|
|
|
g_assert_null(p.pl_sort); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void test_rearranging() |
|
|
|
|
{ |
|
|
|
|
struct playlist p = DEFINE_PLAYLIST(PL_MAX_TYPE, "Test", 0, &test_ops); |
|
|
|
|
struct track *track; |
|
|
|
|
unsigned int i; |
|
|
|
|
|
|
|
|
|
playlist_generic_init(&p, 4, COMPARE_ARTIST, COMPARE_YEAR, |
|
|
|
|
COMPARE_ALBUM, COMPARE_TRACK); |
|
|
|
|
g_assert_cmpuint(g_slist_length(p.pl_sort), ==, 4); |
|
|
|
|
|
|
|
|
|
for (i = 0; i < 13; i++) |
|
|
|
|
playlist_add(&p, track_get(i)); |
|
|
|
|
|
|
|
|
|
g_assert_false(playlist_rearrange(&p, 42, 4)); |
|
|
|
|
g_assert_cmpuint(g_slist_length(p.pl_sort), ==, 4); |
|
|
|
|
g_assert_false(playlist_rearrange(&p, 4, 42)); |
|
|
|
|
g_assert_cmpuint(g_slist_length(p.pl_sort), ==, 4); |
|
|
|
|
g_assert_false(playlist_rearrange(&p, 4, 4)); |
|
|
|
|
g_assert_cmpuint(g_slist_length(p.pl_sort), ==, 4); |
|
|
|
|
g_assert_true(playlist_rearrange(&p, 12, 0)); |
|
|
|
|
g_assert_cmpuint(g_slist_length(p.pl_sort), ==, 0); |
|
|
|
|
g_assert_true(playlist_rearrange(&p, 1, 12)); |
|
|
|
|
g_assert_cmpuint(g_slist_length(p.pl_sort), ==, 0); |
|
|
|
|
|
|
|
|
|
for (i = 0; i < 13; i++) { |
|
|
|
|
track = playlist_at(&p, i); |
|
|
|
|
if (i == 0) |
|
|
|
|
g_assert_cmpuint(track->tr_track, ==, 13); |
|
|
|
|
else if (i == 12) |
|
|
|
|
g_assert_cmpuint(track->tr_track, ==, 1); |
|
|
|
|
else |
|
|
|
|
g_assert_cmpuint(track->tr_track, ==, i + 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
playlist_generic_deinit(&p); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void test_next() |
|
|
|
|
{ |
|
|
|
|
struct playlist p = DEFINE_PLAYLIST(PL_MAX_TYPE, "Test", 0, &test_ops); |
|
|
|
@ -404,6 +443,7 @@ int main(int argc, char **argv)
|
|
|
|
|
g_test_add_func("/Core/Playlist/NULL", test_null); |
|
|
|
|
g_test_add_func("/Core/Playlists/General", test_playlist); |
|
|
|
|
g_test_add_func("/Core/Playlists/Sorting", test_sorting); |
|
|
|
|
g_test_add_func("/Core/Playlists/Rearranging", test_rearranging); |
|
|
|
|
g_test_add_func("/Core/Playlists/Next Track", test_next); |
|
|
|
|
g_test_add_func("/Core/Playlist/Save and Load", test_save_load); |
|
|
|
|
ret = g_test_run(); |
|
|
|
|