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.wifi; 17 18 import static com.google.common.truth.Truth.assertThat; 19 import static org.mockito.Mockito.spy; 20 21 import android.content.Context; 22 23 import com.android.settings.search.SearchIndexableRaw; 24 import com.android.settings.testutils.SettingsRobolectricTestRunner; 25 26 import org.junit.Before; 27 import org.junit.Test; 28 import org.junit.runner.RunWith; 29 import org.mockito.MockitoAnnotations; 30 import org.robolectric.RuntimeEnvironment; 31 import org.robolectric.annotation.Config; 32 33 import java.util.List; 34 35 @RunWith(SettingsRobolectricTestRunner.class) 36 public class WifiSettingsTest { 37 38 private Context mContext; 39 40 @Before setUp()41 public void setUp() { 42 MockitoAnnotations.initMocks(this); 43 mContext = spy(RuntimeEnvironment.application); 44 } 45 46 @Test testSearchIndexProvider_shouldIndexFragmentTitle()47 public void testSearchIndexProvider_shouldIndexFragmentTitle() { 48 final List<SearchIndexableRaw> indexRes = 49 WifiSettings.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext, true /* enabled */); 50 51 assertThat(indexRes).isNotNull(); 52 assertThat(indexRes.get(0).key).isEqualTo(WifiSettings.DATA_KEY_REFERENCE); 53 } 54 55 @Test 56 @Config(qualifiers = "mcc999") testSearchIndexProvider_ifWifiSettingsNotVisible_shouldNotIndexFragmentTitle()57 public void testSearchIndexProvider_ifWifiSettingsNotVisible_shouldNotIndexFragmentTitle() { 58 final List<SearchIndexableRaw> indexRes = 59 WifiSettings.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext, true /* enabled */); 60 61 assertThat(indexRes).isEmpty(); 62 } 63 }