Added unittest for multi-disc albums (#317)
This commit is contained in:
parent
c5848ce648
commit
c1d90eb954
|
@ -37,11 +37,11 @@ public class AlbumsTest extends AbstractTestClass {
|
||||||
Cursor cursor = shadowContentResolver.query(uri, TestValues.Album.PROJECTION, null, null, null);
|
Cursor cursor = shadowContentResolver.query(uri, TestValues.Album.PROJECTION, null, null, null);
|
||||||
|
|
||||||
assertNotNull(cursor);
|
assertNotNull(cursor);
|
||||||
assertEquals("cursor size ", 234, cursor.getCount());
|
assertEquals("cursor size ", 235, cursor.getCount());
|
||||||
int columnIndex = cursor.getColumnIndex(MediaContract.AlbumsColumns.ALBUMID);
|
int columnIndex = cursor.getColumnIndex(MediaContract.AlbumsColumns.ALBUMID);
|
||||||
TestUtils.testCursorContainsRange(cursor, columnIndex, 1, 75);
|
TestUtils.testCursorContainsRange(cursor, columnIndex, 1, 75);
|
||||||
TestUtils.testCursorContainsRange(cursor, columnIndex, 77, 82);
|
TestUtils.testCursorContainsRange(cursor, columnIndex, 77, 82);
|
||||||
TestUtils.testCursorContainsRange(cursor, columnIndex, 84, 235);
|
TestUtils.testCursorContainsRange(cursor, columnIndex, 84, 237);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -37,12 +37,12 @@ public class ArtistsTest extends AbstractTestClass {
|
||||||
Cursor cursor = shadowContentResolver.query(uri, TestValues.Artist.PROJECTION, null, null, null);
|
Cursor cursor = shadowContentResolver.query(uri, TestValues.Artist.PROJECTION, null, null, null);
|
||||||
|
|
||||||
assertNotNull(cursor);
|
assertNotNull(cursor);
|
||||||
assertEquals("cursor size ", 228, cursor.getCount());
|
assertEquals("cursor size ", 229, cursor.getCount());
|
||||||
TestUtils.testCursorContainsRange(cursor, cursor.getColumnIndex(MediaContract.ArtistsColumns.ARTISTID),
|
TestUtils.testCursorContainsRange(cursor, cursor.getColumnIndex(MediaContract.ArtistsColumns.ARTISTID),
|
||||||
1, 94);
|
1, 94);
|
||||||
//Artist id 95 should be missing
|
//Artist id 95 should be missing
|
||||||
TestUtils.testCursorContainsRange(cursor, cursor.getColumnIndex(MediaContract.ArtistsColumns.ARTISTID),
|
TestUtils.testCursorContainsRange(cursor, cursor.getColumnIndex(MediaContract.ArtistsColumns.ARTISTID),
|
||||||
96, 228);
|
96, 230);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -105,9 +105,9 @@ public class SongsTest extends AbstractTestClass {
|
||||||
null, null, null);
|
null, null, null);
|
||||||
|
|
||||||
assertNotNull(cursor);
|
assertNotNull(cursor);
|
||||||
assertEquals("cursor size ", 1810, cursor.getCount());
|
assertEquals("cursor size ", 1817, cursor.getCount());
|
||||||
TestUtils.testCursorContainsRange(cursor, cursor.getColumnIndex(MediaContract.Songs.SONGID),
|
TestUtils.testCursorContainsRange(cursor, cursor.getColumnIndex(MediaContract.Songs.SONGID),
|
||||||
1, 1810);
|
1, 1817);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -131,8 +131,6 @@ public class SongsTest extends AbstractTestClass {
|
||||||
TestValues.ArtistSong.PROJECTION,
|
TestValues.ArtistSong.PROJECTION,
|
||||||
null, null, null);
|
null, null, null);
|
||||||
|
|
||||||
assertTrue(CursorUtils.moveCursorToFirstOccurrence(cursor, cursor.getColumnIndex(MediaContract.Songs.SONGID),
|
|
||||||
TestValues.SongWithArtistWithoutAlbum.songId));
|
|
||||||
assertTrue(CursorUtils.moveCursorToFirstOccurrence(cursor, cursor.getColumnIndex(MediaContract.Songs.SONGID),
|
assertTrue(CursorUtils.moveCursorToFirstOccurrence(cursor, cursor.getColumnIndex(MediaContract.Songs.SONGID),
|
||||||
TestValues.SongWithArtistWithoutAlbum.songId));
|
TestValues.SongWithArtistWithoutAlbum.songId));
|
||||||
TestValues.SongWithArtistWithoutAlbum.test(cursor);
|
TestValues.SongWithArtistWithoutAlbum.test(cursor);
|
||||||
|
@ -165,6 +163,20 @@ public class SongsTest extends AbstractTestClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void queryMultidiscAlbumSongsTest() {
|
||||||
|
Uri uri = MediaContract.Songs.buildAlbumSongsListUri(hostInfo.getId(),
|
||||||
|
TestValues.MultidiscAlbumSongs.albumId);
|
||||||
|
|
||||||
|
Cursor cursor = shadowContentResolver.query(uri, TestValues.MultidiscAlbumSongs.PROJECTION,
|
||||||
|
null, null, null);
|
||||||
|
|
||||||
|
assertNotNull(cursor);
|
||||||
|
assertEquals("cursor size ", 7, cursor.getCount());
|
||||||
|
TestUtils.testCursorContainsRange(cursor, cursor.getColumnIndex(MediaContract.SongsColumns.SONGID),
|
||||||
|
1811, 1817);
|
||||||
|
}
|
||||||
|
|
||||||
private void testMultipleArtistInArtistSongsList(int artistId, int songId) {
|
private void testMultipleArtistInArtistSongsList(int artistId, int songId) {
|
||||||
Uri uri = MediaContract.Songs.buildArtistSongsListUri(hostInfo.getId(),
|
Uri uri = MediaContract.Songs.buildArtistSongsListUri(hostInfo.getId(),
|
||||||
artistId);
|
artistId);
|
||||||
|
|
|
@ -139,6 +139,23 @@ public class TestValues {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class MultidiscAlbumSongs {
|
||||||
|
public static int albumId = 237;
|
||||||
|
public static String title = "Multi disc album";
|
||||||
|
public static String displayArtist = "Multi disc artist";
|
||||||
|
|
||||||
|
public static String[] PROJECTION = MediaContract.Songs.ALL_COLUMNS;
|
||||||
|
|
||||||
|
public static void test(Cursor cursor) {
|
||||||
|
int resultAlbumId = cursor.getInt(cursor.getColumnIndex(MediaContract.AlbumsColumns.ALBUMID));
|
||||||
|
assertEquals(albumId, resultAlbumId);
|
||||||
|
String resultTitle = cursor.getString(cursor.getColumnIndex(MediaContract.AlbumsColumns.TITLE));
|
||||||
|
assertEquals(title, resultTitle);
|
||||||
|
String resultArtist = cursor.getString(cursor.getColumnIndex(MediaContract.AlbumsColumns.DISPLAYARTIST));
|
||||||
|
assertEquals(displayArtist, resultArtist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class ArtistSong {
|
public static class ArtistSong {
|
||||||
public static int songId = 96;
|
public static int songId = 96;
|
||||||
public static int artistId = Artist.artistId;
|
public static int artistId = Artist.artistId;
|
||||||
|
|
|
@ -7631,6 +7631,35 @@
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"thumbnail" : "",
|
"thumbnail" : "",
|
||||||
"rating" : 0
|
"rating" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type" : "",
|
||||||
|
"musicbrainzalbumid" : "",
|
||||||
|
"title" : "Multi disc album",
|
||||||
|
"label" : "Multi disc album",
|
||||||
|
"genreid" : [],
|
||||||
|
"theme" : [],
|
||||||
|
"albumlabel" : "",
|
||||||
|
"playcount" : 0,
|
||||||
|
"style" : [],
|
||||||
|
"albumid" : 237,
|
||||||
|
"rating" : 0,
|
||||||
|
"fanart" : "",
|
||||||
|
"genre" : [],
|
||||||
|
"description" : "",
|
||||||
|
"artist" : [
|
||||||
|
"Multi disc artist"
|
||||||
|
],
|
||||||
|
"year" : 0,
|
||||||
|
"artistid" : [
|
||||||
|
230
|
||||||
|
],
|
||||||
|
"mood" : [],
|
||||||
|
"displayartist" : "Multi disc artist",
|
||||||
|
"thumbnail" : "",
|
||||||
|
"musicbrainzalbumartistid" : [
|
||||||
|
""
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -4562,11 +4562,31 @@
|
||||||
"musicbrainzartistid" : [
|
"musicbrainzartistid" : [
|
||||||
""
|
""
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"instrument" : [],
|
||||||
|
"yearsactive" : [],
|
||||||
|
"label" : "Multi disc artist",
|
||||||
|
"died" : "",
|
||||||
|
"born" : "",
|
||||||
|
"genre" : [],
|
||||||
|
"fanart" : "",
|
||||||
|
"disbanded" : "",
|
||||||
|
"artist" : "Multi disc artist",
|
||||||
|
"description" : "",
|
||||||
|
"formed" : "",
|
||||||
|
"style" : [],
|
||||||
|
"artistid" : 230,
|
||||||
|
"mood" : [],
|
||||||
|
"thumbnail" : "",
|
||||||
|
"musicbrainzartistid" : [
|
||||||
|
""
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"limits" : {
|
"limits" : {
|
||||||
"total" : 227,
|
"total" : 228,
|
||||||
"end" : 228,
|
"end" : 229,
|
||||||
"start" : 0
|
"start" : 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75383,12 +75383,278 @@
|
||||||
"playcount" : 0,
|
"playcount" : 0,
|
||||||
"track" : 3,
|
"track" : 3,
|
||||||
"albumid" : 236
|
"albumid" : 236
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"genreid" : [],
|
||||||
|
"albumartistid" : [
|
||||||
|
232
|
||||||
|
],
|
||||||
|
"musicbrainztrackid" : "",
|
||||||
|
"duration" : 5,
|
||||||
|
"disc" : 1,
|
||||||
|
"album" : "Multi disc album",
|
||||||
|
"musicbrainzalbumid" : "",
|
||||||
|
"label" : "First disc first song",
|
||||||
|
"title" : "First disc first song",
|
||||||
|
"artistid" : [
|
||||||
|
232
|
||||||
|
],
|
||||||
|
"lastplayed" : "",
|
||||||
|
"displayartist" : "Multi disc artist",
|
||||||
|
"musicbrainzalbumartistid" : [],
|
||||||
|
"thumbnail" : "",
|
||||||
|
"musicbrainzartistid" : [],
|
||||||
|
"comment" : "",
|
||||||
|
"lyrics" : "",
|
||||||
|
"track" : 1,
|
||||||
|
"year" : 0,
|
||||||
|
"songid" : 1811,
|
||||||
|
"fanart" : "",
|
||||||
|
"genre" : [],
|
||||||
|
"file" : "/Users/martijn/Projects/dummymediafiles/media/music/Multi disc artist/Multi disc album/01-first_disc_first_track.mp3",
|
||||||
|
"artist" : [
|
||||||
|
"Multi disc artist"
|
||||||
|
],
|
||||||
|
"playcount" : 0,
|
||||||
|
"albumid" : 237,
|
||||||
|
"rating" : 0,
|
||||||
|
"albumartist" : [
|
||||||
|
"Multi disc artist"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"musicbrainzalbumid" : "",
|
||||||
|
"label" : "First disc second song",
|
||||||
|
"title" : "First disc second song",
|
||||||
|
"album" : "Multi disc album",
|
||||||
|
"disc" : 1,
|
||||||
|
"duration" : 5,
|
||||||
|
"musicbrainztrackid" : "",
|
||||||
|
"albumartistid" : [
|
||||||
|
232
|
||||||
|
],
|
||||||
|
"genreid" : [],
|
||||||
|
"playcount" : 0,
|
||||||
|
"rating" : 0,
|
||||||
|
"albumartist" : [
|
||||||
|
"Multi disc artist"
|
||||||
|
],
|
||||||
|
"albumid" : 237,
|
||||||
|
"genre" : [],
|
||||||
|
"fanart" : "",
|
||||||
|
"artist" : [
|
||||||
|
"Multi disc artist"
|
||||||
|
],
|
||||||
|
"file" : "/Users/martijn/Projects/dummymediafiles/media/music/Multi disc artist/Multi disc album/02-first_disc_second_track.mp3",
|
||||||
|
"year" : 0,
|
||||||
|
"songid" : 1812,
|
||||||
|
"track" : 2,
|
||||||
|
"lastplayed" : "",
|
||||||
|
"artistid" : [
|
||||||
|
232
|
||||||
|
],
|
||||||
|
"thumbnail" : "",
|
||||||
|
"musicbrainzartistid" : [],
|
||||||
|
"comment" : "",
|
||||||
|
"musicbrainzalbumartistid" : [],
|
||||||
|
"lyrics" : "",
|
||||||
|
"displayartist" : "Multi disc artist"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"album" : "Multi disc album",
|
||||||
|
"musicbrainzalbumid" : "",
|
||||||
|
"title" : "Second disc first song",
|
||||||
|
"label" : "Second disc first song",
|
||||||
|
"albumartistid" : [
|
||||||
|
232
|
||||||
|
],
|
||||||
|
"genreid" : [],
|
||||||
|
"musicbrainztrackid" : "",
|
||||||
|
"duration" : 5,
|
||||||
|
"disc" : 2,
|
||||||
|
"genre" : [],
|
||||||
|
"fanart" : "",
|
||||||
|
"file" : "/Users/martijn/Projects/dummymediafiles/media/music/Multi disc artist/Multi disc album/01-second_disc_first_track.mp3",
|
||||||
|
"artist" : [
|
||||||
|
"Multi disc artist"
|
||||||
|
],
|
||||||
|
"playcount" : 0,
|
||||||
|
"albumid" : 237,
|
||||||
|
"albumartist" : [
|
||||||
|
"Multi disc artist"
|
||||||
|
],
|
||||||
|
"rating" : 0,
|
||||||
|
"artistid" : [
|
||||||
|
232
|
||||||
|
],
|
||||||
|
"lastplayed" : "",
|
||||||
|
"displayartist" : "Multi disc artist",
|
||||||
|
"thumbnail" : "",
|
||||||
|
"musicbrainzartistid" : [],
|
||||||
|
"comment" : "",
|
||||||
|
"musicbrainzalbumartistid" : [],
|
||||||
|
"lyrics" : "",
|
||||||
|
"track" : 1,
|
||||||
|
"songid" : 1813,
|
||||||
|
"year" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"albumartist" : [
|
||||||
|
"Multi disc artist"
|
||||||
|
],
|
||||||
|
"rating" : 0,
|
||||||
|
"albumid" : 237,
|
||||||
|
"playcount" : 0,
|
||||||
|
"artist" : [
|
||||||
|
"Multi disc artist"
|
||||||
|
],
|
||||||
|
"file" : "/Users/martijn/Projects/dummymediafiles/media/music/Multi disc artist/Multi disc album/02-second_disc_second_track.mp3",
|
||||||
|
"genre" : [],
|
||||||
|
"fanart" : "",
|
||||||
|
"year" : 0,
|
||||||
|
"songid" : 1814,
|
||||||
|
"track" : 2,
|
||||||
|
"musicbrainzartistid" : [],
|
||||||
|
"thumbnail" : "",
|
||||||
|
"musicbrainzalbumartistid" : [],
|
||||||
|
"comment" : "",
|
||||||
|
"lyrics" : "",
|
||||||
|
"displayartist" : "Multi disc artist",
|
||||||
|
"lastplayed" : "",
|
||||||
|
"artistid" : [
|
||||||
|
232
|
||||||
|
],
|
||||||
|
"label" : "Second disc second song",
|
||||||
|
"title" : "Second disc second song",
|
||||||
|
"musicbrainzalbumid" : "",
|
||||||
|
"album" : "Multi disc album",
|
||||||
|
"duration" : 5,
|
||||||
|
"disc" : 2,
|
||||||
|
"musicbrainztrackid" : "",
|
||||||
|
"genreid" : [],
|
||||||
|
"albumartistid" : [
|
||||||
|
232
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title" : "Third disc first song",
|
||||||
|
"label" : "Third disc first song",
|
||||||
|
"musicbrainzalbumid" : "",
|
||||||
|
"album" : "Multi disc album",
|
||||||
|
"disc" : 3,
|
||||||
|
"duration" : 5,
|
||||||
|
"musicbrainztrackid" : "",
|
||||||
|
"genreid" : [],
|
||||||
|
"albumartistid" : [
|
||||||
|
232
|
||||||
|
],
|
||||||
|
"rating" : 0,
|
||||||
|
"albumartist" : [
|
||||||
|
"Multi disc artist"
|
||||||
|
],
|
||||||
|
"albumid" : 237,
|
||||||
|
"playcount" : 0,
|
||||||
|
"artist" : [
|
||||||
|
"Multi disc artist"
|
||||||
|
],
|
||||||
|
"file" : "/Users/martijn/Projects/dummymediafiles/media/music/Multi disc artist/Multi disc album/01-third_disc_first_track.mp3",
|
||||||
|
"genre" : [],
|
||||||
|
"fanart" : "",
|
||||||
|
"year" : 0,
|
||||||
|
"songid" : 1815,
|
||||||
|
"track" : 1,
|
||||||
|
"thumbnail" : "",
|
||||||
|
"musicbrainzalbumartistid" : [],
|
||||||
|
"musicbrainzartistid" : [],
|
||||||
|
"comment" : "",
|
||||||
|
"lyrics" : "",
|
||||||
|
"displayartist" : "Multi disc artist",
|
||||||
|
"lastplayed" : "",
|
||||||
|
"artistid" : [
|
||||||
|
232
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"album" : "Multi disc album",
|
||||||
|
"musicbrainzalbumid" : "",
|
||||||
|
"label" : "Third disc second song",
|
||||||
|
"title" : "Third disc second song",
|
||||||
|
"musicbrainztrackid" : "",
|
||||||
|
"genreid" : [],
|
||||||
|
"albumartistid" : [
|
||||||
|
232
|
||||||
|
],
|
||||||
|
"duration" : 5,
|
||||||
|
"disc" : 3,
|
||||||
|
"fanart" : "",
|
||||||
|
"genre" : [],
|
||||||
|
"artist" : [
|
||||||
|
"Multi disc artist"
|
||||||
|
],
|
||||||
|
"file" : "/Users/martijn/Projects/dummymediafiles/media/music/Multi disc artist/Multi disc album/02-third_disc_second_track.mp3",
|
||||||
|
"playcount" : 0,
|
||||||
|
"albumartist" : [
|
||||||
|
"Multi disc artist"
|
||||||
|
],
|
||||||
|
"rating" : 0,
|
||||||
|
"albumid" : 237,
|
||||||
|
"lastplayed" : "",
|
||||||
|
"artistid" : [
|
||||||
|
232
|
||||||
|
],
|
||||||
|
"musicbrainzalbumartistid" : [],
|
||||||
|
"thumbnail" : "",
|
||||||
|
"musicbrainzartistid" : [],
|
||||||
|
"comment" : "",
|
||||||
|
"lyrics" : "",
|
||||||
|
"displayartist" : "Multi disc artist",
|
||||||
|
"year" : 0,
|
||||||
|
"songid" : 1816,
|
||||||
|
"track" : 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"file" : "/Users/martijn/Projects/dummymediafiles/media/music/Multi disc artist/Multi disc album/03-third_disc_third_track.mp3",
|
||||||
|
"artist" : [
|
||||||
|
"Multi disc artist"
|
||||||
|
],
|
||||||
|
"fanart" : "",
|
||||||
|
"genre" : [],
|
||||||
|
"albumid" : 237,
|
||||||
|
"albumartist" : [
|
||||||
|
"Multi disc artist"
|
||||||
|
],
|
||||||
|
"rating" : 0,
|
||||||
|
"playcount" : 0,
|
||||||
|
"displayartist" : "Multi disc artist",
|
||||||
|
"thumbnail" : "",
|
||||||
|
"musicbrainzartistid" : [],
|
||||||
|
"musicbrainzalbumartistid" : [],
|
||||||
|
"lyrics" : "",
|
||||||
|
"comment" : "",
|
||||||
|
"artistid" : [
|
||||||
|
232
|
||||||
|
],
|
||||||
|
"lastplayed" : "",
|
||||||
|
"track" : 3,
|
||||||
|
"year" : 0,
|
||||||
|
"songid" : 1817,
|
||||||
|
"album" : "Multi disc album",
|
||||||
|
"title" : "Third disc third song",
|
||||||
|
"label" : "Third disc third song",
|
||||||
|
"musicbrainzalbumid" : "",
|
||||||
|
"albumartistid" : [
|
||||||
|
232
|
||||||
|
],
|
||||||
|
"genreid" : [],
|
||||||
|
"musicbrainztrackid" : "",
|
||||||
|
"duration" : 5,
|
||||||
|
"disc" : 3
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"limits" : {
|
"limits" : {
|
||||||
"end" : 1809,
|
"end" : 1817,
|
||||||
"start" : 0,
|
"start" : 0,
|
||||||
"total" : 1810
|
"total" : 1818
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"jsonrpc" : "2.0"
|
"jsonrpc" : "2.0"
|
||||||
|
|
|
@ -49,6 +49,7 @@ public class TestUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests if cursor contains all numbers from start until end for given column index.
|
* Tests if cursor contains all numbers from start until end for given column index.
|
||||||
|
* Including the start and end integers.
|
||||||
* @param columnIndex
|
* @param columnIndex
|
||||||
* @param cursor
|
* @param cursor
|
||||||
* @param start
|
* @param start
|
||||||
|
|
|
@ -197,41 +197,48 @@ sub printAlbumTestNumbers($$) {
|
||||||
print "\n\n";
|
print "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub printSongTestNumbers($$) {
|
sub printSongTestNumbers(\@) {
|
||||||
my $artistid = shift;
|
my $songids = shift;
|
||||||
my $albumid = shift;
|
print "Amount of songs: ", scalar @{$songids}, "\n\n";
|
||||||
|
print "Song ids: ";
|
||||||
|
my @songs = sort {$a->{"songid"} <=> $b->{"songid"}} @{$songids};
|
||||||
|
printRanges("songid", @songs);
|
||||||
|
print "\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
my $json_hash = decodeJson( "AudioLibrary.GetSongs.json" );
|
sub printArtistSongsTestNumbers(\@$) {
|
||||||
my $result = getSongs($json_hash);
|
my $songids = shift;
|
||||||
print "Amount of songs: ", scalar @{$result}, "\n\n";
|
my $artistid = shift;
|
||||||
|
|
||||||
my @songsforartist;
|
my @songsforartist;
|
||||||
my @songsforalbum;
|
|
||||||
|
|
||||||
print "Song ids: ";
|
for my $song (@{$songids}) {
|
||||||
|
|
||||||
my @songids = sort {$a->{"songid"} <=> $b->{"songid"}} @{$result};
|
|
||||||
printRanges("songid", @songids);
|
|
||||||
|
|
||||||
for my $song (@songids) {
|
|
||||||
for my $id (@{$song->{"artistid"}}) {
|
for my $id (@{$song->{"artistid"}}) {
|
||||||
if ( $id == $artistid ) {
|
if ( $id == $artistid ) {
|
||||||
push @songsforartist, $song;
|
push @songsforartist, $song;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
print "Songs for artistid " . $artistid . ": total=" . scalar @songsforartist . ": ids=";
|
||||||
|
printRanges("songid", @songsforartist);
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub printAlbumSongsTestNumbers(\@$) {
|
||||||
|
my $songids = shift;
|
||||||
|
my $albumid = shift;
|
||||||
|
|
||||||
|
my @songsforalbum;
|
||||||
|
|
||||||
|
for my $song (@{$songids}) {
|
||||||
if ( $song->{"albumid"} == $albumid ) {
|
if ( $song->{"albumid"} == $albumid ) {
|
||||||
push @songsforalbum, $song;
|
push @songsforalbum, $song;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print "\n\n";
|
|
||||||
|
|
||||||
print "Songs for artistid " . $artistid . ": total=" . scalar @songsforartist . ": ids=";
|
|
||||||
printRanges("songid", @songsforartist);
|
|
||||||
print "\n\n";
|
|
||||||
|
|
||||||
print "Songs for albumid " . $albumid . ": total=" . scalar @songsforalbum . ": ids=";
|
print "Songs for albumid " . $albumid . ": total=" . scalar @songsforalbum . ": ids=";
|
||||||
printRanges("songid", @songsforalbum);
|
printRanges("songid", @songsforalbum);
|
||||||
print "\n\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub printSongCornerCases() {
|
sub printSongCornerCases() {
|
||||||
|
@ -278,6 +285,12 @@ printArtistTestNumbers(13);
|
||||||
printAlbumTestNumbers(13, 13);
|
printAlbumTestNumbers(13, 13);
|
||||||
printAlbumCornerCases();
|
printAlbumCornerCases();
|
||||||
|
|
||||||
printSongTestNumbers(13, 13);
|
my $json_hash = decodeJson( "AudioLibrary.GetSongs.json" );
|
||||||
|
my $result = getSongs($json_hash);
|
||||||
|
printSongTestNumbers(@{$result});
|
||||||
|
printArtistSongsTestNumbers(@{$result}, 232);
|
||||||
|
printAlbumSongsTestNumbers(@{$result}, 237);
|
||||||
|
|
||||||
|
print "\n\n";
|
||||||
printSongCornerCases();
|
printSongCornerCases();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue