Loading src/com/android/settings/display/ShowOperatorNamePreferenceController.java +2 −1 Original line number Diff line number Diff line Loading @@ -19,10 +19,11 @@ import android.support.v14.preference.SwitchPreference; import android.support.v7.preference.Preference; import com.android.settings.R; import com.android.settings.core.PreferenceControllerMixin; import com.android.settingslib.core.AbstractPreferenceController; public class ShowOperatorNamePreferenceController extends AbstractPreferenceController implements Preference.OnPreferenceChangeListener { implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener { private static final String KEY_SHOW_OPERATOR_NAME = "show_operator_name"; Loading tests/unit/src/com/android/settings/core/PreferenceControllerContractTest.java 0 → 100644 +86 −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.core; import static junit.framework.Assert.fail; import android.content.Context; import android.provider.SearchIndexableResource; import android.support.test.InstrumentationRegistry; import android.support.test.filters.MediumTest; import android.support.test.runner.AndroidJUnit4; import android.util.ArraySet; import com.android.settings.search.DatabaseIndexingUtils; import com.android.settings.search.Indexable; import com.android.settings.search.SearchIndexableResources; import com.android.settingslib.core.AbstractPreferenceController; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import java.util.List; import java.util.Set; @RunWith(AndroidJUnit4.class) @MediumTest public class PreferenceControllerContractTest { private Context mContext; @Before public void setUp() { mContext = InstrumentationRegistry.getTargetContext(); } @Test public void controllersInSearchShouldImplementPreferenceControllerMixin() { final Set<String> errorClasses = new ArraySet<>(); for (SearchIndexableResource page : SearchIndexableResources.values()) { final Class<?> clazz = DatabaseIndexingUtils.getIndexableClass(page.className); final Indexable.SearchIndexProvider provider = DatabaseIndexingUtils.getSearchIndexProvider(clazz); if (provider == null) { continue; } final List<AbstractPreferenceController> controllers = provider.getPreferenceControllers(mContext); if (controllers == null) { continue; } for (AbstractPreferenceController controller : controllers) { if (!(controller instanceof PreferenceControllerMixin)) { errorClasses.add(controller.getClass().getName()); } } } if (!errorClasses.isEmpty()) { final StringBuilder errorMessage = new StringBuilder() .append("Each preference must implement PreferenceControllerMixin, ") .append("the following classes don't:\n"); for (String c : errorClasses) { errorMessage.append(c).append("\n"); } fail(errorMessage.toString()); } } } tests/unit/src/com/android/settings/UniquePreferenceTest.java→tests/unit/src/com/android/settings/core/UniquePreferenceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ * limitations under the License. */ package com.android.settings; package com.android.settings.core; import static junit.framework.Assert.fail; Loading Loading
src/com/android/settings/display/ShowOperatorNamePreferenceController.java +2 −1 Original line number Diff line number Diff line Loading @@ -19,10 +19,11 @@ import android.support.v14.preference.SwitchPreference; import android.support.v7.preference.Preference; import com.android.settings.R; import com.android.settings.core.PreferenceControllerMixin; import com.android.settingslib.core.AbstractPreferenceController; public class ShowOperatorNamePreferenceController extends AbstractPreferenceController implements Preference.OnPreferenceChangeListener { implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener { private static final String KEY_SHOW_OPERATOR_NAME = "show_operator_name"; Loading
tests/unit/src/com/android/settings/core/PreferenceControllerContractTest.java 0 → 100644 +86 −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.core; import static junit.framework.Assert.fail; import android.content.Context; import android.provider.SearchIndexableResource; import android.support.test.InstrumentationRegistry; import android.support.test.filters.MediumTest; import android.support.test.runner.AndroidJUnit4; import android.util.ArraySet; import com.android.settings.search.DatabaseIndexingUtils; import com.android.settings.search.Indexable; import com.android.settings.search.SearchIndexableResources; import com.android.settingslib.core.AbstractPreferenceController; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import java.util.List; import java.util.Set; @RunWith(AndroidJUnit4.class) @MediumTest public class PreferenceControllerContractTest { private Context mContext; @Before public void setUp() { mContext = InstrumentationRegistry.getTargetContext(); } @Test public void controllersInSearchShouldImplementPreferenceControllerMixin() { final Set<String> errorClasses = new ArraySet<>(); for (SearchIndexableResource page : SearchIndexableResources.values()) { final Class<?> clazz = DatabaseIndexingUtils.getIndexableClass(page.className); final Indexable.SearchIndexProvider provider = DatabaseIndexingUtils.getSearchIndexProvider(clazz); if (provider == null) { continue; } final List<AbstractPreferenceController> controllers = provider.getPreferenceControllers(mContext); if (controllers == null) { continue; } for (AbstractPreferenceController controller : controllers) { if (!(controller instanceof PreferenceControllerMixin)) { errorClasses.add(controller.getClass().getName()); } } } if (!errorClasses.isEmpty()) { final StringBuilder errorMessage = new StringBuilder() .append("Each preference must implement PreferenceControllerMixin, ") .append("the following classes don't:\n"); for (String c : errorClasses) { errorMessage.append(c).append("\n"); } fail(errorMessage.toString()); } } }
tests/unit/src/com/android/settings/UniquePreferenceTest.java→tests/unit/src/com/android/settings/core/UniquePreferenceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ * limitations under the License. */ package com.android.settings; package com.android.settings.core; import static junit.framework.Assert.fail; Loading