Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 94af6d9e authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka Committed by Android (Google) Code Review
Browse files

Merge "Make unit test independent from test device locale"

parents d99abf8c 8586a434
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -17,10 +17,13 @@
package com.android.inputmethod.keyboard.internal;

import android.app.Instrumentation;
import android.content.Context;
import android.content.res.Resources;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.MediumTest;

import com.android.inputmethod.latin.CollectionUtils;
import com.android.inputmethod.latin.LocaleUtils.RunInLocale;

import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -29,15 +32,23 @@ import java.util.Locale;

@MediumTest
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
    protected void setUp() throws Exception {
        super.setUp();

        final Instrumentation instrumentation = getInstrumentation();
        mTextsSet.setLanguage(Locale.ENGLISH.getLanguage());
        mTextsSet.loadStringResources(instrumentation.getTargetContext());
        final Context targetContext = 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(
                com.android.inputmethod.latin.tests.R.string.class);
        mTextsSet.loadStringResourcesInternal(instrumentation.getContext(),
+15 −4
Original line number Diff line number Diff line
@@ -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_UNSPECIFIED;

import android.content.Context;
import android.content.res.Resources;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;

import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.LocaleUtils.RunInLocale;

import java.util.Arrays;
import java.util.Locale;

@SmallTest
public class KeySpecParserTests extends AndroidTestCase {
    private final KeyboardCodesSet mCodesSet = new KeyboardCodesSet();
    private final KeyboardTextsSet mTextsSet = new KeyboardTextsSet();
    private final static Locale TEST_LOCALE = Locale.ENGLISH;
    final KeyboardCodesSet mCodesSet = new KeyboardCodesSet();
    final KeyboardTextsSet mTextsSet = new KeyboardTextsSet();

    private static final String CODE_SETTINGS = "!code/key_settings";
    private static final String ICON_SETTINGS = "!icon/settings_key";
@@ -48,10 +52,17 @@ public class KeySpecParserTests extends AndroidTestCase {
    protected void setUp() throws Exception {
        super.setUp();

        final String language = Locale.ENGLISH.getLanguage();
        final String language = TEST_LOCALE.getLanguage();
        mCodesSet.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(
                CODE_SETTINGS, mCodesSet, CODE_UNSPECIFIED);