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.settings.accessibility; 18 19 import static com.android.settings.core.BasePreferenceController.AVAILABLE; 20 import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE; 21 22 import static com.google.common.truth.Truth.assertThat; 23 24 import android.content.Context; 25 import android.util.FeatureFlagUtils; 26 27 import androidx.test.core.app.ApplicationProvider; 28 29 import org.junit.Before; 30 import org.junit.Rule; 31 import org.junit.Test; 32 import org.junit.runner.RunWith; 33 import org.mockito.junit.MockitoJUnit; 34 import org.mockito.junit.MockitoRule; 35 import org.robolectric.RobolectricTestRunner; 36 37 /** Tests for {@link HearingAidAudioRoutingPreferenceController}. */ 38 @RunWith(RobolectricTestRunner.class) 39 public class HearingAidAudioRoutingPreferenceControllerTest { 40 @Rule 41 public final MockitoRule mockito = MockitoJUnit.rule(); 42 43 private final Context mContext = ApplicationProvider.getApplicationContext(); 44 45 private HearingAidAudioRoutingPreferenceController mController; 46 47 @Before setUp()48 public void setUp() { 49 mController = new HearingAidAudioRoutingPreferenceController(mContext, "test_key"); 50 } 51 52 @Test getAvailabilityStatus_audioRoutingNotSupported_returnUnsupported()53 public void getAvailabilityStatus_audioRoutingNotSupported_returnUnsupported() { 54 FeatureFlagUtils.setEnabled(mContext, 55 FeatureFlagUtils.SETTINGS_AUDIO_ROUTING, false); 56 57 assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE); 58 } 59 60 @Test getAvailabilityStatus_audioRoutingNotSupported_available()61 public void getAvailabilityStatus_audioRoutingNotSupported_available() { 62 FeatureFlagUtils.setEnabled(mContext, 63 FeatureFlagUtils.SETTINGS_AUDIO_ROUTING, true); 64 65 assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); 66 } 67 } 68