Combine Language & region and Input & gestures in System settings.
Merge preferences into one page, and update test. Bug: 34976047 Test: make RunSettingsRoboTests Change-Id: I5f15192e42f6054c02d4c8ffa9f25db3075da409
This commit is contained in:
@@ -3187,8 +3187,8 @@
|
||||
</activity>
|
||||
|
||||
<!-- Alias for IME & Language in new IA. Should merge into TargetActivity when launch -->
|
||||
<activity android:name=".Settings$LanguageAndRegionSettingsActivity"
|
||||
android:label="@string/language_and_region_settings_title"
|
||||
<activity android:name=".Settings$LanguageAndInputSettingsActivity"
|
||||
android:label="@string/language_keyboard_settings_title"
|
||||
android:icon="@drawable/ic_settings_language">
|
||||
<intent-filter android:priority="260">
|
||||
<action android:name="com.android.settings.action.SETTINGS"/>
|
||||
@@ -3196,27 +3196,12 @@
|
||||
<meta-data android:name="com.android.settings.category"
|
||||
android:value="com.android.settings.category.ia.system"/>
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.language.LanguageAndRegionSettings"/>
|
||||
android:value="com.android.settings.language.LanguageAndInputSettings"/>
|
||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||
android:value="true"/>
|
||||
<!-- Inherit intent-filter from LanguageSettingsActivity -->
|
||||
</activity>
|
||||
|
||||
<activity android:name=".Settings$InputAndGestureSettingsActivity"
|
||||
android:label="@string/input_gesture_settings_title"
|
||||
android:icon="@drawable/ic_settings_language">
|
||||
<intent-filter android:priority="255">
|
||||
<action android:name="com.android.settings.action.SETTINGS" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.category"
|
||||
android:value="com.android.settings.category.ia.system" />
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.inputmethod.InputAndGestureSettings" />
|
||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||
android:value="true" />
|
||||
<!-- Inherit intent-filter from LanguageSettingsActivity -->
|
||||
</activity>
|
||||
|
||||
<!-- Alias for Date & Time in new IA. Should merge into TargetActivity when launch -->
|
||||
<activity-alias android:name="DateTimeDashboardAlias"
|
||||
android:targetActivity="Settings$DateTimeSettingsActivity">
|
||||
@@ -3267,6 +3252,8 @@
|
||||
android:value="com.android.settings.category.ia.system" />
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.DeviceInfoSettings" />
|
||||
<meta-data android:name="com.android.settings.title"
|
||||
android:resource="@string/about_settings" />
|
||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||
android:value="true" />
|
||||
</activity-alias>
|
||||
|
@@ -3720,10 +3720,6 @@
|
||||
<string name="language_settings">Languages & input</string>
|
||||
<!-- Title of Languages & input settings screen -->
|
||||
<string name="language_keyboard_settings_title">Languages & input</string>
|
||||
<!-- Title of Languages & region settings screen -->
|
||||
<string name="language_and_region_settings_title">Languages & region</string>
|
||||
<!-- Title of Input & gesture settings screen -->
|
||||
<string name="input_gesture_settings_title">Input & gestures</string>
|
||||
<!-- On Languages & input settings screen, heading. Inside the "Languages & input settings" screen, this is the header for settings that relate to keyboard (enable/disable each keyboard, settings for each keyboard). -->
|
||||
<string name="keyboard_settings_category">Keyboard & input methods</string>
|
||||
<!-- On Text & language settings screen, setting option name. title of the setting to take the user to a screen to select the locale. -->
|
||||
|
@@ -17,7 +17,12 @@
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/input_gesture_settings_title">
|
||||
android:title="@string/language_keyboard_settings_title" >
|
||||
|
||||
<Preference
|
||||
android:key="phone_language"
|
||||
android:title="@string/phone_language"
|
||||
android:fragment="com.android.settings.localepicker.LocaleListEditor"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/keyboard_and_input_methods_category">
|
||||
@@ -29,6 +34,20 @@
|
||||
android:fragment="com.android.settings.inputmethod.PhysicalKeyboardFragment"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<!-- Spell checker preference title, summary and fragment will be set programmatically. -->
|
||||
<!-- Note: Mark this as persistent="false" to remove unnecessarily saved shared preference.
|
||||
See: InputMethodAndSubtypeUtil.removeUnnecessaryNonPersistentPreference. -->
|
||||
<Preference
|
||||
android:key="spellcheckers_settings"
|
||||
android:title="@string/spellcheckers_settings_title"
|
||||
android:persistent="false"
|
||||
android:fragment="com.android.settings.inputmethod.SpellCheckersSettings"/>
|
||||
|
||||
<!-- User dictionary preference title and fragment will be set programmatically. -->
|
||||
<Preference
|
||||
android:key="key_user_dictionary_settings"
|
||||
android:title="@string/user_dict_settings_title"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="gesture_settings_category"
|
||||
android:title="@string/gesture_preference_title">
|
||||
@@ -71,6 +90,18 @@
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<!-- TTS -->
|
||||
<PreferenceCategory
|
||||
android:key="voice_category"
|
||||
android:title="@string/voice_category">
|
||||
|
||||
<Preference
|
||||
android:key="tts_settings"
|
||||
android:title="@string/tts_settings_title"
|
||||
android:fragment="com.android.settings.tts.TextToSpeechSettings"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="game_controller_settings_category"
|
||||
android:title="@string/game_controller_settings_category">
|
@@ -1,51 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2016 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.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<Preference
|
||||
android:key="phone_language"
|
||||
android:title="@string/phone_language"
|
||||
android:fragment="com.android.settings.localepicker.LocaleListEditor"/>
|
||||
|
||||
<!-- Spell checker preference title, summary and fragment will be set programmatically. -->
|
||||
<!-- Note: Mark this as persistent="false" to remove unnecessarily saved shared preference.
|
||||
See: InputMethodAndSubtypeUtil.removeUnnecessaryNonPersistentPreference. -->
|
||||
<Preference
|
||||
android:key="spellcheckers_settings"
|
||||
android:title="@string/spellcheckers_settings_title"
|
||||
android:persistent="false"
|
||||
android:fragment="com.android.settings.inputmethod.SpellCheckersSettings"/>
|
||||
|
||||
<!-- User dictionary preference title and fragment will be set programmatically. -->
|
||||
<Preference
|
||||
android:key="key_user_dictionary_settings"
|
||||
android:title="@string/user_dict_settings_title"/>
|
||||
|
||||
<!-- TTS -->
|
||||
<PreferenceCategory
|
||||
android:key="voice_category"
|
||||
android:title="@string/voice_category">
|
||||
|
||||
<Preference
|
||||
android:key="tts_settings"
|
||||
android:title="@string/tts_settings_title"
|
||||
android:fragment="com.android.settings.tts.TextToSpeechSettings"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
@@ -41,14 +41,13 @@ public class Settings extends SettingsActivity {
|
||||
public static class WifiSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class WifiP2pSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class InputMethodAndLanguageSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class InputAndGestureSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class AvailableVirtualKeyboardActivity extends SettingsActivity { /* empty */ }
|
||||
public static class KeyboardLayoutPickerActivity extends SettingsActivity { /* empty */ }
|
||||
public static class PhysicalKeyboardActivity extends SettingsActivity { /* empty */ }
|
||||
public static class InputMethodAndSubtypeEnablerActivity extends SettingsActivity { /* empty */ }
|
||||
public static class SpellCheckersSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class LocalePickerActivity extends SettingsActivity { /* empty */ }
|
||||
public static class LanguageAndRegionSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class LanguageAndInputSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class UserDictionarySettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class DisplaySettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class NightDisplaySettingsActivity extends SettingsActivity { /* empty */ }
|
||||
|
@@ -88,13 +88,12 @@ import com.android.settings.gestures.GestureSettings;
|
||||
import com.android.settings.gestures.PickupGestureSettings;
|
||||
import com.android.settings.gestures.SwipeToNotificationSettings;
|
||||
import com.android.settings.inputmethod.AvailableVirtualKeyboardFragment;
|
||||
import com.android.settings.inputmethod.InputAndGestureSettings;
|
||||
import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
|
||||
import com.android.settings.inputmethod.KeyboardLayoutPickerFragment;
|
||||
import com.android.settings.inputmethod.PhysicalKeyboardFragment;
|
||||
import com.android.settings.inputmethod.SpellCheckersSettings;
|
||||
import com.android.settings.inputmethod.UserDictionaryList;
|
||||
import com.android.settings.language.LanguageAndRegionSettings;
|
||||
import com.android.settings.language.LanguageAndInputSettings;
|
||||
import com.android.settings.localepicker.LocaleListEditor;
|
||||
import com.android.settings.location.LocationSettings;
|
||||
import com.android.settings.network.NetworkDashboardFragment;
|
||||
@@ -149,8 +148,7 @@ public class SettingsGateway {
|
||||
LocaleListEditor.class.getName(),
|
||||
InputMethodAndLanguageSettings.class.getName(),
|
||||
AvailableVirtualKeyboardFragment.class.getName(),
|
||||
InputAndGestureSettings.class.getName(),
|
||||
LanguageAndRegionSettings.class.getName(),
|
||||
LanguageAndInputSettings.class.getName(),
|
||||
SpellCheckersSettings.class.getName(),
|
||||
UserDictionaryList.class.getName(),
|
||||
UserDictionarySettings.class.getName(),
|
||||
@@ -299,8 +297,7 @@ public class SettingsGateway {
|
||||
// Home page > Security
|
||||
"com.android.settings.LocationDashboardAlias",
|
||||
// Home page > System
|
||||
Settings.LanguageAndRegionSettingsActivity.class.getName(),
|
||||
Settings.InputAndGestureSettingsActivity.class.getName(),
|
||||
Settings.LanguageAndInputSettingsActivity.class.getName(),
|
||||
"com.android.settings.DateTimeDashboardAlias",
|
||||
"com.android.settings.AccessibilityDashboardAlias",
|
||||
"com.android.settings.AboutDeviceDashboardAlias",
|
||||
|
@@ -28,9 +28,8 @@ import com.android.settings.applications.AppAndNotificationDashboardFragment;
|
||||
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
|
||||
import com.android.settings.deviceinfo.StorageDashboardFragment;
|
||||
import com.android.settings.fuelgauge.PowerUsageSummary;
|
||||
import com.android.settings.inputmethod.InputAndGestureSettings;
|
||||
import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
|
||||
import com.android.settings.language.LanguageAndRegionSettings;
|
||||
import com.android.settings.language.LanguageAndInputSettings;
|
||||
import com.android.settings.network.NetworkDashboardFragment;
|
||||
import com.android.settings.notification.SoundSettings;
|
||||
import com.android.settings.system.SystemDashboardFragment;
|
||||
@@ -81,11 +80,9 @@ public class DashboardFragmentRegistry {
|
||||
CategoryKey.CATEGORY_ACCOUNT);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(
|
||||
SystemDashboardFragment.class.getName(), CategoryKey.CATEGORY_SYSTEM);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(
|
||||
InputAndGestureSettings.class.getName(), CategoryKey.CATEGORY_SYSTEM_INPUT);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(InputMethodAndLanguageSettings.class.getName(),
|
||||
CategoryKey.CATEGORY_SYSTEM_LANGUAGE);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(LanguageAndRegionSettings.class.getName(),
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(LanguageAndInputSettings.class.getName(),
|
||||
CategoryKey.CATEGORY_SYSTEM_LANGUAGE);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(DevelopmentSettings.class.getName(),
|
||||
CategoryKey.CATEGORY_SYSTEM_DEVELOPMENT);
|
||||
|
@@ -14,11 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.inputmethod;
|
||||
package com.android.settings.language;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.speech.tts.TtsEngines;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
@@ -31,6 +32,8 @@ import com.android.settings.gestures.DoubleTapPowerPreferenceController;
|
||||
import com.android.settings.gestures.DoubleTapScreenPreferenceController;
|
||||
import com.android.settings.gestures.DoubleTwistPreferenceController;
|
||||
import com.android.settings.gestures.PickupGesturePreferenceController;
|
||||
import com.android.settings.inputmethod.GameControllerPreferenceController;
|
||||
import com.android.settings.inputmethod.SpellCheckerPreferenceController;
|
||||
import com.android.settings.gestures.SwipeToNotificationPreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
@@ -39,15 +42,15 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class InputAndGestureSettings extends DashboardFragment {
|
||||
public class LanguageAndInputSettings extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "InputAndGestureSettings";
|
||||
private static final String TAG = "LangAndInputSettings";
|
||||
|
||||
private AmbientDisplayConfiguration mAmbientDisplayConfig;
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.SETTINGS_INPUT_CATEGORY;
|
||||
return MetricsProto.MetricsEvent.SETTINGS_LANGUAGE_CATEGORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,14 +58,27 @@ public class InputAndGestureSettings extends DashboardFragment {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
mProgressiveDisclosureMixin.setTileLimit(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.input_and_gesture;
|
||||
return R.xml.language_and_input;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<PreferenceController> getPreferenceControllers(Context context) {
|
||||
final Lifecycle lifecycle = getLifecycle();
|
||||
final List<PreferenceController> controllers = new ArrayList<>();
|
||||
// Language
|
||||
controllers.add(new PhoneLanguagePreferenceController(context));
|
||||
controllers.add(new SpellCheckerPreferenceController(context));
|
||||
controllers.add(new UserDictionaryPreferenceController(context));
|
||||
controllers.add(new TtsPreferenceController(context, new TtsEngines(context)));
|
||||
// Input
|
||||
final GameControllerPreferenceController gameControllerPreferenceController
|
||||
= new GameControllerPreferenceController(context);
|
||||
getLifecycle().addObserver(gameControllerPreferenceController);
|
||||
@@ -70,7 +86,6 @@ public class InputAndGestureSettings extends DashboardFragment {
|
||||
if (mAmbientDisplayConfig == null) {
|
||||
mAmbientDisplayConfig = new AmbientDisplayConfiguration(context);
|
||||
}
|
||||
final List<PreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(gameControllerPreferenceController);
|
||||
// Gestures
|
||||
|
||||
@@ -99,7 +114,7 @@ public class InputAndGestureSettings extends DashboardFragment {
|
||||
return null;
|
||||
}
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.input_and_gesture;
|
||||
sir.xmlResId = R.xml.language_and_input;
|
||||
return Arrays.asList(sir);
|
||||
}
|
||||
};
|
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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.language;
|
||||
|
||||
import android.content.Context;
|
||||
import android.speech.tts.TtsEngines;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.inputmethod.SpellCheckerPreferenceController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LanguageAndRegionSettings extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "LangAndRegionSettings";
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.SETTINGS_LANGUAGE_CATEGORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.language_and_region;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<PreferenceController> getPreferenceControllers(Context context) {
|
||||
final List<PreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new PhoneLanguagePreferenceController(context));
|
||||
controllers.add(new SpellCheckerPreferenceController(context));
|
||||
controllers.add(new UserDictionaryPreferenceController(context));
|
||||
controllers.add(new TtsPreferenceController(context, new TtsEngines(context)));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
}
|
@@ -56,10 +56,10 @@ import com.android.settings.gestures.GestureSettings;
|
||||
import com.android.settings.gestures.PickupGestureSettings;
|
||||
import com.android.settings.gestures.SwipeToNotificationSettings;
|
||||
import com.android.settings.inputmethod.AvailableVirtualKeyboardFragment;
|
||||
import com.android.settings.inputmethod.InputAndGestureSettings;
|
||||
import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
|
||||
import com.android.settings.inputmethod.PhysicalKeyboardFragment;
|
||||
import com.android.settings.inputmethod.VirtualKeyboardFragment;
|
||||
import com.android.settings.language.LanguageAndInputSettings;
|
||||
import com.android.settings.location.LocationSettings;
|
||||
import com.android.settings.location.ScanningSettings;
|
||||
import com.android.settings.network.NetworkDashboardFragment;
|
||||
@@ -140,7 +140,7 @@ public final class SearchIndexableResources {
|
||||
addIndex(DoubleTwistGestureSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_gestures);
|
||||
addIndex(SwipeToNotificationSettings.class, NO_DATA_RES_ID,
|
||||
R.drawable.ic_settings_gestures);
|
||||
addIndex(InputAndGestureSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_language);
|
||||
addIndex(LanguageAndInputSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_language);
|
||||
addIndex(LocationSettings.class, R.xml.location_settings, R.drawable.ic_settings_location);
|
||||
addIndex(ScanningSettings.class, R.xml.location_scanning, R.drawable.ic_settings_location);
|
||||
addIndex(SecuritySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_security);
|
||||
|
@@ -14,10 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.inputmethod;
|
||||
package com.android.settings.language;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.input.InputManager;
|
||||
import android.view.textservice.TextServicesManager;
|
||||
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.settings.R;
|
||||
@@ -46,7 +47,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class InputAndGestureSettingsTest {
|
||||
public class LanguageAndInputSettingsTest {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@@ -56,12 +57,14 @@ public class InputAndGestureSettingsTest {
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mContext.getSystemService(Context.INPUT_SERVICE)).thenReturn(mock(InputManager.class));
|
||||
when(mContext.getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE))
|
||||
.thenReturn(mock(TextServicesManager.class));
|
||||
mFragment = new TestFragment(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPreferenceScreenResId() {
|
||||
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(R.xml.input_and_gesture);
|
||||
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(R.xml.language_and_input);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -77,10 +80,17 @@ public class InputAndGestureSettingsTest {
|
||||
.addObserver(any(LifecycleObserver.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPreferenceControllers_shouldAllBeCreated() {
|
||||
final List<PreferenceController> controllers = mFragment.getPreferenceControllers(mContext);
|
||||
|
||||
assertThat(controllers.isEmpty()).isFalse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test fragment to expose lifecycle and context so we can verify behavior for observables.
|
||||
*/
|
||||
public static class TestFragment extends InputAndGestureSettings {
|
||||
public static class TestFragment extends LanguageAndInputSettings {
|
||||
|
||||
private Lifecycle mLifecycle;
|
||||
private Context mContext;
|
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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.language;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.textservice.TextServicesManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class LanguageAndRegionSettingsTest {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
private TestFragment mFragment;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mContext.getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE))
|
||||
.thenReturn(mock(TextServicesManager.class));
|
||||
mFragment = new TestFragment(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPreferenceScreenResId() {
|
||||
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(R.xml.language_and_region);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPreferenceControllers_shouldAllBeCreated() {
|
||||
final List<PreferenceController> controllers = mFragment.getPreferenceControllers(mContext);
|
||||
|
||||
assertThat(controllers.isEmpty()).isFalse();
|
||||
}
|
||||
|
||||
public static class TestFragment extends LanguageAndRegionSettings {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public TestFragment(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getContext() {
|
||||
return mContext;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user