am 94af6d9e: Merge "Make unit test independent from test device locale"
* commit '94af6d9e7f779fad4886d70fcac26844ecdc0c15': Make unit test independent from test device localemain
commit
f4e557c941
|
@ -17,10 +17,13 @@
|
||||||
package com.android.inputmethod.keyboard.internal;
|
package com.android.inputmethod.keyboard.internal;
|
||||||
|
|
||||||
import android.app.Instrumentation;
|
import android.app.Instrumentation;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.test.InstrumentationTestCase;
|
import android.test.InstrumentationTestCase;
|
||||||
import android.test.suitebuilder.annotation.MediumTest;
|
import android.test.suitebuilder.annotation.MediumTest;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.CollectionUtils;
|
import com.android.inputmethod.latin.CollectionUtils;
|
||||||
|
import com.android.inputmethod.latin.LocaleUtils.RunInLocale;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -29,15 +32,23 @@ import java.util.Locale;
|
||||||
|
|
||||||
@MediumTest
|
@MediumTest
|
||||||
public class KeySpecParserSplitTests extends InstrumentationTestCase {
|
public class KeySpecParserSplitTests extends InstrumentationTestCase {
|
||||||
private final KeyboardTextsSet mTextsSet = new KeyboardTextsSet();
|
private static final Locale TEST_LOCALE = Locale.ENGLISH;
|
||||||
|
final KeyboardTextsSet mTextsSet = new KeyboardTextsSet();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
final Instrumentation instrumentation = getInstrumentation();
|
final Instrumentation instrumentation = getInstrumentation();
|
||||||
mTextsSet.setLanguage(Locale.ENGLISH.getLanguage());
|
final Context targetContext = instrumentation.getTargetContext();
|
||||||
mTextsSet.loadStringResources(instrumentation.getTargetContext());
|
mTextsSet.setLanguage(TEST_LOCALE.getLanguage());
|
||||||
|
new RunInLocale<Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void job(final Resources res) {
|
||||||
|
mTextsSet.loadStringResources(targetContext);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}.runInLocale(targetContext.getResources(), TEST_LOCALE);
|
||||||
final String[] testResourceNames = getAllResourceIdNames(
|
final String[] testResourceNames = getAllResourceIdNames(
|
||||||
com.android.inputmethod.latin.tests.R.string.class);
|
com.android.inputmethod.latin.tests.R.string.class);
|
||||||
mTextsSet.loadStringResourcesInternal(instrumentation.getContext(),
|
mTextsSet.loadStringResourcesInternal(instrumentation.getContext(),
|
||||||
|
|
|
@ -20,18 +20,22 @@ import static com.android.inputmethod.keyboard.internal.KeyboardIconsSet.ICON_UN
|
||||||
import static com.android.inputmethod.latin.Constants.CODE_OUTPUT_TEXT;
|
import static com.android.inputmethod.latin.Constants.CODE_OUTPUT_TEXT;
|
||||||
import static com.android.inputmethod.latin.Constants.CODE_UNSPECIFIED;
|
import static com.android.inputmethod.latin.Constants.CODE_UNSPECIFIED;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.Constants;
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
import com.android.inputmethod.latin.LocaleUtils.RunInLocale;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class KeySpecParserTests extends AndroidTestCase {
|
public class KeySpecParserTests extends AndroidTestCase {
|
||||||
private final KeyboardCodesSet mCodesSet = new KeyboardCodesSet();
|
private final static Locale TEST_LOCALE = Locale.ENGLISH;
|
||||||
private final KeyboardTextsSet mTextsSet = new KeyboardTextsSet();
|
final KeyboardCodesSet mCodesSet = new KeyboardCodesSet();
|
||||||
|
final KeyboardTextsSet mTextsSet = new KeyboardTextsSet();
|
||||||
|
|
||||||
private static final String CODE_SETTINGS = "!code/key_settings";
|
private static final String CODE_SETTINGS = "!code/key_settings";
|
||||||
private static final String ICON_SETTINGS = "!icon/settings_key";
|
private static final String ICON_SETTINGS = "!icon/settings_key";
|
||||||
|
@ -48,10 +52,17 @@ public class KeySpecParserTests extends AndroidTestCase {
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
final String language = Locale.ENGLISH.getLanguage();
|
final String language = TEST_LOCALE.getLanguage();
|
||||||
mCodesSet.setLanguage(language);
|
mCodesSet.setLanguage(language);
|
||||||
mTextsSet.setLanguage(language);
|
mTextsSet.setLanguage(language);
|
||||||
mTextsSet.loadStringResources(getContext());
|
final Context context = getContext();
|
||||||
|
new RunInLocale<Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void job(final Resources res) {
|
||||||
|
mTextsSet.loadStringResources(context);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}.runInLocale(context.getResources(), TEST_LOCALE);
|
||||||
|
|
||||||
mCodeSettings = KeySpecParser.parseCode(
|
mCodeSettings = KeySpecParser.parseCode(
|
||||||
CODE_SETTINGS, mCodesSet, CODE_UNSPECIFIED);
|
CODE_SETTINGS, mCodesSet, CODE_UNSPECIFIED);
|
||||||
|
|
Loading…
Reference in New Issue