Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 031af9f2 authored by Matthew Fritze's avatar Matthew Fritze
Browse files

Remove Wallpaper duplicate from setting search

Bug: 33701673
Test: make -j40 RunSettingsRoboTests
Change-Id: I520cbc74284d92ab05b733346ee1b3115ddd8e9f
parent 6393e175
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ public class LegalSettings extends SettingsPreferenceFragment implements Indexab
    private static final String KEY_LICENSE = "license";
    private static final String KEY_COPYRIGHT = "copyright";
    private static final String KEY_WEBVIEW_LICENSE = "webview_license";
    private static final String KEY_WALLPAPER_ATTRIBUTIONS = "wallpaper_attributions";

    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
@@ -76,7 +77,7 @@ public class LegalSettings extends SettingsPreferenceFragment implements Indexab

            @Override
            public List<String> getNonIndexableKeys(Context context) {
                final List<String> keys = new ArrayList<String>();
                final List<String> keys = super.getNonIndexableKeys(context);
                if (!checkIntentAction(context, "android.settings.TERMS")) {
                    keys.add(KEY_TERMS);
                }
@@ -89,6 +90,7 @@ public class LegalSettings extends SettingsPreferenceFragment implements Indexab
                if (!checkIntentAction(context, "android.settings.WEBVIEW_LICENSE")) {
                    keys.add(KEY_WEBVIEW_LICENSE);
                }
                keys.add(KEY_WALLPAPER_ATTRIBUTIONS);
                return keys;
            }

+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider {
            }
            return nonIndexableKeys;
        } else {
            return EMPTY_LIST;
            return new ArrayList<>();
        }
    }

+46 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.settings;

import android.content.Context;

import com.android.settings.testutils.XmlTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;

import java.util.List;

import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.spy;

@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class LegalSettingsTest {

    @Test
    public void testNonIndexableKeys_existInXmlLayout() {
        final Context context = RuntimeEnvironment.application;
        final List<String> niks = LegalSettings.SEARCH_INDEX_DATA_PROVIDER
                .getNonIndexableKeys(context);

        final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context,
                R.xml.about_legal);

        assertThat(keys).containsAllIn(niks);
    }
}
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
@@ -671,9 +671,9 @@ public class DatabaseIndexingManagerTest {
                new HashMap<String, Set<String>>());

        Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index WHERE enabled = 1", null);
        assertThat(cursor.getCount()).isEqualTo(2);
        assertThat(cursor.getCount()).isEqualTo(1);
        cursor = mDb.rawQuery("SELECT * FROM prefs_index WHERE enabled = 0", null);
        assertThat(cursor.getCount()).isEqualTo(4);
        assertThat(cursor.getCount()).isEqualTo(5);
    }

    @Test