public void testIfAudioFocusGetsAbandonedOnAudioFocusLossEvent() { audioFocus.requestAudioFocus(); assertTrue( "AudioFocus is not held, although it was requested", audioFocus.isAudioFocusGranted()); audioFocus.onAudioFocusChange(AudioManager.AUDIOFOCUS_LOSS); assertFalse( "AudioFocus should be abandoned after focus is lost", audioFocus.isAudioFocusGranted()); }
public void testRequestAndReleaseAudioFocus() { assertFalse("AudioFocus is held before requesting it", audioFocus.isAudioFocusGranted()); audioFocus.requestAudioFocus(); assertTrue( "AudioFocus is not held, although it was requested", audioFocus.isAudioFocusGranted()); audioFocus.releaseAudioFocus(); assertFalse( "Audio Focus is still held, although it is released", audioFocus.isAudioFocusGranted()); }