aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java')
-rw-r--r--tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java33
1 files changed, 15 insertions, 18 deletions
diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java
index ec836ccca..0246c49a1 100644
--- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java
+++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java
@@ -17,9 +17,7 @@
package com.android.inputmethod.keyboard;
import android.content.Context;
-import android.content.SharedPreferences;
import android.content.res.Resources;
-import android.preference.PreferenceManager;
import android.test.AndroidTestCase;
import android.view.ContextThemeWrapper;
import android.view.inputmethod.EditorInfo;
@@ -62,8 +60,8 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
}
};
- private SharedPreferences mSharedPreferences;
- private String mSavedAdditionalSubtypes;
+ private RichInputMethodManager mRichImm;
+ private InputMethodSubtype[] mSavedAdditionalSubtypes;
private int mScreenMetrics;
protected abstract int getKeyboardThemeForTests();
@@ -72,26 +70,26 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
protected void setUp() throws Exception {
super.setUp();
final Context context = getContext();
- mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
final Resources res = context.getResources();
+ RichInputMethodManager.init(context);
+ mRichImm = RichInputMethodManager.getInstance();
- // Save additional subtypes preference.
- mSavedAdditionalSubtypes = Settings.readPrefAdditionalSubtypes(mSharedPreferences, res);
- final String predefinedSubtypes = AdditionalSubtypeUtils.createPrefSubtypes(
- res.getStringArray(R.array.predefined_subtypes));
- // Reset additional subtypes to predefined ones.
- Settings.writePrefAdditionalSubtypes(mSharedPreferences, predefinedSubtypes);
+ // Save and reset additional subtypes preference.
+ mSavedAdditionalSubtypes = mRichImm.getAdditionalSubtypes(context);
+ final InputMethodSubtype[] predefinedAdditionalSubtypes =
+ AdditionalSubtypeUtils.createAdditionalSubtypesArray(
+ AdditionalSubtypeUtils.createPrefSubtypes(
+ res.getStringArray(R.array.predefined_subtypes)));
+ mRichImm.setAdditionalInputMethodSubtypes(predefinedAdditionalSubtypes);
final KeyboardTheme keyboardTheme = KeyboardTheme.searchKeyboardThemeById(
getKeyboardThemeForTests(), KeyboardTheme.KEYBOARD_THEMES);
setContext(new ContextThemeWrapper(getContext(), keyboardTheme.mStyleId));
KeyboardLayoutSet.onKeyboardThemeChanged();
- mScreenMetrics = res.getInteger(R.integer.config_screen_metrics);
- RichInputMethodManager.init(context);
- final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
+ mScreenMetrics = Settings.readScreenMetrics(res);
- final InputMethodInfo imi = richImm.getInputMethodInfoOfThisIme();
+ final InputMethodInfo imi = mRichImm.getInputMethodInfoOfThisIme();
final int subtypeCount = imi.getSubtypeCount();
for (int index = 0; index < subtypeCount; index++) {
mAllSubtypesList.add(imi.getSubtypeAt(index));
@@ -101,7 +99,7 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
@Override
protected void tearDown() throws Exception {
// Restore additional subtypes preference.
- Settings.writePrefAdditionalSubtypes(mSharedPreferences, mSavedAdditionalSubtypes);
+ mRichImm.setAdditionalInputMethodSubtypes(mSavedAdditionalSubtypes);
super.tearDown();
}
@@ -121,8 +119,7 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
}
protected final boolean isPhone() {
- return mScreenMetrics == Constants.SCREEN_METRICS_SMALL_PHONE
- || mScreenMetrics == Constants.SCREEN_METRICS_LARGE_PHONE;
+ return Constants.isPhone(mScreenMetrics);
}
protected final InputMethodSubtype getSubtype(final Locale locale,