17e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka/*
27e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka * Copyright (C) 2011 The Android Open Source Project
37e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka *
4ce6bcdd1a547c9874f05a08074cafdfea16196d6Tadashi G. Takaoka * Licensed under the Apache License, Version 2.0 (the "License");
5ce6bcdd1a547c9874f05a08074cafdfea16196d6Tadashi G. Takaoka * you may not use this file except in compliance with the License.
6ce6bcdd1a547c9874f05a08074cafdfea16196d6Tadashi G. Takaoka * You may obtain a copy of the License at
77e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka *
8ce6bcdd1a547c9874f05a08074cafdfea16196d6Tadashi G. Takaoka *      http://www.apache.org/licenses/LICENSE-2.0
97e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka *
107e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka * Unless required by applicable law or agreed to in writing, software
11ce6bcdd1a547c9874f05a08074cafdfea16196d6Tadashi G. Takaoka * distributed under the License is distributed on an "AS IS" BASIS,
12ce6bcdd1a547c9874f05a08074cafdfea16196d6Tadashi G. Takaoka * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13ce6bcdd1a547c9874f05a08074cafdfea16196d6Tadashi G. Takaoka * See the License for the specific language governing permissions and
14ce6bcdd1a547c9874f05a08074cafdfea16196d6Tadashi G. Takaoka * limitations under the License.
157e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka */
167e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka
17a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaokapackage com.android.inputmethod.latin.utils;
187e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka
197e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaokaimport android.content.Context;
2027b42ced86e1c85de3d59d91a9e5c577fa552569Tadashi G. Takaokaimport android.content.res.Resources;
217e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaokaimport android.test.AndroidTestCase;
22b4598f7d05d6afd01ddc7ea0bed71dda837d1debTadashi G. Takaokaimport android.test.suitebuilder.annotation.SmallTest;
237e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaokaimport android.view.inputmethod.InputMethodSubtype;
247e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka
25a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaokaimport com.android.inputmethod.latin.R;
26a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaokaimport com.android.inputmethod.latin.RichInputMethodManager;
27f6972561fcb45310f18230ce217f0c6bb57e7eeeTadashi G. Takaoka
287e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaokaimport java.util.ArrayList;
297e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaokaimport java.util.Locale;
307e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka
31b4598f7d05d6afd01ddc7ea0bed71dda837d1debTadashi G. Takaoka@SmallTest
32a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaokapublic class SubtypeLocaleUtilsTests extends AndroidTestCase {
33f6972561fcb45310f18230ce217f0c6bb57e7eeeTadashi G. Takaoka    // Locale to subtypes list.
345f282ea9e4a4590fcbab6e27d5fca7dacbb40a6aTadashi G. Takaoka    private final ArrayList<InputMethodSubtype> mSubtypesList = CollectionUtils.newArrayList();
357e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka
366fbbab3b8442ad010c53dc53a09535f7b0ef0323Tadashi G. Takaoka    private RichInputMethodManager mRichImm;
3727b42ced86e1c85de3d59d91a9e5c577fa552569Tadashi G. Takaoka    private Resources mRes;
3827b42ced86e1c85de3d59d91a9e5c577fa552569Tadashi G. Takaoka
394b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka    InputMethodSubtype EN_US;
404b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka    InputMethodSubtype EN_GB;
414b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka    InputMethodSubtype ES_US;
424b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka    InputMethodSubtype FR;
434b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka    InputMethodSubtype FR_CA;
444b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka    InputMethodSubtype DE;
454b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka    InputMethodSubtype ZZ;
464b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka    InputMethodSubtype DE_QWERTY;
474b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka    InputMethodSubtype FR_QWERTZ;
488203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    InputMethodSubtype EN_US_AZERTY;
498203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    InputMethodSubtype EN_UK_DVORAK;
508203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    InputMethodSubtype ES_US_COLEMAK;
51e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    InputMethodSubtype ZZ_AZERTY;
528203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    InputMethodSubtype ZZ_PC;
534b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka
547e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka    @Override
557e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka    protected void setUp() throws Exception {
567e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka        super.setUp();
577e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka        final Context context = getContext();
58f90fc105ab1159f43f536bcacdd1224c2c05bacbTadashi G. Takaoka        RichInputMethodManager.init(context);
596fbbab3b8442ad010c53dc53a09535f7b0ef0323Tadashi G. Takaoka        mRichImm = RichInputMethodManager.getInstance();
6027b42ced86e1c85de3d59d91a9e5c577fa552569Tadashi G. Takaoka        mRes = context.getResources();
61a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka        SubtypeLocaleUtils.init(context);
624b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka
634b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka        EN_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
644b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka                Locale.US.toString(), "qwerty");
654b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka        EN_GB = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
664b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka                Locale.UK.toString(), "qwerty");
674b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka        ES_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
684b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka                "es_US", "spanish");
694b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka        FR = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
704b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka                Locale.FRENCH.toString(), "azerty");
714b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka        FR_CA = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
724b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka                Locale.CANADA_FRENCH.toString(), "qwerty");
734b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka        DE = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
744b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka                Locale.GERMAN.toString(), "qwertz");
754b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka        ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
76a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                SubtypeLocaleUtils.NO_LANGUAGE, "qwerty");
77a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka        DE_QWERTY = AdditionalSubtypeUtils.createAdditionalSubtype(
784b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka                Locale.GERMAN.toString(), "qwerty", null);
79a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka        FR_QWERTZ = AdditionalSubtypeUtils.createAdditionalSubtype(
804b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka                Locale.FRENCH.toString(), "qwertz", null);
81a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka        EN_US_AZERTY = AdditionalSubtypeUtils.createAdditionalSubtype(
824b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka                Locale.US.toString(), "azerty", null);
83a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka        EN_UK_DVORAK = AdditionalSubtypeUtils.createAdditionalSubtype(
848203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                Locale.UK.toString(), "dvorak", null);
85a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka        ES_US_COLEMAK = AdditionalSubtypeUtils.createAdditionalSubtype(
868203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                "es_US", "colemak", null);
87a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka        ZZ_AZERTY = AdditionalSubtypeUtils.createAdditionalSubtype(
88a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                SubtypeLocaleUtils.NO_LANGUAGE, "azerty", null);
89a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka        ZZ_PC = AdditionalSubtypeUtils.createAdditionalSubtype(
90a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                SubtypeLocaleUtils.NO_LANGUAGE, "pcqwerty", null);
914b3cae9b0cbd5bf30a1c8da383ff247f9c2afc5aTadashi G. Takaoka
923bf57a5624679a20db26df912077a53b9f90ad36Tadashi G. Takaoka    }
933bf57a5624679a20db26df912077a53b9f90ad36Tadashi G. Takaoka
94f6972561fcb45310f18230ce217f0c6bb57e7eeeTadashi G. Takaoka    public void testAllFullDisplayName() {
953bf57a5624679a20db26df912077a53b9f90ad36Tadashi G. Takaoka        for (final InputMethodSubtype subtype : mSubtypesList) {
96a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            final String subtypeName =
97a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                    SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype);
98a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
9927b42ced86e1c85de3d59d91a9e5c577fa552569Tadashi G. Takaoka                final String noLanguage = mRes.getString(R.string.subtype_no_language);
10027b42ced86e1c85de3d59d91a9e5c577fa552569Tadashi G. Takaoka                assertTrue(subtypeName, subtypeName.contains(noLanguage));
10127b42ced86e1c85de3d59d91a9e5c577fa552569Tadashi G. Takaoka            } else {
10227b42ced86e1c85de3d59d91a9e5c577fa552569Tadashi G. Takaoka                final String languageName =
103a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeLocaleDisplayName(subtype.getLocale());
10427b42ced86e1c85de3d59d91a9e5c577fa552569Tadashi G. Takaoka                assertTrue(subtypeName, subtypeName.contains(languageName));
1055cb4eaeec01eee8eed2c8746a95bb53151ef4e74Tadashi G. Takaoka            }
1067e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka        }
1077e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka    }
1083bf57a5624679a20db26df912077a53b9f90ad36Tadashi G. Takaoka
109e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    public void testKeyboardLayoutSetName() {
110a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka        assertEquals("en_US", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(EN_US));
111a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka        assertEquals("en_GB", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(EN_GB));
112a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka        assertEquals("es_US", "spanish", SubtypeLocaleUtils.getKeyboardLayoutSetName(ES_US));
113a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka        assertEquals("fr   ", "azerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(FR));
114a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka        assertEquals("fr_CA", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(FR_CA));
115a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka        assertEquals("de   ", "qwertz", SubtypeLocaleUtils.getKeyboardLayoutSetName(DE));
116a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka        assertEquals("zz   ", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(ZZ));
1178203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    }
1188203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka
1198203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    // InputMethodSubtype's display name in system locale (en_US).
1208203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //        isAdditionalSubtype (T=true, F=false)
1218203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    // locale layout  |  display name
1228203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    // ------ ------- - ----------------------
1238203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  en_US qwerty  F  English (US)            exception
1248203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  en_GB qwerty  F  English (UK)            exception
1258203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  es_US spanish F  Spanish (US)            exception
1268203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  fr    azerty  F  French
1278203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  fr_CA qwerty  F  French (Canada)
1288203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  de    qwertz  F  German
129c5beb522ed954d372a4a1e3f38db7b56d37eb820Jean Chalard    //  zz    qwerty  F  Alphabet (QWERTY)
1308203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  fr    qwertz  T  French (QWERTZ)
1318203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  de    qwerty  T  German (QWERTY)
1328203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  en_US azerty  T  English (US) (AZERTY)   exception
1338203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  en_UK dvorak  T  English (UK) (Dvorak)   exception
1348203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  es_US colemak T  Spanish (US) (Colemak)  exception
135c5beb522ed954d372a4a1e3f38db7b56d37eb820Jean Chalard    //  zz    pc      T  Alphabet (PC)
1368203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka
1378203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    public void testPredefinedSubtypesInEnglishSystemLocale() {
1388203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka        final RunInLocale<Void> tests = new RunInLocale<Void>() {
1398203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka            @Override
1400c3a9b549c3ff9bdf47c52cf59347f7e111dd183Tadashi G. Takaoka            protected Void job(final Resources res) {
1418203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("en_US", "English (US)",
142a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(EN_US));
1438203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("en_GB", "English (UK)",
144a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(EN_GB));
1458203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("es_US", "Spanish (US)",
146a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ES_US));
1478203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("fr   ", "French",
148a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(FR));
1498203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("fr_CA", "French (Canada)",
150a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(FR_CA));
1518203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("de   ", "German",
152a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE));
153c5beb522ed954d372a4a1e3f38db7b56d37eb820Jean Chalard                assertEquals("zz   ", "Alphabet (QWERTY)",
154a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ));
1558203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                return null;
1568203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka            }
1578203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka        };
1588203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka        tests.runInLocale(mRes, Locale.ENGLISH);
1598203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    }
1608203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka
1618203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    public void testAdditionalSubtypesInEnglishSystemLocale() {
1628203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka        final RunInLocale<Void> tests = new RunInLocale<Void>() {
1638203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka            @Override
1640c3a9b549c3ff9bdf47c52cf59347f7e111dd183Tadashi G. Takaoka            protected Void job(final Resources res) {
1658203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("fr qwertz",    "French (QWERTZ)",
166a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(FR_QWERTZ));
1678203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("de qwerty",    "German (QWERTY)",
168a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE_QWERTY));
1698203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("en_US azerty", "English (US) (AZERTY)",
170a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(EN_US_AZERTY));
1718203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("en_UK dvorak", "English (UK) (Dvorak)",
172a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(EN_UK_DVORAK));
1738203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("es_US colemak","Spanish (US) (Colemak)",
174a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ES_US_COLEMAK));
175c5beb522ed954d372a4a1e3f38db7b56d37eb820Jean Chalard                assertEquals("zz pc",    "Alphabet (PC)",
176a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ_PC));
1778203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                return null;
1788203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka            }
1798203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka        };
1808203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka        tests.runInLocale(mRes, Locale.ENGLISH);
1818203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    }
1828203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka
1838203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    // InputMethodSubtype's display name in system locale (fr).
1848203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //        isAdditionalSubtype (T=true, F=false)
1858203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    // locale layout  |  display name
1868203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    // ------ ------- - ----------------------
1878203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  en_US qwerty  F  Anglais (États-Unis)            exception
1888203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  en_GB qwerty  F  Anglais (Royaume-Uni)            exception
1898203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  es_US spanish F  Espagnol (États-Unis)            exception
1908203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  fr    azerty  F  Français
1918203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  fr_CA qwerty  F  Français (Canada)
1928203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  de    qwertz  F  Allemand
19367a54c4bbe4a6a097a4ceacfd67667000c70e595Tadashi G. Takaoka    //  zz    qwerty  F  Aucune langue (QWERTY)
1948203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  fr    qwertz  T  Français (QWERTZ)
1958203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  de    qwerty  T  Allemand (QWERTY)
1968203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  en_US azerty  T  Anglais (États-Unis) (AZERTY)   exception
1978203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  en_UK dvorak  T  Anglais (Royaume-Uni) (Dvorak)   exception
1988203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    //  es_US colemak T  Espagnol (États-Unis) (Colemak)  exception
199c5beb522ed954d372a4a1e3f38db7b56d37eb820Jean Chalard    //  zz    pc      T  Alphabet (PC)
2008203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka
2018203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    public void testPredefinedSubtypesInFrenchSystemLocale() {
2028203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka        final RunInLocale<Void> tests = new RunInLocale<Void>() {
2038203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka            @Override
2040c3a9b549c3ff9bdf47c52cf59347f7e111dd183Tadashi G. Takaoka            protected Void job(final Resources res) {
2058203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("en_US", "Anglais (États-Unis)",
206a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(EN_US));
2078203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("en_GB", "Anglais (Royaume-Uni)",
208a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(EN_GB));
2098203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("es_US", "Espagnol (États-Unis)",
210a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ES_US));
2118203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("fr   ", "Français",
212a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(FR));
2138203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("fr_CA", "Français (Canada)",
214a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(FR_CA));
2158203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("de   ", "Allemand",
216a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE));
2175080983ea6c54acffc4c653df03179101a08ccd3Tadashi G. Takaoka                assertEquals("zz   ", "Alphabet latin (QWERTY)",
218a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ));
2198203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                return null;
2208203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka            }
2218203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka        };
2228203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka        tests.runInLocale(mRes, Locale.FRENCH);
2238203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    }
2248203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka
2258203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka    public void testAdditionalSubtypesInFrenchSystemLocale() {
2268203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka        final RunInLocale<Void> tests = new RunInLocale<Void>() {
2278203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka            @Override
2280c3a9b549c3ff9bdf47c52cf59347f7e111dd183Tadashi G. Takaoka            protected Void job(final Resources res) {
2298203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("fr qwertz",    "Français (QWERTZ)",
230a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(FR_QWERTZ));
2318203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("de qwerty",    "Allemand (QWERTY)",
232a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE_QWERTY));
2338203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("en_US azerty", "Anglais (États-Unis) (AZERTY)",
234a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(EN_US_AZERTY));
2358203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("en_UK dvorak", "Anglais (Royaume-Uni) (Dvorak)",
236a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(EN_UK_DVORAK));
2378203f7afe7c885e185f8633a89960a78a69ac647Tadashi G. Takaoka                assertEquals("es_US colemak","Espagnol (États-Unis) (Colemak)",
238a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ES_US_COLEMAK));
2395080983ea6c54acffc4c653df03179101a08ccd3Tadashi G. Takaoka                assertEquals("zz pc",    "Alphabet latin (PC)",
240a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ_PC));
24127b42ced86e1c85de3d59d91a9e5c577fa552569Tadashi G. Takaoka                return null;
24227b42ced86e1c85de3d59d91a9e5c577fa552569Tadashi G. Takaoka            }
24327b42ced86e1c85de3d59d91a9e5c577fa552569Tadashi G. Takaoka        };
24427b42ced86e1c85de3d59d91a9e5c577fa552569Tadashi G. Takaoka        tests.runInLocale(mRes, Locale.FRENCH);
2453bf57a5624679a20db26df912077a53b9f90ad36Tadashi G. Takaoka    }
246e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka
247e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    public void testAllFullDisplayNameForSpacebar() {
248e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka        for (final InputMethodSubtype subtype : mSubtypesList) {
249a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            final String subtypeName =
250a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                    SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype);
251a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            final String spacebarText = SubtypeLocaleUtils.getFullDisplayName(subtype);
252e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            final String languageName =
253a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                    SubtypeLocaleUtils.getSubtypeLocaleDisplayName(subtype.getLocale());
254a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
255e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka                assertFalse(subtypeName, spacebarText.contains(languageName));
256e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            } else {
257e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka                assertTrue(subtypeName, spacebarText.contains(languageName));
258e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            }
259e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka        }
260e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    }
261e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka
262e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka   public void testAllMiddleDisplayNameForSpacebar() {
263e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka        for (final InputMethodSubtype subtype : mSubtypesList) {
264a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            final String subtypeName =
265a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                    SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype);
266a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            final String spacebarText = SubtypeLocaleUtils.getMiddleDisplayName(subtype);
267a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
268e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka                assertEquals(subtypeName,
269a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype), spacebarText);
270e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            } else {
271e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka                assertEquals(subtypeName,
272a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                        SubtypeLocaleUtils.getSubtypeLocaleDisplayName(subtype.getLocale()),
273e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka                        spacebarText);
274e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            }
275e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka        }
276e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    }
277e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka
278e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    public void testAllShortDisplayNameForSpacebar() {
279e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka        for (final InputMethodSubtype subtype : mSubtypesList) {
280a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            final String subtypeName =
281a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                    SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype);
282a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            final Locale locale = SubtypeLocaleUtils.getSubtypeLocale(subtype);
283a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            final String spacebarText = SubtypeLocaleUtils.getShortDisplayName(subtype);
284e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            final String languageCode = StringUtils.capitalizeFirstCodePoint(
285e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka                    locale.getLanguage(), locale);
286a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
287e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka                assertEquals(subtypeName, "", spacebarText);
288e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            } else {
289e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka                assertEquals(subtypeName, languageCode, spacebarText);
290e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            }
291e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka        }
292e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    }
293e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka
294e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    // InputMethodSubtype's display name for spacebar text in its locale.
295e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    //        isAdditionalSubtype (T=true, F=false)
296e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    // locale layout  | Short  Middle      Full
297e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    // ------ ------- - ---- --------- ----------------------
298e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    //  en_US qwerty  F  En  English   English (US)           exception
299e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    //  en_GB qwerty  F  En  English   English (UK)           exception
300e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    //  es_US spanish F  Es  Español   Español (EE.UU.)       exception
301e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    //  fr    azerty  F  Fr  Français  Français
302e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    //  fr_CA qwerty  F  Fr  Français  Français (Canada)
303e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    //  de    qwertz  F  De  Deutsch   Deutsch
304e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    //  zz    qwerty  F      QWERTY    QWERTY
305e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    //  fr    qwertz  T  Fr  Français  Français
306e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    //  de    qwerty  T  De  Deutsch   Deutsch
307e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    //  en_US azerty  T  En  English   English (US)
308e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    //  zz    azerty  T      AZERTY    AZERTY
309e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka
310e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    private final RunInLocale<Void> testsPredefinedSubtypesForSpacebar = new RunInLocale<Void>() {
311e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka        @Override
3120c3a9b549c3ff9bdf47c52cf59347f7e111dd183Tadashi G. Takaoka        protected Void job(final Resources res) {
313a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("en_US", "English (US)", SubtypeLocaleUtils.getFullDisplayName(EN_US));
314a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("en_GB", "English (UK)", SubtypeLocaleUtils.getFullDisplayName(EN_GB));
315a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("es_US", "Español (EE.UU.)",
316a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                    SubtypeLocaleUtils.getFullDisplayName(ES_US));
317a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("fr   ", "Français",     SubtypeLocaleUtils.getFullDisplayName(FR));
318a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("fr_CA", "Français (Canada)",
319a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                    SubtypeLocaleUtils.getFullDisplayName(FR_CA));
320a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("de   ", "Deutsch",      SubtypeLocaleUtils.getFullDisplayName(DE));
321a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("zz   ", "QWERTY",       SubtypeLocaleUtils.getFullDisplayName(ZZ));
322a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka
323a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("en_US", "English",  SubtypeLocaleUtils.getMiddleDisplayName(EN_US));
324a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("en_GB", "English",  SubtypeLocaleUtils.getMiddleDisplayName(EN_GB));
325a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("es_US", "Español",  SubtypeLocaleUtils.getMiddleDisplayName(ES_US));
326a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("fr   ", "Français", SubtypeLocaleUtils.getMiddleDisplayName(FR));
327a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("fr_CA", "Français", SubtypeLocaleUtils.getMiddleDisplayName(FR_CA));
328a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("de   ", "Deutsch",  SubtypeLocaleUtils.getMiddleDisplayName(DE));
329a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("zz   ", "QWERTY",   SubtypeLocaleUtils.getMiddleDisplayName(ZZ));
330a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka
331a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("en_US", "En", SubtypeLocaleUtils.getShortDisplayName(EN_US));
332a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("en_GB", "En", SubtypeLocaleUtils.getShortDisplayName(EN_GB));
333a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("es_US", "Es", SubtypeLocaleUtils.getShortDisplayName(ES_US));
334a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("fr   ", "Fr", SubtypeLocaleUtils.getShortDisplayName(FR));
335a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("fr_CA", "Fr", SubtypeLocaleUtils.getShortDisplayName(FR_CA));
336a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("de   ", "De", SubtypeLocaleUtils.getShortDisplayName(DE));
337a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("zz   ", "",   SubtypeLocaleUtils.getShortDisplayName(ZZ));
338e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            return null;
339e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka        }
340e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    };
341e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka
342e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    private final RunInLocale<Void> testsAdditionalSubtypesForSpacebar = new RunInLocale<Void>() {
343e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka        @Override
3440c3a9b549c3ff9bdf47c52cf59347f7e111dd183Tadashi G. Takaoka        protected Void job(final Resources res) {
345e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            assertEquals("fr qwertz",    "Français",
346a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                    SubtypeLocaleUtils.getFullDisplayName(FR_QWERTZ));
347e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            assertEquals("de qwerty",    "Deutsch",
348a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                    SubtypeLocaleUtils.getFullDisplayName(DE_QWERTY));
349e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            assertEquals("en_US azerty", "English (US)",
350a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                    SubtypeLocaleUtils.getFullDisplayName(EN_US_AZERTY));
351e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            assertEquals("zz azerty",    "AZERTY",
352a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                    SubtypeLocaleUtils.getFullDisplayName(ZZ_AZERTY));
353e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka
354e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            assertEquals("fr qwertz",    "Français",
355a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                    SubtypeLocaleUtils.getMiddleDisplayName(FR_QWERTZ));
356e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            assertEquals("de qwerty",    "Deutsch",
357a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                    SubtypeLocaleUtils.getMiddleDisplayName(DE_QWERTY));
358e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            assertEquals("en_US azerty", "English",
359a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                    SubtypeLocaleUtils.getMiddleDisplayName(EN_US_AZERTY));
360e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            assertEquals("zz azerty",    "AZERTY",
361a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                    SubtypeLocaleUtils.getMiddleDisplayName(ZZ_AZERTY));
362e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka
363a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("fr qwertz",    "Fr", SubtypeLocaleUtils.getShortDisplayName(FR_QWERTZ));
364a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("de qwerty",    "De", SubtypeLocaleUtils.getShortDisplayName(DE_QWERTY));
365a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("en_US azerty", "En",
366a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka                    SubtypeLocaleUtils.getShortDisplayName(EN_US_AZERTY));
367a410cb48eab0cd75aa27e20f60e47a29a59fb9ffTadashi G. Takaoka            assertEquals("zz azerty",    "",   SubtypeLocaleUtils.getShortDisplayName(ZZ_AZERTY));
368e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka            return null;
369e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka        }
370e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    };
371e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka
372e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    public void testPredefinedSubtypesForSpacebarInEnglish() {
373e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka        testsPredefinedSubtypesForSpacebar.runInLocale(mRes, Locale.ENGLISH);
374e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    }
375e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka
376e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    public void testAdditionalSubtypeForSpacebarInEnglish() {
377e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka        testsAdditionalSubtypesForSpacebar.runInLocale(mRes, Locale.ENGLISH);
378e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    }
379e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka
380e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    public void testPredefinedSubtypesForSpacebarInFrench() {
381e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka        testsPredefinedSubtypesForSpacebar.runInLocale(mRes, Locale.FRENCH);
382e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    }
383e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka
384e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    public void testAdditionalSubtypeForSpacebarInFrench() {
385e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka        testsAdditionalSubtypesForSpacebar.runInLocale(mRes, Locale.FRENCH);
386e6c51847426121246cc8b48f42f8f5668db71cdbTadashi G. Takaoka    }
3877e438300db9b36c00597fccb95cbbc9cc5baf029Tadashi G. Takaoka}
388