Пример #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 queryAlbumWithMultipleArtistsTest() {
    Uri uri =
        MediaContract.Albums.buildAlbumUri(
            hostInfo.getId(), TestValues.AlbumWithMultipleArtists.albumId);

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

    assertNotNull(cursor);
    assertEquals("cursor size ", 1, cursor.getCount());
    assertTrue(cursor.moveToFirst());
    LogUtils.LOGD("MediaProviderMusicTest", Utils.cursorToString(cursor));
    TestValues.AlbumWithMultipleArtists.test(cursor);
  }
Пример #3
0
  @Test
  public void querySongWithArtistWithoutAlbumTest() {
    Uri uri =
        MediaContract.Songs.buildArtistSongsListUri(
            hostInfo.getId(), TestValues.SongWithArtistWithoutAlbum.artistId);

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

    assertNotNull(cursor);
    assertEquals("cursor size ", 1, cursor.getCount());
    assertTrue(cursor.moveToFirst());
    Utils.cursorToString(cursor);
    TestValues.SongWithArtistWithoutAlbum.test(cursor);
  }
Пример #4
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));
  }