use of android.media.AudioAttributes in project robolectric by robolectric.
the class ShadowAudioManager method createAudioPlaybackConfiguration.
protected AudioPlaybackConfiguration createAudioPlaybackConfiguration(AudioAttributes audioAttributes) {
// use reflection to call package private APIs
if (RuntimeEnvironment.getApiLevel() >= S) {
PlayerBase.PlayerIdCard playerIdCard = ReflectionHelpers.callConstructor(PlayerBase.PlayerIdCard.class, ReflectionHelpers.ClassParameter.from(int.class, 0), /* type */
ReflectionHelpers.ClassParameter.from(AudioAttributes.class, audioAttributes), ReflectionHelpers.ClassParameter.from(IPlayer.class, null), ReflectionHelpers.ClassParameter.from(int.class, 0));
AudioPlaybackConfiguration config = ReflectionHelpers.callConstructor(AudioPlaybackConfiguration.class, ReflectionHelpers.ClassParameter.from(PlayerBase.PlayerIdCard.class, playerIdCard), ReflectionHelpers.ClassParameter.from(int.class, 0), /* piid */
ReflectionHelpers.ClassParameter.from(int.class, 0), /* uid */
ReflectionHelpers.ClassParameter.from(int.class, 0));
ReflectionHelpers.setField(config, "mPlayerState", AudioPlaybackConfiguration.PLAYER_STATE_STARTED);
return config;
} else {
PlayerBase.PlayerIdCard playerIdCard = ReflectionHelpers.callConstructor(PlayerBase.PlayerIdCard.class, from(int.class, 0), /* type */
from(AudioAttributes.class, audioAttributes), from(IPlayer.class, null));
AudioPlaybackConfiguration config = ReflectionHelpers.callConstructor(AudioPlaybackConfiguration.class, from(PlayerBase.PlayerIdCard.class, playerIdCard), from(int.class, 0), /* piid */
from(int.class, 0), /* uid */
from(int.class, 0));
ReflectionHelpers.setField(config, "mPlayerState", AudioPlaybackConfiguration.PLAYER_STATE_STARTED);
return config;
}
}
use of android.media.AudioAttributes in project robolectric by robolectric.
the class ShadowAudioManagerTest method getDevicesForAttributes_returnsEmptyListByDefault.
@Test
@Config(minSdk = R)
public void getDevicesForAttributes_returnsEmptyListByDefault() {
AudioAttributes movieAttribute = new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_MOVIE).build();
assertThat(shadowOf(audioManager).getDevicesForAttributes(movieAttribute)).isEmpty();
}
use of android.media.AudioAttributes in project robolectric by robolectric.
the class ShadowAudioManagerTest method setDevicesForAttributes_overridesSetDefaultDevicesForAttributes.
@Test
@Config(minSdk = R)
public void setDevicesForAttributes_overridesSetDefaultDevicesForAttributes() {
AudioAttributes movieAttribute = new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_MOVIE).build();
shadowOf(audioManager).setDefaultDevicesForAttributes(ImmutableList.of(new Object()));
ImmutableList<Object> newDevices = ImmutableList.of(new Object(), new Object());
shadowOf(audioManager).setDevicesForAttributes(movieAttribute, newDevices);
assertThat(shadowOf(audioManager).getDevicesForAttributes(movieAttribute)).isEqualTo(newDevices);
}
use of android.media.AudioAttributes in project robolectric by robolectric.
the class ShadowAudioManagerTest method setDevicesForAttributes_updatesDevicesForAttributes.
@Test
@Config(minSdk = R)
public void setDevicesForAttributes_updatesDevicesForAttributes() {
AudioAttributes movieAttribute = new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_MOVIE).build();
ImmutableList<Object> newDevices = ImmutableList.of(new Object());
shadowOf(audioManager).setDevicesForAttributes(movieAttribute, newDevices);
assertThat(shadowOf(audioManager).getDevicesForAttributes(movieAttribute)).isEqualTo(newDevices);
}
use of android.media.AudioAttributes in project robolectric by robolectric.
the class ShadowAudioManagerTest method setDefaultDevicesForAttributes_updatesDevicesForAttributes.
@Test
@Config(minSdk = R)
public void setDefaultDevicesForAttributes_updatesDevicesForAttributes() {
AudioAttributes movieAttribute = new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_MOVIE).build();
ImmutableList<Object> newDevices = ImmutableList.of(new Object());
shadowOf(audioManager).setDefaultDevicesForAttributes(newDevices);
assertThat(shadowOf(audioManager).getDevicesForAttributes(movieAttribute)).isEqualTo(newDevices);
}
Aggregations