[Audiosharing] Add logging 2.

Test: atest -c com.android.settings.connecteddevice.audiosharing.audiostreams
Bug: 308368124
Change-Id: I50fc57427aa135a13566c4627ba193aed9d73e0d
This commit is contained in:
chelseahao
2024-06-12 14:23:38 +08:00
committed by Chelsea Hao
parent f017332c91
commit a3b1638c4b
14 changed files with 261 additions and 103 deletions

View File

@@ -92,6 +92,8 @@ public class AddSourceWaitForResponseStateTest {
@Test
public void testPerformAction_metadataIsNotNull_addSource() {
when(mMockPreference.getAudioStreamMetadata()).thenReturn(mMockMetadata);
when(mMockPreference.getSourceOriginForLogging())
.thenReturn(SourceOriginForLogging.UNKNOWN);
mInstance.performAction(mMockPreference, mMockController, mMockHelper);
@@ -105,6 +107,8 @@ public class AddSourceWaitForResponseStateTest {
when(mMockPreference.isShown()).thenReturn(true);
when(mMockPreference.getAudioStreamState()).thenReturn(mInstance.getStateEnum());
when(mMockPreference.getAudioStreamBroadcastId()).thenReturn(BROADCAST_ID);
when(mMockPreference.getSourceOriginForLogging())
.thenReturn(SourceOriginForLogging.UNKNOWN);
mInstance.performAction(mMockPreference, mMockController, mMockHelper);
ShadowLooper.idleMainLooper(ADD_SOURCE_WAIT_FOR_RESPONSE_TIMEOUT_MILLIS, TimeUnit.SECONDS);

View File

@@ -107,7 +107,8 @@ public class AudioStreamPreferenceTest {
@Test
public void setAudioStreamMetadata_shouldUpdateMetadata() {
AudioStreamPreference p =
AudioStreamPreference.fromMetadata(mContext, mBluetoothLeBroadcastMetadata);
AudioStreamPreference.fromMetadata(
mContext, mBluetoothLeBroadcastMetadata, SourceOriginForLogging.UNKNOWN);
BluetoothLeBroadcastMetadata metadata = mock(BluetoothLeBroadcastMetadata.class);
p.setAudioStreamMetadata(metadata);
@@ -117,7 +118,8 @@ public class AudioStreamPreferenceTest {
@Test
public void setAudioStreamState_shouldUpdateState() {
AudioStreamPreference p =
AudioStreamPreference.fromMetadata(mContext, mBluetoothLeBroadcastMetadata);
AudioStreamPreference.fromMetadata(
mContext, mBluetoothLeBroadcastMetadata, SourceOriginForLogging.UNKNOWN);
AudioStreamState state = AudioStreamState.SOURCE_ADDED;
p.setAudioStreamState(state);
@@ -127,7 +129,8 @@ public class AudioStreamPreferenceTest {
@Test
public void fromMetadata_shouldReturnBroadcastInfo() {
AudioStreamPreference p =
AudioStreamPreference.fromMetadata(mContext, mBluetoothLeBroadcastMetadata);
AudioStreamPreference.fromMetadata(
mContext, mBluetoothLeBroadcastMetadata, SourceOriginForLogging.UNKNOWN);
assertThat(p.getAudioStreamBroadcastId()).isEqualTo(BROADCAST_ID);
assertThat(p.getAudioStreamBroadcastName()).isEqualTo(BROADCAST_NAME);
assertThat(p.getAudioStreamRssi()).isEqualTo(BROADCAST_RSSI);
@@ -152,7 +155,8 @@ public class AudioStreamPreferenceTest {
public void shouldHideSecondTarget_notEncrypted() {
when(mBluetoothLeBroadcastMetadata.isEncrypted()).thenReturn(false);
AudioStreamPreference p =
AudioStreamPreference.fromMetadata(mContext, mBluetoothLeBroadcastMetadata);
AudioStreamPreference.fromMetadata(
mContext, mBluetoothLeBroadcastMetadata, SourceOriginForLogging.UNKNOWN);
assertThat(p.shouldHideSecondTarget()).isTrue();
}
@@ -160,7 +164,8 @@ public class AudioStreamPreferenceTest {
public void shouldShowSecondTarget_encrypted() {
when(mBluetoothLeBroadcastMetadata.isEncrypted()).thenReturn(true);
AudioStreamPreference p =
AudioStreamPreference.fromMetadata(mContext, mBluetoothLeBroadcastMetadata);
AudioStreamPreference.fromMetadata(
mContext, mBluetoothLeBroadcastMetadata, SourceOriginForLogging.UNKNOWN);
assertThat(p.shouldHideSecondTarget()).isFalse();
}

View File

@@ -93,6 +93,8 @@ public class WaitForSyncStateTest {
.thenReturn(AudioStreamsProgressCategoryController.AudioStreamState.WAIT_FOR_SYNC);
when(mMockPreference.getAudioStreamBroadcastId()).thenReturn(1);
when(mMockPreference.getAudioStreamMetadata()).thenReturn(mMockMetadata);
when(mMockPreference.getSourceOriginForLogging())
.thenReturn(SourceOriginForLogging.UNKNOWN);
mInstance.performAction(mMockPreference, mMockController, mMockHelper);
ShadowLooper.idleMainLooper(WAIT_FOR_SYNC_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);