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 */ 16package com.android.settings.wifi; 17 18import static com.google.common.truth.Truth.assertThat; 19import static org.mockito.Mockito.spy; 20 21import android.content.Context; 22 23import com.android.settings.search.SearchIndexableRaw; 24import com.android.settings.testutils.SettingsRobolectricTestRunner; 25 26import org.junit.Before; 27import org.junit.Test; 28import org.junit.runner.RunWith; 29import org.mockito.MockitoAnnotations; 30import org.robolectric.RuntimeEnvironment; 31import org.robolectric.annotation.Config; 32 33import java.util.List; 34 35@RunWith(SettingsRobolectricTestRunner.class) 36public class WifiSettingsTest { 37 38 private Context mContext; 39 40 @Before 41 public void setUp() { 42 MockitoAnnotations.initMocks(this); 43 mContext = spy(RuntimeEnvironment.application); 44 } 45 46 @Test 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") 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}