AudioPlayerViewModel extends ViewModel implements MediaPlayer.OnCompletionListener { public LiveData<Boolean> isPlaying(@NonNull String clipID) { return Transformations.map(currentlyPlaying, value -> { if (isCurrentPlayingClip(clipID, value)) { return !value.isPaused(); } else { return false; } }); } AudioPlayerViewModel(MediaPlayerFactory mediaPlayerFactory, Scheduler scheduler); void play(Clip clip); void playInOrder(List<Clip> clips); void stop(); void pause(); LiveData<Boolean> isPlaying(@NonNull String clipID); LiveData<Integer> getPosition(String clipID); void setPosition(String clipID, Integer newPosition); void background(); @Override void onCompletion(MediaPlayer mediaPlayer); LiveData<Exception> getError(); void dismissError();  }
@Test public void isPlaying_whenNothingPlaying_is_false() { LiveData<Boolean> isPlaying = liveDataTester.activate(viewModel.isPlaying("clip1")); assertThat(isPlaying.getValue(), equalTo(false)); }