예제 #1
0
  @Test
  public void queryAllSongsTest() {
    Uri uri = MediaContract.Songs.buildSongsListUri(hostInfo.getId());

    Cursor cursor = contentResolver.query(uri, TestValues.ArtistSong.PROJECTION, null, null, null);

    assertNotNull(cursor);
    assertEquals("cursor size ", 1804, cursor.getCount());
    TestUtils.testCursorContainsRange(
        cursor, cursor.getColumnIndex(MediaContract.Songs.SONGID), 1, 1804);

    // Test if list also contains a song WITH an album AND an artist
    assertTrue(
        Utils.moveCursorTo(
            cursor,
            cursor.getColumnIndex(MediaContract.Songs.SONGID),
            TestValues.SongWithAlbumAndArtist.songId));
    TestValues.SongWithAlbumAndArtist.test(cursor);

    // Test if list also contains a song WITHOUT an album but WITH an artist
    assertTrue(
        Utils.moveCursorTo(
            cursor,
            cursor.getColumnIndex(MediaContract.Songs.SONGID),
            TestValues.SongWithArtistWithoutAlbum.songId));
    TestValues.SongWithArtistWithoutAlbum.test(cursor);

    // Test if list also contains a song WITH an album but WITHOUT an artist
    assertTrue(
        Utils.moveCursorTo(
            cursor,
            cursor.getColumnIndex(MediaContract.Songs.SONGID),
            TestValues.SongWithAlbumWithoutArtist.songId));
    TestValues.SongWithAlbumWithoutArtist.test(cursor);

    // Test if list contains a song WITH MULTIPLE artists
    assertTrue(
        Utils.moveCursorTo(
            cursor,
            cursor.getColumnIndex(MediaContract.Songs.SONGID),
            TestValues.SongWithMultipleArtists.songId));
    TestValues.SongWithMultipleArtists.test(cursor);
  }
예제 #2
0
  @Test
  public void queryArtistSongsTest() {
    Uri uri =
        MediaContract.Songs.buildArtistSongsListUri(
            hostInfo.getId(), TestValues.ArtistSong.artistId);

    Cursor cursor = contentResolver.query(uri, TestValues.ArtistSong.PROJECTION, null, null, null);

    assertNotNull(cursor);
    assertEquals("cursor size ", 17, cursor.getCount());
    TestUtils.testCursorContainsRange(
        cursor, cursor.getColumnIndex(MediaContract.SongsColumns.SONGID), 96, 112);
    assertTrue(
        Utils.moveCursorTo(
            cursor,
            cursor.getColumnIndex(MediaContract.Songs.SONGID),
            TestValues.ArtistSong.songId));
  }