• 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 
17 package com.android.settings.system;
18 
19 import static com.google.common.truth.Truth.assertThat;
20 
21 import android.content.Context;
22 
23 import com.android.settings.testutils.SettingsRobolectricTestRunner;
24 import com.android.settings.testutils.XmlTestUtils;
25 import com.android.settings.testutils.shadow.SettingsShadowResources;
26 
27 import org.junit.After;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.junit.runner.RunWith;
31 import org.robolectric.RuntimeEnvironment;
32 import org.robolectric.annotation.Config;
33 
34 import java.util.List;
35 
36 @RunWith(SettingsRobolectricTestRunner.class)
37 @Config(shadows = SettingsShadowResources.class)
38 public class SystemDashboardFragmentTest {
39 
40     @Before
setup()41     public void setup() {
42         SettingsShadowResources.overrideResource(
43                 com.android.internal.R.bool.config_supportSystemNavigationKeys, true);
44     }
45 
46     @After
tearDown()47     public void tearDown() {
48         SettingsShadowResources.reset();
49     }
50 
51     @Test
testNonIndexableKeys_existInXmlLayout()52     public void testNonIndexableKeys_existInXmlLayout() {
53         final Context context = RuntimeEnvironment.application;
54         final List<String> niks = SystemDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
55                 .getNonIndexableKeys(context);
56         final int xmlId = (new SystemDashboardFragment()).getPreferenceScreenResId();
57 
58         final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
59 
60         assertThat(keys).containsAllIn(niks);
61     }
62 }
63