1 /* 2 * Copyright (C) 2023 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 com.android.car.audio; 18 19 import static org.mockito.Mockito.when; 20 21 import org.mockito.Mockito; 22 23 public final class TestCarAudioDeviceInfoBuilder { 24 public static final int STEP_VALUE = 2; 25 public static final int MIN_GAIN = 3; 26 public static final int MAX_GAIN = 10; 27 public static final int DEFAULT_GAIN = 5; 28 29 private final String mAddress; 30 31 private int mStepValue = STEP_VALUE; 32 private int mDefaultGain = DEFAULT_GAIN; 33 private int mMinGain = MIN_GAIN; 34 private int mMaxGain = MAX_GAIN; 35 TestCarAudioDeviceInfoBuilder(String address)36 TestCarAudioDeviceInfoBuilder(String address) { 37 mAddress = address; 38 } 39 setStepValue(int stepValue)40 TestCarAudioDeviceInfoBuilder setStepValue(int stepValue) { 41 mStepValue = stepValue; 42 return this; 43 } 44 setDefaultGain(int defaultGain)45 TestCarAudioDeviceInfoBuilder setDefaultGain(int defaultGain) { 46 mDefaultGain = defaultGain; 47 return this; 48 } 49 setMinGain(int minGain)50 TestCarAudioDeviceInfoBuilder setMinGain(int minGain) { 51 mMinGain = minGain; 52 return this; 53 } 54 setMaxGain(int maxGain)55 TestCarAudioDeviceInfoBuilder setMaxGain(int maxGain) { 56 mMaxGain = maxGain; 57 return this; 58 } 59 build()60 CarAudioDeviceInfo build() { 61 CarAudioDeviceInfo infoMock = Mockito.mock(CarAudioDeviceInfo.class); 62 when(infoMock.getStepValue()).thenReturn(mStepValue); 63 when(infoMock.getDefaultGain()).thenReturn(mDefaultGain); 64 when(infoMock.getMaxGain()).thenReturn(mMaxGain); 65 when(infoMock.getMinGain()).thenReturn(mMinGain); 66 when(infoMock.getAddress()).thenReturn(mAddress); 67 return infoMock; 68 } 69 } 70