1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.bluetooth; 18 19 import android.test.suitebuilder.annotation.SmallTest; 20 21 import junit.framework.TestCase; 22 23 /** 24 * Unit test cases for {@link BluetoothLeAudioCodecConfig}. 25 */ 26 public class BluetoothLeAudioCodecConfigTest extends TestCase { 27 private int[] mCodecTypeArray = new int[] { 28 BluetoothLeAudioCodecConfig.SOURCE_CODEC_TYPE_LC3, 29 BluetoothLeAudioCodecConfig.SOURCE_CODEC_TYPE_INVALID, 30 }; 31 32 @SmallTest testBluetoothLeAudioCodecConfig_valid_get_methods()33 public void testBluetoothLeAudioCodecConfig_valid_get_methods() { 34 35 for (int codecIdx = 0; codecIdx < mCodecTypeArray.length; codecIdx++) { 36 int codecType = mCodecTypeArray[codecIdx]; 37 38 BluetoothLeAudioCodecConfig leAudioCodecConfig = 39 buildBluetoothLeAudioCodecConfig(codecType); 40 41 if (codecType == BluetoothLeAudioCodecConfig.SOURCE_CODEC_TYPE_LC3) { 42 assertEquals("LC3", leAudioCodecConfig.getCodecName()); 43 } 44 if (codecType == BluetoothLeAudioCodecConfig.SOURCE_CODEC_TYPE_INVALID) { 45 assertEquals("INVALID CODEC", leAudioCodecConfig.getCodecName()); 46 } 47 48 assertEquals(codecType, leAudioCodecConfig.getCodecType()); 49 } 50 } 51 buildBluetoothLeAudioCodecConfig(int sourceCodecType)52 private BluetoothLeAudioCodecConfig buildBluetoothLeAudioCodecConfig(int sourceCodecType) { 53 return new BluetoothLeAudioCodecConfig.Builder() 54 .setCodecType(sourceCodecType) 55 .build(); 56 57 } 58 } 59