• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 package com.android.settings.deviceinfo;
17 
18 import static com.google.common.truth.Truth.assertThat;
19 import static org.mockito.Mockito.when;
20 
21 import android.content.Context;
22 import android.os.SystemProperties;
23 import android.support.v7.preference.Preference;
24 import android.support.v7.preference.PreferenceScreen;
25 
26 import com.android.settings.testutils.SettingsRobolectricTestRunner;
27 
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.junit.runner.RunWith;
31 import org.mockito.Answers;
32 import org.mockito.Mock;
33 import org.mockito.MockitoAnnotations;
34 
35 @RunWith(SettingsRobolectricTestRunner.class)
36 public class FccEquipmentIdPreferenceControllerTest {
37 
38     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
39     private Context mContext;
40     @Mock
41     private Preference mPreference;
42     @Mock
43     private PreferenceScreen mPreferenceScreen;
44     private FccEquipmentIdPreferenceController mController;
45 
46     @Before
setUp()47     public void setUp() {
48         MockitoAnnotations.initMocks(this);
49         mController = new FccEquipmentIdPreferenceController(mContext);
50         when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
51             .thenReturn(mPreference);
52     }
53 
54     @Test
isAvailable_configEmpty_shouldReturnFalse()55     public void isAvailable_configEmpty_shouldReturnFalse() {
56         assertThat(mController.isAvailable()).isFalse();
57     }
58 
59     @Test
isAvailable_configNonEmpty_shouldReturnTrue()60     public void isAvailable_configNonEmpty_shouldReturnTrue() {
61         SystemProperties.set("ro.ril.fccid", "fcc_equipment");
62 
63         assertThat(mController.isAvailable()).isTrue();
64     }
65 }
66