Remove Language and Input duplicates
Change the keys in the Language and Input screen for the gesture and tts-output settings so they can be disabled in search. Then change the preference controllers to take a key as input to avoid crashes on the other screens with these settings. Merge for: ag/2098173/ Test: make RunSettingsRoboTests Bug: 33701673 Change-Id: I8bc0776131fcac5a6edf7e8271bc53252c2fc719
This commit is contained in:
@@ -18,7 +18,9 @@ package com.android.settings.language;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -42,6 +44,9 @@ import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settings.fuelgauge.PowerUsageSummary;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
import com.android.settings.testutils.shadow.ShadowSecureSettings;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
@@ -52,6 +57,7 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -80,6 +86,7 @@ public class LanguageAndInputSettingsTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
FakeFeatureFactory.setupForTest(mContext);
|
||||
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mock(UserManager.class));
|
||||
when(mContext.getSystemService(Context.INPUT_SERVICE)).thenReturn(mock(InputManager.class));
|
||||
when(mContext.getSystemService(Context.INPUT_SERVICE)).thenReturn(mIm);
|
||||
@@ -145,6 +152,37 @@ public class LanguageAndInputSettingsTest {
|
||||
verify(loader).setSummary(provider, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonIndexableKeys_existInXmlLayout() {
|
||||
final Context context = spy(RuntimeEnvironment.application);
|
||||
//(InputManager) context.getSystemService(Context.INPUT_SERVICE);
|
||||
InputManager manager = mock(InputManager.class);
|
||||
when(manager.getInputDeviceIds()).thenReturn(new int[]{});
|
||||
doReturn(manager).when(context).getSystemService(Context.INPUT_SERVICE);
|
||||
final List<String> niks = LanguageAndInputSettings.SEARCH_INDEX_DATA_PROVIDER
|
||||
.getNonIndexableKeys(context);
|
||||
final int xmlId = (new LanguageAndInputSettings()).getPreferenceScreenResId();
|
||||
|
||||
final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
|
||||
|
||||
assertThat(keys).containsAllIn(niks);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
final LanguageAndInputSettings fragment = new LanguageAndInputSettings();
|
||||
final List<String> preferenceScreenKeys = XmlTestUtils.getKeysFromPreferenceXml(context,
|
||||
fragment.getPreferenceScreenResId());
|
||||
final List<String> preferenceKeys = new ArrayList<>();
|
||||
|
||||
for (PreferenceController controller : fragment.getPreferenceControllers(context)) {
|
||||
preferenceKeys.add(controller.getPreferenceKey());
|
||||
}
|
||||
|
||||
assertThat(preferenceScreenKeys).containsAllIn(preferenceKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test fragment to expose lifecycle and context so we can verify behavior for observables.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user