1 /* 2 * Copyright (C) 2018 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.display; 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 static org.mockito.Mockito.spy; 25 26 import android.content.Context; 27 28 import org.junit.Before; 29 import org.junit.Test; 30 import org.junit.runner.RunWith; 31 import org.mockito.MockitoAnnotations; 32 import org.robolectric.RobolectricTestRunner; 33 import org.robolectric.RuntimeEnvironment; 34 import org.robolectric.annotation.Config; 35 36 @RunWith(RobolectricTestRunner.class) 37 public class TopLevelDisplayPreferenceControllerTest { 38 private Context mContext; 39 private TopLevelDisplayPreferenceController mController; 40 41 @Before setUp()42 public void setUp() { 43 MockitoAnnotations.initMocks(this); 44 mContext = spy(RuntimeEnvironment.application); 45 mController = new TopLevelDisplayPreferenceController(mContext, "test_key"); 46 } 47 48 @Test getAvailibilityStatus_availableByDefault()49 public void getAvailibilityStatus_availableByDefault() { 50 assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); 51 } 52 53 @Test 54 @Config(qualifiers = "mcc999") getAvailabilityStatus_unsupportedWhenSet()55 public void getAvailabilityStatus_unsupportedWhenSet() { 56 assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE); 57 } 58 } 59