Loading core/tests/BroadcastRadioTests/src/android/hardware/radio/RadioManagerTest.java +17 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; Loading Loading @@ -728,10 +729,10 @@ public final class RadioManagerTest { @Test public void equals_withFmBandConfigsOfDifferentAfSupportValues() { RadioManager.FmBandConfig fmBandConfigCompared = new RadioManager.FmBandConfig( new RadioManager.FmBandDescriptor(REGION, RadioManager.BAND_FM, FM_LOWER_LIMIT, FM_UPPER_LIMIT, FM_SPACING, STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, !AF_SUPPORTED, EA_SUPPORTED)); RadioManager.FmBandConfig.Builder builder = new RadioManager.FmBandConfig.Builder( createFmBandDescriptor()).setStereo(STEREO_SUPPORTED).setRds(RDS_SUPPORTED) .setTa(TA_SUPPORTED).setAf(!AF_SUPPORTED).setEa(EA_SUPPORTED); RadioManager.FmBandConfig fmBandConfigCompared = builder.build(); assertWithMessage("FM Band Config of different af support value") .that(FM_BAND_CONFIG).isNotEqualTo(fmBandConfigCompared); Loading Loading @@ -1299,6 +1300,18 @@ public final class RadioManagerTest { verify(mCloseHandleMock).close(); } @Test public void addAnnouncementListener_withListenerAddedBeforeAndCloseException_throws() throws Exception { createRadioManager(); Set<Integer> enableTypeSet = createAnnouncementTypeSet(EVENT_ANNOUNCEMENT_TYPE); mRadioManager.addAnnouncementListener(enableTypeSet, mEventListener); doThrow(new RemoteException()).when(mCloseHandleMock).close(); assertThrows(RuntimeException.class, () -> mRadioManager.addAnnouncementListener(enableTypeSet, mEventListener)); } @Test public void addAnnouncementListener_whenServiceDied_throwException() throws Exception { createRadioManager(); Loading core/tests/BroadcastRadioTests/src/android/hardware/radio/TunerAdapterTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,16 @@ public final class TunerAdapterTest { verify(mTunerMock).close(); } @Test public void close_forTunerAdapterCalledTwice() throws Exception { mRadioTuner.close(); verify(mTunerMock).close(); mRadioTuner.close(); verify(mTunerMock).close(); } @Test public void setConfiguration_forTunerAdapter() throws Exception { int status = mRadioTuner.setConfiguration(TEST_BAND_CONFIG); Loading @@ -133,6 +143,12 @@ public final class TunerAdapterTest { .that(status).isEqualTo(RadioManager.STATUS_OK); } @Test public void setConfiguration_withNull_fails() throws Exception { assertWithMessage("Status for setting configuration with null") .that(mRadioTuner.setConfiguration(null)).isEqualTo(RadioManager.STATUS_BAD_VALUE); } @Test public void setConfiguration_withInvalidParameters_fails() throws Exception { doThrow(new IllegalArgumentException()).when(mTunerMock).setConfiguration(any()); Loading Loading @@ -839,6 +855,15 @@ public final class TunerAdapterTest { verify(mCallbackMock, timeout(CALLBACK_TIMEOUT_MS)).onError(RadioTuner.ERROR_CANCELLED); } @Test public void onTuneFailed_withDeadService() throws Exception { mTunerCallback.onTuneFailed(RadioManager.STATUS_DEAD_OBJECT, FM_SELECTOR); verify(mCallbackMock, timeout(CALLBACK_TIMEOUT_MS)).onTuneFailed( RadioManager.STATUS_DEAD_OBJECT, FM_SELECTOR); verify(mCallbackMock, timeout(CALLBACK_TIMEOUT_MS)).onError(RadioTuner.ERROR_SERVER_DIED); } @Test public void onProgramListChanged_forTunerCallbackAdapter() throws Exception { mTunerCallback.onProgramListChanged(); Loading Loading
core/tests/BroadcastRadioTests/src/android/hardware/radio/RadioManagerTest.java +17 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; Loading Loading @@ -728,10 +729,10 @@ public final class RadioManagerTest { @Test public void equals_withFmBandConfigsOfDifferentAfSupportValues() { RadioManager.FmBandConfig fmBandConfigCompared = new RadioManager.FmBandConfig( new RadioManager.FmBandDescriptor(REGION, RadioManager.BAND_FM, FM_LOWER_LIMIT, FM_UPPER_LIMIT, FM_SPACING, STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, !AF_SUPPORTED, EA_SUPPORTED)); RadioManager.FmBandConfig.Builder builder = new RadioManager.FmBandConfig.Builder( createFmBandDescriptor()).setStereo(STEREO_SUPPORTED).setRds(RDS_SUPPORTED) .setTa(TA_SUPPORTED).setAf(!AF_SUPPORTED).setEa(EA_SUPPORTED); RadioManager.FmBandConfig fmBandConfigCompared = builder.build(); assertWithMessage("FM Band Config of different af support value") .that(FM_BAND_CONFIG).isNotEqualTo(fmBandConfigCompared); Loading Loading @@ -1299,6 +1300,18 @@ public final class RadioManagerTest { verify(mCloseHandleMock).close(); } @Test public void addAnnouncementListener_withListenerAddedBeforeAndCloseException_throws() throws Exception { createRadioManager(); Set<Integer> enableTypeSet = createAnnouncementTypeSet(EVENT_ANNOUNCEMENT_TYPE); mRadioManager.addAnnouncementListener(enableTypeSet, mEventListener); doThrow(new RemoteException()).when(mCloseHandleMock).close(); assertThrows(RuntimeException.class, () -> mRadioManager.addAnnouncementListener(enableTypeSet, mEventListener)); } @Test public void addAnnouncementListener_whenServiceDied_throwException() throws Exception { createRadioManager(); Loading
core/tests/BroadcastRadioTests/src/android/hardware/radio/TunerAdapterTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,16 @@ public final class TunerAdapterTest { verify(mTunerMock).close(); } @Test public void close_forTunerAdapterCalledTwice() throws Exception { mRadioTuner.close(); verify(mTunerMock).close(); mRadioTuner.close(); verify(mTunerMock).close(); } @Test public void setConfiguration_forTunerAdapter() throws Exception { int status = mRadioTuner.setConfiguration(TEST_BAND_CONFIG); Loading @@ -133,6 +143,12 @@ public final class TunerAdapterTest { .that(status).isEqualTo(RadioManager.STATUS_OK); } @Test public void setConfiguration_withNull_fails() throws Exception { assertWithMessage("Status for setting configuration with null") .that(mRadioTuner.setConfiguration(null)).isEqualTo(RadioManager.STATUS_BAD_VALUE); } @Test public void setConfiguration_withInvalidParameters_fails() throws Exception { doThrow(new IllegalArgumentException()).when(mTunerMock).setConfiguration(any()); Loading Loading @@ -839,6 +855,15 @@ public final class TunerAdapterTest { verify(mCallbackMock, timeout(CALLBACK_TIMEOUT_MS)).onError(RadioTuner.ERROR_CANCELLED); } @Test public void onTuneFailed_withDeadService() throws Exception { mTunerCallback.onTuneFailed(RadioManager.STATUS_DEAD_OBJECT, FM_SELECTOR); verify(mCallbackMock, timeout(CALLBACK_TIMEOUT_MS)).onTuneFailed( RadioManager.STATUS_DEAD_OBJECT, FM_SELECTOR); verify(mCallbackMock, timeout(CALLBACK_TIMEOUT_MS)).onError(RadioTuner.ERROR_SERVER_DIED); } @Test public void onProgramListChanged_forTunerCallbackAdapter() throws Exception { mTunerCallback.onProgramListChanged(); Loading