| :
* Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.development; import static com.android.settings.development.BluetoothA2dpCodecPreferenceController.BLUETOOTH_A2DP_CODEC_KEY; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.bluetooth.BluetoothCodecConfig; import android.content.Context; import android.content.res.Resources; import androidx.preference.ListPreference; import androidx.preference.PreferenceScreen; import com.android.settings.R; import com.android.settingslib.core.AbstractPreferenceController; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; @RunWith(RobolectricTestRunner.class) public class BluetoothA2dpCodecPreferenceControllerTest { @Mock private PreferenceScreen mScreen; @Mock private ListPreference mPreference; @Mock private BluetoothCodecConfig mCodecConfig; private Context mContext; private BluetoothA2dpCodecPreferenceController mController; @Before public void setup() { MockitoAnnotations.initMocks(this); mContext = spy(RuntimeEnvironment.application); mController = new BluetoothA2dpCodecPreferenceController(mContext); when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference); doReturn(mContext.getResources()).when(mContext).getResources(); } @Test public void getPreferenceKey_shouldReturnCorrectKey() { assertThat(mController.getPreferenceKey()).isEqualTo(BLUETOOTH_A2DP_CODEC_KEY); } @Test public void updateState_shouldSetSummary() { final Resources res = mContext.getResources(); final CharSequence[] entries = res.getTextArray(R.array.bluetooth_a2dp_codec_summaries); final CharSequence[] values = res.getTextArray(R.array.bluetooth_a2dp_codec_values); when(mCodecConfig.getCodecName()).thenReturn(values[0].toString()); mController.updateState(mPreference); verify(mPreference).setSummary(entries[0]); } @Test public void isAvailable_shouldReturnTrue() { assertThat(mController.isAvailable()).isTrue(); } @Test public void getPreferenceController_shouldReturnCorrectType() { assertThat(mController).isInstanceOf(AbstractPreferenceController.class); } }
ǸҳܰȨ۳ʱ踶ѹ
˴
ɨ븶Ѽɸ
接续盒 | 尾纤 | vaoa | CRAN | CRAN站点部署方案 | PDN信令失败 | mapinfo在线地图 | 广电网络 | 广电共享 | sggg | sgg | sggggg |