Loading core/tests/BroadcastRadioTests/src/android/hardware/radio/ProgramSelectorTest.java +45 −9 Original line number Diff line number Diff line Loading @@ -123,6 +123,17 @@ public final class ProgramSelectorTest { .that(identifierFromParcel).isEqualTo(FM_IDENTIFIER); } @Test public void construct_withNullInSecondaryIdsForSelector() { IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> { new ProgramSelector(DAB_PROGRAM_TYPE, DAB_DMB_SID_EXT_IDENTIFIER_1, new ProgramSelector.Identifier[]{null}, /* vendorIds= */ null); }); assertWithMessage("Exception for null secondary id") .that(thrown).hasMessageThat().contains("secondaryIds list must not contain nulls"); } @Test public void getProgramType() { ProgramSelector selector = getFmSelector(/* secondaryIds= */ null, /* vendorIds= */ null); Loading Loading @@ -269,11 +280,11 @@ public final class ProgramSelectorTest { ProgramSelector selector = ProgramSelector.createAmFmSelector(band, (int) AM_FREQUENCY); assertWithMessage("Program type") assertWithMessage("AM program type without subchannel") .that(selector.getProgramType()).isEqualTo(ProgramSelector.PROGRAM_TYPE_AM); assertWithMessage("Primary identifiers") assertWithMessage("AM primary identifiers without subchannel") .that(selector.getPrimaryId()).isEqualTo(primaryIdExpected); assertWithMessage("Secondary identifiers") assertWithMessage("AM secondary identifiers without subchannel") .that(selector.getSecondaryIds()).isEmpty(); } Loading @@ -285,14 +296,28 @@ public final class ProgramSelectorTest { ProgramSelector selector = ProgramSelector.createAmFmSelector( RadioManager.BAND_INVALID, (int) FM_FREQUENCY); assertWithMessage("Program type") assertWithMessage("FM program type without band and subchannel") .that(selector.getProgramType()).isEqualTo(ProgramSelector.PROGRAM_TYPE_FM); assertWithMessage("Primary identifiers") assertWithMessage("FM primary identifiers without band and subchannel") .that(selector.getPrimaryId()).isEqualTo(primaryIdExpected); assertWithMessage("Secondary identifiers") assertWithMessage("FM secondary identifiers without band and subchannel") .that(selector.getSecondaryIds()).isEmpty(); } @Test public void createAmFmSelector_withValidFrequency() { ProgramSelector.Identifier primaryIdExpected = new ProgramSelector.Identifier( ProgramSelector.IDENTIFIER_TYPE_AMFM_FREQUENCY, AM_FREQUENCY); ProgramSelector selector = ProgramSelector.createAmFmSelector(RadioManager.BAND_INVALID, (int) AM_FREQUENCY); assertWithMessage("AM program type with valid frequency") .that(selector.getProgramType()).isEqualTo(ProgramSelector.PROGRAM_TYPE_AM); assertWithMessage("AM primary identifiers with valid frequency") .that(selector.getPrimaryId()).isEqualTo(primaryIdExpected); } @Test public void createAmFmSelector_withValidFrequencyAndSubChannel() { int band = RadioManager.BAND_AM_HD; Loading @@ -307,14 +332,25 @@ public final class ProgramSelectorTest { ProgramSelector selector = ProgramSelector.createAmFmSelector(band, (int) AM_FREQUENCY, subChannel); assertWithMessage("Program type") assertWithMessage("AM program type with valid frequency and subchannel") .that(selector.getProgramType()).isEqualTo(ProgramSelector.PROGRAM_TYPE_AM); assertWithMessage("Primary identifiers") assertWithMessage("AM primary identifiers with valid frequency and subchannel") .that(selector.getPrimaryId()).isEqualTo(primaryIdExpected); assertWithMessage("Secondary identifiers") assertWithMessage("AM secondary identifiers with valid frequency and subchannel") .that(selector.getSecondaryIds()).isEqualTo(secondaryIdExpected); } @Test public void createAmFmSelector_withInvalidBand_throwsIllegalArgumentException() { IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> { ProgramSelector.createAmFmSelector(/* band= */ 1000, (int) AM_FREQUENCY); }); assertWithMessage("Exception for using invalid band") .that(thrown).hasMessageThat().contains( "Unknown band"); } @Test public void createAmFmSelector_withInvalidFrequency_throwsIllegalArgumentException() { int invalidFrequency = 50000; Loading core/tests/BroadcastRadioTests/src/android/hardware/radio/RadioManagerTest.java +168 −11 Original line number Diff line number Diff line Loading @@ -168,6 +168,16 @@ public final class RadioManagerTest { @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Test public void constructor_withUnsupportedTypeForBandDescriptor_throwsException() { IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> new RadioManager.AmBandDescriptor(REGION, /* type= */ 100, AM_LOWER_LIMIT, AM_UPPER_LIMIT, AM_SPACING, STEREO_SUPPORTED)); assertWithMessage("Unsupported band type exception") .that(thrown).hasMessageThat().contains("Unsupported band"); } @Test public void getType_forBandDescriptor() { RadioManager.BandDescriptor bandDescriptor = createAmBandDescriptor(); Loading Loading @@ -362,6 +372,18 @@ public final class RadioManagerTest { .that(AM_BAND_DESCRIPTOR).isEqualTo(amBandDescriptorCompared); } @Test public void equals_withAmBandDescriptorsAndOtherTypeObject() { assertWithMessage("AM Band Descriptor") .that(AM_BAND_DESCRIPTOR).isNotEqualTo(FM_BAND_DESCRIPTOR); } @Test public void equals_withFmBandDescriptorsAndOtherTypeObject() { assertWithMessage("FM Band Descriptor") .that(FM_BAND_DESCRIPTOR).isNotEqualTo(AM_BAND_DESCRIPTOR); } @Test public void equals_withAmBandDescriptorsOfDifferentUpperLimits_returnsFalse() { RadioManager.AmBandDescriptor amBandDescriptorCompared = Loading @@ -373,9 +395,83 @@ public final class RadioManagerTest { } @Test public void equals_withAmAndFmBandDescriptors_returnsFalse() { assertWithMessage("AM Band Descriptor") .that(AM_BAND_DESCRIPTOR).isNotEqualTo(FM_BAND_DESCRIPTOR); public void equals_withAmBandDescriptorsOfDifferentStereoSupportValues() { RadioManager.AmBandDescriptor amBandDescriptorCompared = new RadioManager.AmBandDescriptor(REGION, RadioManager.BAND_AM, AM_LOWER_LIMIT, AM_UPPER_LIMIT, AM_SPACING, !STEREO_SUPPORTED); assertWithMessage("AM Band Descriptor of different stereo support values") .that(AM_BAND_DESCRIPTOR).isNotEqualTo(amBandDescriptorCompared); } @Test public void equals_withFmBandDescriptorsOfDifferentSpacingValues() { RadioManager.FmBandDescriptor fmBandDescriptorCompared = new RadioManager.FmBandDescriptor( REGION, RadioManager.BAND_FM, FM_LOWER_LIMIT, FM_UPPER_LIMIT, FM_SPACING * 2, STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, AF_SUPPORTED, EA_SUPPORTED); assertWithMessage("FM Band Descriptors of different support limit values") .that(FM_BAND_DESCRIPTOR).isNotEqualTo(fmBandDescriptorCompared); } @Test public void equals_withFmBandConfigsOfDifferentLowerLimitValues() { RadioManager.FmBandDescriptor fmBandDescriptorCompared = new RadioManager.FmBandDescriptor( REGION + 1, RadioManager.BAND_AM_HD, AM_LOWER_LIMIT, AM_UPPER_LIMIT, AM_SPACING, STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, AF_SUPPORTED, EA_SUPPORTED); assertWithMessage("FM Band Descriptors of different region values") .that(FM_BAND_DESCRIPTOR).isNotEqualTo(fmBandDescriptorCompared); } @Test public void equals_withFmBandDescriptorsOfDifferentStereoSupportValues() { RadioManager.FmBandDescriptor fmBandDescriptorCompared = 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); assertWithMessage("FM Band Descriptors of different stereo support values") .that(fmBandDescriptorCompared).isNotEqualTo(FM_BAND_DESCRIPTOR); } @Test public void equals_withFmBandDescriptorsOfDifferentRdsSupportValues() { RadioManager.FmBandDescriptor fmBandDescriptorCompared = 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); assertWithMessage("FM Band Descriptors of different rds support values") .that(fmBandDescriptorCompared).isNotEqualTo(FM_BAND_DESCRIPTOR); } @Test public void equals_withFmBandDescriptorsOfDifferentTaSupportValues() { RadioManager.FmBandDescriptor fmBandDescriptorCompared = 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); assertWithMessage("FM Band Descriptors of different ta support values") .that(fmBandDescriptorCompared).isNotEqualTo(FM_BAND_DESCRIPTOR); } @Test public void equals_withFmBandDescriptorsOfDifferentAfSupportValues() { RadioManager.FmBandDescriptor fmBandDescriptorCompared = 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); assertWithMessage("FM Band Descriptors of different af support values") .that(fmBandDescriptorCompared).isNotEqualTo(FM_BAND_DESCRIPTOR); } @Test public void equals_withFmBandDescriptorsOfDifferentEaSupportValues() { RadioManager.FmBandDescriptor fmBandDescriptorCompared = 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); assertWithMessage("FM Band Descriptors of different ea support values") .that(fmBandDescriptorCompared).isNotEqualTo(FM_BAND_DESCRIPTOR); } @Test Loading Loading @@ -587,18 +683,79 @@ public final class RadioManagerTest { } @Test public void equals_withFmBandConfigsOfDifferentAfs_returnsFalse() { 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 fmBandConfigFromBuilder = builder.build(); public void equals_withFmBandConfigsOfDifferentRegionValues() { RadioManager.FmBandConfig fmBandConfigCompared = new RadioManager.FmBandConfig( new RadioManager.FmBandDescriptor(REGION + 1, RadioManager.BAND_AM_HD, AM_LOWER_LIMIT, AM_UPPER_LIMIT, AM_SPACING, STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, AF_SUPPORTED, EA_SUPPORTED)); assertWithMessage("FM Band Config of different regions") .that(FM_BAND_CONFIG).isNotEqualTo(fmBandConfigCompared); } @Test public void equals_withFmBandConfigsOfDifferentStereoSupportValues() { 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)); assertWithMessage("FM Band Config with different stereo support values") .that(fmBandConfigCompared).isNotEqualTo(FM_BAND_CONFIG); } assertWithMessage("FM Band Config of different af value") .that(FM_BAND_CONFIG).isNotEqualTo(fmBandConfigFromBuilder); @Test public void equals_withFmBandConfigsOfDifferentRdsSupportValues() { 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)); assertWithMessage("FM Band Config with different RDS support values") .that(fmBandConfigCompared).isNotEqualTo(FM_BAND_CONFIG); } @Test public void equals_withFmBandConfigsOfDifferentTaSupportValues() { 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)); assertWithMessage("FM Band Configs with different ta values") .that(fmBandConfigCompared).isNotEqualTo(FM_BAND_CONFIG); } @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)); assertWithMessage("FM Band Config of different af support value") .that(FM_BAND_CONFIG).isNotEqualTo(fmBandConfigCompared); } @Test public void equals_withFmBandConfigsOfDifferentEaSupportValues() { 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)); assertWithMessage("FM Band Configs with different ea support values") .that(fmBandConfigCompared).isNotEqualTo(FM_BAND_CONFIG); } @Test public void equals_withAmBandConfigsAndOtherTypeObject() { assertWithMessage("AM Band Config") .that(AM_BAND_CONFIG).isNotEqualTo(FM_BAND_CONFIG); } @Test public void equals_withFmAndAmBandConfigs_returnsFalse() { public void equals_withFmBandConfigsAndOtherTypeObject() { assertWithMessage("FM Band Config") .that(FM_BAND_CONFIG).isNotEqualTo(AM_BAND_CONFIG); } Loading core/tests/BroadcastRadioTests/src/android/hardware/radio/RadioMetadataTest.java +132 −39 File changed.Preview size limit exceeded, changes collapsed. Show changes core/tests/BroadcastRadioTests/src/android/hardware/radio/UniqueProgramIdentifierTest.java +54 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.hardware.radio; import static org.junit.Assert.assertThrows; import android.annotation.Nullable; import android.os.Parcel; Loading Loading @@ -44,6 +46,24 @@ public final class UniqueProgramIdentifierTest { @Rule public final Expect expect = Expect.create(); @Test public void requireCriticalSecondaryIds_forDab() { expect.withMessage("Critical secondary Id required for DAB") .that(UniqueProgramIdentifier.requireCriticalSecondaryIds( ProgramSelector.IDENTIFIER_TYPE_DAB_SID_EXT)).isTrue(); } @Test public void constructor_withNullSelector() { ProgramSelector nullSelector = null; NullPointerException thrown = assertThrows(NullPointerException.class, () -> new UniqueProgramIdentifier(nullSelector)); expect.withMessage("Null pointer exception for unique program identifier") .that(thrown).hasMessageThat().contains("can not be null"); } @Test public void getPrimaryId_forUniqueProgramIdentifier() { ProgramSelector dabSelector = getDabSelector(new ProgramSelector.Identifier[]{ Loading @@ -66,6 +86,27 @@ public final class UniqueProgramIdentifierTest { DAB_ENSEMBLE_IDENTIFIER, DAB_FREQUENCY_IDENTIFIER); } @Test public void getCriticalSecondaryIds_forDabUniqueProgramIdentifierWithoutEnsemble() { ProgramSelector dabSelector = getDabSelector(new ProgramSelector.Identifier[]{ DAB_FREQUENCY_IDENTIFIER}, /* vendorIds= */ null); UniqueProgramIdentifier dabIdentifier = new UniqueProgramIdentifier(dabSelector); expect.withMessage("Critical secondary ids of DAB unique identifier without ensemble") .that(dabIdentifier.getCriticalSecondaryIds()) .containsExactly(DAB_FREQUENCY_IDENTIFIER); } @Test public void getCriticalSecondaryIds_forDabUniqueProgramIdentifierWithoutSecondaryIds() { ProgramSelector dabSelector = getDabSelector(new ProgramSelector.Identifier[]{}, /* vendorIds= */ null); UniqueProgramIdentifier dabIdentifier = new UniqueProgramIdentifier(dabSelector); expect.withMessage("Critical secondary ids of DAB unique identifier") .that(dabIdentifier.getCriticalSecondaryIds()).isEmpty(); } @Test public void getCriticalSecondaryIds_forFmUniqueProgramIdentifier() { UniqueProgramIdentifier fmUniqueIdentifier = new UniqueProgramIdentifier( Loading Loading @@ -146,6 +187,19 @@ public final class UniqueProgramIdentifierTest { .that(dabIdentifier1).isNotEqualTo(dabIdentifier2); } @Test public void equals_withMissingSecondaryIdsForUniqueProgramIdentifier() { ProgramSelector dabSelector1 = getDabSelector(new ProgramSelector.Identifier[]{ DAB_ENSEMBLE_IDENTIFIER}, /* vendorIds= */ null); UniqueProgramIdentifier dabIdentifier1 = new UniqueProgramIdentifier(dabSelector1); ProgramSelector dabSelector2 = getDabSelector(new ProgramSelector.Identifier[]{ DAB_ENSEMBLE_IDENTIFIER, DAB_FREQUENCY_IDENTIFIER}, /* vendorIds= */ null); UniqueProgramIdentifier dabIdentifier2 = new UniqueProgramIdentifier(dabSelector2); expect.withMessage("DAB unique identifier with missing secondary ids") .that(dabIdentifier1).isNotEqualTo(dabIdentifier2); } @Test public void describeContents_forUniqueProgramIdentifier() { UniqueProgramIdentifier fmUniqueIdentifier = new UniqueProgramIdentifier(FM_IDENTIFIER); Loading Loading
core/tests/BroadcastRadioTests/src/android/hardware/radio/ProgramSelectorTest.java +45 −9 Original line number Diff line number Diff line Loading @@ -123,6 +123,17 @@ public final class ProgramSelectorTest { .that(identifierFromParcel).isEqualTo(FM_IDENTIFIER); } @Test public void construct_withNullInSecondaryIdsForSelector() { IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> { new ProgramSelector(DAB_PROGRAM_TYPE, DAB_DMB_SID_EXT_IDENTIFIER_1, new ProgramSelector.Identifier[]{null}, /* vendorIds= */ null); }); assertWithMessage("Exception for null secondary id") .that(thrown).hasMessageThat().contains("secondaryIds list must not contain nulls"); } @Test public void getProgramType() { ProgramSelector selector = getFmSelector(/* secondaryIds= */ null, /* vendorIds= */ null); Loading Loading @@ -269,11 +280,11 @@ public final class ProgramSelectorTest { ProgramSelector selector = ProgramSelector.createAmFmSelector(band, (int) AM_FREQUENCY); assertWithMessage("Program type") assertWithMessage("AM program type without subchannel") .that(selector.getProgramType()).isEqualTo(ProgramSelector.PROGRAM_TYPE_AM); assertWithMessage("Primary identifiers") assertWithMessage("AM primary identifiers without subchannel") .that(selector.getPrimaryId()).isEqualTo(primaryIdExpected); assertWithMessage("Secondary identifiers") assertWithMessage("AM secondary identifiers without subchannel") .that(selector.getSecondaryIds()).isEmpty(); } Loading @@ -285,14 +296,28 @@ public final class ProgramSelectorTest { ProgramSelector selector = ProgramSelector.createAmFmSelector( RadioManager.BAND_INVALID, (int) FM_FREQUENCY); assertWithMessage("Program type") assertWithMessage("FM program type without band and subchannel") .that(selector.getProgramType()).isEqualTo(ProgramSelector.PROGRAM_TYPE_FM); assertWithMessage("Primary identifiers") assertWithMessage("FM primary identifiers without band and subchannel") .that(selector.getPrimaryId()).isEqualTo(primaryIdExpected); assertWithMessage("Secondary identifiers") assertWithMessage("FM secondary identifiers without band and subchannel") .that(selector.getSecondaryIds()).isEmpty(); } @Test public void createAmFmSelector_withValidFrequency() { ProgramSelector.Identifier primaryIdExpected = new ProgramSelector.Identifier( ProgramSelector.IDENTIFIER_TYPE_AMFM_FREQUENCY, AM_FREQUENCY); ProgramSelector selector = ProgramSelector.createAmFmSelector(RadioManager.BAND_INVALID, (int) AM_FREQUENCY); assertWithMessage("AM program type with valid frequency") .that(selector.getProgramType()).isEqualTo(ProgramSelector.PROGRAM_TYPE_AM); assertWithMessage("AM primary identifiers with valid frequency") .that(selector.getPrimaryId()).isEqualTo(primaryIdExpected); } @Test public void createAmFmSelector_withValidFrequencyAndSubChannel() { int band = RadioManager.BAND_AM_HD; Loading @@ -307,14 +332,25 @@ public final class ProgramSelectorTest { ProgramSelector selector = ProgramSelector.createAmFmSelector(band, (int) AM_FREQUENCY, subChannel); assertWithMessage("Program type") assertWithMessage("AM program type with valid frequency and subchannel") .that(selector.getProgramType()).isEqualTo(ProgramSelector.PROGRAM_TYPE_AM); assertWithMessage("Primary identifiers") assertWithMessage("AM primary identifiers with valid frequency and subchannel") .that(selector.getPrimaryId()).isEqualTo(primaryIdExpected); assertWithMessage("Secondary identifiers") assertWithMessage("AM secondary identifiers with valid frequency and subchannel") .that(selector.getSecondaryIds()).isEqualTo(secondaryIdExpected); } @Test public void createAmFmSelector_withInvalidBand_throwsIllegalArgumentException() { IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> { ProgramSelector.createAmFmSelector(/* band= */ 1000, (int) AM_FREQUENCY); }); assertWithMessage("Exception for using invalid band") .that(thrown).hasMessageThat().contains( "Unknown band"); } @Test public void createAmFmSelector_withInvalidFrequency_throwsIllegalArgumentException() { int invalidFrequency = 50000; Loading
core/tests/BroadcastRadioTests/src/android/hardware/radio/RadioManagerTest.java +168 −11 Original line number Diff line number Diff line Loading @@ -168,6 +168,16 @@ public final class RadioManagerTest { @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Test public void constructor_withUnsupportedTypeForBandDescriptor_throwsException() { IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> new RadioManager.AmBandDescriptor(REGION, /* type= */ 100, AM_LOWER_LIMIT, AM_UPPER_LIMIT, AM_SPACING, STEREO_SUPPORTED)); assertWithMessage("Unsupported band type exception") .that(thrown).hasMessageThat().contains("Unsupported band"); } @Test public void getType_forBandDescriptor() { RadioManager.BandDescriptor bandDescriptor = createAmBandDescriptor(); Loading Loading @@ -362,6 +372,18 @@ public final class RadioManagerTest { .that(AM_BAND_DESCRIPTOR).isEqualTo(amBandDescriptorCompared); } @Test public void equals_withAmBandDescriptorsAndOtherTypeObject() { assertWithMessage("AM Band Descriptor") .that(AM_BAND_DESCRIPTOR).isNotEqualTo(FM_BAND_DESCRIPTOR); } @Test public void equals_withFmBandDescriptorsAndOtherTypeObject() { assertWithMessage("FM Band Descriptor") .that(FM_BAND_DESCRIPTOR).isNotEqualTo(AM_BAND_DESCRIPTOR); } @Test public void equals_withAmBandDescriptorsOfDifferentUpperLimits_returnsFalse() { RadioManager.AmBandDescriptor amBandDescriptorCompared = Loading @@ -373,9 +395,83 @@ public final class RadioManagerTest { } @Test public void equals_withAmAndFmBandDescriptors_returnsFalse() { assertWithMessage("AM Band Descriptor") .that(AM_BAND_DESCRIPTOR).isNotEqualTo(FM_BAND_DESCRIPTOR); public void equals_withAmBandDescriptorsOfDifferentStereoSupportValues() { RadioManager.AmBandDescriptor amBandDescriptorCompared = new RadioManager.AmBandDescriptor(REGION, RadioManager.BAND_AM, AM_LOWER_LIMIT, AM_UPPER_LIMIT, AM_SPACING, !STEREO_SUPPORTED); assertWithMessage("AM Band Descriptor of different stereo support values") .that(AM_BAND_DESCRIPTOR).isNotEqualTo(amBandDescriptorCompared); } @Test public void equals_withFmBandDescriptorsOfDifferentSpacingValues() { RadioManager.FmBandDescriptor fmBandDescriptorCompared = new RadioManager.FmBandDescriptor( REGION, RadioManager.BAND_FM, FM_LOWER_LIMIT, FM_UPPER_LIMIT, FM_SPACING * 2, STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, AF_SUPPORTED, EA_SUPPORTED); assertWithMessage("FM Band Descriptors of different support limit values") .that(FM_BAND_DESCRIPTOR).isNotEqualTo(fmBandDescriptorCompared); } @Test public void equals_withFmBandConfigsOfDifferentLowerLimitValues() { RadioManager.FmBandDescriptor fmBandDescriptorCompared = new RadioManager.FmBandDescriptor( REGION + 1, RadioManager.BAND_AM_HD, AM_LOWER_LIMIT, AM_UPPER_LIMIT, AM_SPACING, STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, AF_SUPPORTED, EA_SUPPORTED); assertWithMessage("FM Band Descriptors of different region values") .that(FM_BAND_DESCRIPTOR).isNotEqualTo(fmBandDescriptorCompared); } @Test public void equals_withFmBandDescriptorsOfDifferentStereoSupportValues() { RadioManager.FmBandDescriptor fmBandDescriptorCompared = 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); assertWithMessage("FM Band Descriptors of different stereo support values") .that(fmBandDescriptorCompared).isNotEqualTo(FM_BAND_DESCRIPTOR); } @Test public void equals_withFmBandDescriptorsOfDifferentRdsSupportValues() { RadioManager.FmBandDescriptor fmBandDescriptorCompared = 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); assertWithMessage("FM Band Descriptors of different rds support values") .that(fmBandDescriptorCompared).isNotEqualTo(FM_BAND_DESCRIPTOR); } @Test public void equals_withFmBandDescriptorsOfDifferentTaSupportValues() { RadioManager.FmBandDescriptor fmBandDescriptorCompared = 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); assertWithMessage("FM Band Descriptors of different ta support values") .that(fmBandDescriptorCompared).isNotEqualTo(FM_BAND_DESCRIPTOR); } @Test public void equals_withFmBandDescriptorsOfDifferentAfSupportValues() { RadioManager.FmBandDescriptor fmBandDescriptorCompared = 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); assertWithMessage("FM Band Descriptors of different af support values") .that(fmBandDescriptorCompared).isNotEqualTo(FM_BAND_DESCRIPTOR); } @Test public void equals_withFmBandDescriptorsOfDifferentEaSupportValues() { RadioManager.FmBandDescriptor fmBandDescriptorCompared = 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); assertWithMessage("FM Band Descriptors of different ea support values") .that(fmBandDescriptorCompared).isNotEqualTo(FM_BAND_DESCRIPTOR); } @Test Loading Loading @@ -587,18 +683,79 @@ public final class RadioManagerTest { } @Test public void equals_withFmBandConfigsOfDifferentAfs_returnsFalse() { 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 fmBandConfigFromBuilder = builder.build(); public void equals_withFmBandConfigsOfDifferentRegionValues() { RadioManager.FmBandConfig fmBandConfigCompared = new RadioManager.FmBandConfig( new RadioManager.FmBandDescriptor(REGION + 1, RadioManager.BAND_AM_HD, AM_LOWER_LIMIT, AM_UPPER_LIMIT, AM_SPACING, STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, AF_SUPPORTED, EA_SUPPORTED)); assertWithMessage("FM Band Config of different regions") .that(FM_BAND_CONFIG).isNotEqualTo(fmBandConfigCompared); } @Test public void equals_withFmBandConfigsOfDifferentStereoSupportValues() { 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)); assertWithMessage("FM Band Config with different stereo support values") .that(fmBandConfigCompared).isNotEqualTo(FM_BAND_CONFIG); } assertWithMessage("FM Band Config of different af value") .that(FM_BAND_CONFIG).isNotEqualTo(fmBandConfigFromBuilder); @Test public void equals_withFmBandConfigsOfDifferentRdsSupportValues() { 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)); assertWithMessage("FM Band Config with different RDS support values") .that(fmBandConfigCompared).isNotEqualTo(FM_BAND_CONFIG); } @Test public void equals_withFmBandConfigsOfDifferentTaSupportValues() { 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)); assertWithMessage("FM Band Configs with different ta values") .that(fmBandConfigCompared).isNotEqualTo(FM_BAND_CONFIG); } @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)); assertWithMessage("FM Band Config of different af support value") .that(FM_BAND_CONFIG).isNotEqualTo(fmBandConfigCompared); } @Test public void equals_withFmBandConfigsOfDifferentEaSupportValues() { 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)); assertWithMessage("FM Band Configs with different ea support values") .that(fmBandConfigCompared).isNotEqualTo(FM_BAND_CONFIG); } @Test public void equals_withAmBandConfigsAndOtherTypeObject() { assertWithMessage("AM Band Config") .that(AM_BAND_CONFIG).isNotEqualTo(FM_BAND_CONFIG); } @Test public void equals_withFmAndAmBandConfigs_returnsFalse() { public void equals_withFmBandConfigsAndOtherTypeObject() { assertWithMessage("FM Band Config") .that(FM_BAND_CONFIG).isNotEqualTo(AM_BAND_CONFIG); } Loading
core/tests/BroadcastRadioTests/src/android/hardware/radio/RadioMetadataTest.java +132 −39 File changed.Preview size limit exceeded, changes collapsed. Show changes
core/tests/BroadcastRadioTests/src/android/hardware/radio/UniqueProgramIdentifierTest.java +54 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.hardware.radio; import static org.junit.Assert.assertThrows; import android.annotation.Nullable; import android.os.Parcel; Loading Loading @@ -44,6 +46,24 @@ public final class UniqueProgramIdentifierTest { @Rule public final Expect expect = Expect.create(); @Test public void requireCriticalSecondaryIds_forDab() { expect.withMessage("Critical secondary Id required for DAB") .that(UniqueProgramIdentifier.requireCriticalSecondaryIds( ProgramSelector.IDENTIFIER_TYPE_DAB_SID_EXT)).isTrue(); } @Test public void constructor_withNullSelector() { ProgramSelector nullSelector = null; NullPointerException thrown = assertThrows(NullPointerException.class, () -> new UniqueProgramIdentifier(nullSelector)); expect.withMessage("Null pointer exception for unique program identifier") .that(thrown).hasMessageThat().contains("can not be null"); } @Test public void getPrimaryId_forUniqueProgramIdentifier() { ProgramSelector dabSelector = getDabSelector(new ProgramSelector.Identifier[]{ Loading @@ -66,6 +86,27 @@ public final class UniqueProgramIdentifierTest { DAB_ENSEMBLE_IDENTIFIER, DAB_FREQUENCY_IDENTIFIER); } @Test public void getCriticalSecondaryIds_forDabUniqueProgramIdentifierWithoutEnsemble() { ProgramSelector dabSelector = getDabSelector(new ProgramSelector.Identifier[]{ DAB_FREQUENCY_IDENTIFIER}, /* vendorIds= */ null); UniqueProgramIdentifier dabIdentifier = new UniqueProgramIdentifier(dabSelector); expect.withMessage("Critical secondary ids of DAB unique identifier without ensemble") .that(dabIdentifier.getCriticalSecondaryIds()) .containsExactly(DAB_FREQUENCY_IDENTIFIER); } @Test public void getCriticalSecondaryIds_forDabUniqueProgramIdentifierWithoutSecondaryIds() { ProgramSelector dabSelector = getDabSelector(new ProgramSelector.Identifier[]{}, /* vendorIds= */ null); UniqueProgramIdentifier dabIdentifier = new UniqueProgramIdentifier(dabSelector); expect.withMessage("Critical secondary ids of DAB unique identifier") .that(dabIdentifier.getCriticalSecondaryIds()).isEmpty(); } @Test public void getCriticalSecondaryIds_forFmUniqueProgramIdentifier() { UniqueProgramIdentifier fmUniqueIdentifier = new UniqueProgramIdentifier( Loading Loading @@ -146,6 +187,19 @@ public final class UniqueProgramIdentifierTest { .that(dabIdentifier1).isNotEqualTo(dabIdentifier2); } @Test public void equals_withMissingSecondaryIdsForUniqueProgramIdentifier() { ProgramSelector dabSelector1 = getDabSelector(new ProgramSelector.Identifier[]{ DAB_ENSEMBLE_IDENTIFIER}, /* vendorIds= */ null); UniqueProgramIdentifier dabIdentifier1 = new UniqueProgramIdentifier(dabSelector1); ProgramSelector dabSelector2 = getDabSelector(new ProgramSelector.Identifier[]{ DAB_ENSEMBLE_IDENTIFIER, DAB_FREQUENCY_IDENTIFIER}, /* vendorIds= */ null); UniqueProgramIdentifier dabIdentifier2 = new UniqueProgramIdentifier(dabSelector2); expect.withMessage("DAB unique identifier with missing secondary ids") .that(dabIdentifier1).isNotEqualTo(dabIdentifier2); } @Test public void describeContents_forUniqueProgramIdentifier() { UniqueProgramIdentifier fmUniqueIdentifier = new UniqueProgramIdentifier(FM_IDENTIFIER); Loading