1 /*
2  * Copyright (C) 2020 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.testutils;
17 
18 import android.content.Context;
19 
20 import com.android.settings.R;
21 import com.android.settings.search.BaseSearchIndexProvider;
22 import com.android.settingslib.search.Indexable;
23 
24 import java.util.List;
25 
26 public class FakeIndexProvider implements Indexable {
27 
28     public static final String KEY = "TestKey";
29 
30     /**
31      * The fake SearchIndexProvider. Note that the use of location_settings below implies that tests
32      * using this should be using the res/xml-mcc999/location_settings.xml or
33      * res/xml-mcc998/location_settings.xml. Annotate tests with
34      * {@code @Config(qualifiers = "mcc999")}.
35      */
36     public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
37             new BaseSearchIndexProvider(R.xml.location_settings) {
38 
39                 @Override
40                 public List<String> getNonIndexableKeys(Context context) {
41                     List<String> result = super.getNonIndexableKeys(context);
42                     result.add(KEY);
43                     return result;
44                 }
45             };
46 }
47