Merge "Throw exception when attempting to build empty AudioMixingRule."
This commit is contained in:
committed by
Android (Google) Code Review
commit
351785dcfa
@@ -704,8 +704,12 @@ public class AudioMixingRule {
|
||||
* Combines all of the matching and exclusion rules that have been set and return a new
|
||||
* {@link AudioMixingRule} object.
|
||||
* @return a new {@link AudioMixingRule} object
|
||||
* @throws IllegalArgumentException if the rule is empty.
|
||||
*/
|
||||
public AudioMixingRule build() {
|
||||
if (mCriteria.isEmpty()) {
|
||||
throw new IllegalArgumentException("Cannot build AudioMixingRule with no rules.");
|
||||
}
|
||||
return new AudioMixingRule(
|
||||
mTargetMixType == AudioMix.MIX_TYPE_INVALID
|
||||
? AudioMix.MIX_TYPE_PLAYERS : mTargetMixType,
|
||||
|
||||
@@ -212,6 +212,12 @@ public class AudioMixingRuleUnitTests {
|
||||
containsInAnyOrder(isAudioMixSessionCriterion(TEST_SESSION_ID)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void audioMixingRuleWithNoRulesFails() {
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> new AudioMixingRule.Builder().build());
|
||||
}
|
||||
|
||||
|
||||
private static Matcher isAudioMixUidCriterion(int uid, boolean exclude) {
|
||||
return new CustomTypeSafeMatcher<AudioMixMatchCriterion>("uid mix criterion") {
|
||||
|
||||
Reference in New Issue
Block a user