13da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka/*
23da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka * Copyright (C) 2014 The Android Open Source Project
33da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka *
43da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka * Licensed under the Apache License, Version 2.0 (the "License");
53da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka * you may not use this file except in compliance with the License.
63da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka * You may obtain a copy of the License at
73da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka *
83da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka *      http://www.apache.org/licenses/LICENSE-2.0
93da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka *
103da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka * Unless required by applicable law or agreed to in writing, software
113da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka * distributed under the License is distributed on an "AS IS" BASIS,
123da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
133da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka * See the License for the specific language governing permissions and
143da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka * limitations under the License.
153da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka */
163da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka
1788984aedae83d15b47a22f2716c8d01b1fa7f4d8Tadashi G. Takaokapackage com.android.inputmethod.keyboard.action;
183da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka
193da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaokaimport android.content.res.Resources;
203da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaokaimport android.test.suitebuilder.annotation.MediumTest;
213da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaokaimport android.view.inputmethod.EditorInfo;
223da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaokaimport android.view.inputmethod.InputMethodSubtype;
233da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka
2488984aedae83d15b47a22f2716c8d01b1fa7f4d8Tadashi G. Takaokaimport com.android.inputmethod.keyboard.KeyboardLayoutSet;
253da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaokaimport com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
26aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaokaimport com.android.inputmethod.keyboard.internal.KeyboardTextsSet;
273da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaokaimport com.android.inputmethod.latin.R;
285f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaokaimport com.android.inputmethod.latin.RichInputMethodManager;
293da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaokaimport com.android.inputmethod.latin.utils.RunInLocale;
303da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaokaimport com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
313da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka
325f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaokaimport java.util.Locale;
335f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka
343da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka@MediumTest
3588984aedae83d15b47a22f2716c8d01b1fa7f4d8Tadashi G. Takaokapublic class KlpActionLabelTests extends KlpActionTestsBase {
3688984aedae83d15b47a22f2716c8d01b1fa7f4d8Tadashi G. Takaoka    void doTestActionKeys(final InputMethodSubtype subtype, final String tag,
3751333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka            final ExpectedActionKey unspecifiedKey, final ExpectedActionKey noneKey,
3851333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka            final ExpectedActionKey goKey, final ExpectedActionKey searchKey,
3951333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka            final ExpectedActionKey sendKey, final ExpectedActionKey nextKey,
4051333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka            final ExpectedActionKey doneKey, final ExpectedActionKey previousKey) {
4151333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka        doTestActionKey(
4251333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka                tag + " unspecified", subtype, EditorInfo.IME_ACTION_UNSPECIFIED, unspecifiedKey);
4351333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka        doTestActionKey(tag + " none", subtype, EditorInfo.IME_ACTION_NONE, noneKey);
4451333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka        doTestActionKey(tag + " go", subtype, EditorInfo.IME_ACTION_GO, goKey);
4551333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka        doTestActionKey(tag + " search", subtype, EditorInfo.IME_ACTION_SEARCH, searchKey);
4651333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka        doTestActionKey(tag + " send", subtype, EditorInfo.IME_ACTION_SEND, sendKey);
4751333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka        doTestActionKey(tag + " next", subtype, EditorInfo.IME_ACTION_NEXT, nextKey);
4851333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka        doTestActionKey(tag + " done", subtype, EditorInfo.IME_ACTION_DONE, doneKey);
4951333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka        doTestActionKey(tag + " previous", subtype, EditorInfo.IME_ACTION_PREVIOUS, previousKey);
5051333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka    }
5151333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka
52f2eadbb497a172f602e49226a7f891d9e9097760Tadashi G. Takaoka    // Working variable to simulate system locale changing.
53f2eadbb497a172f602e49226a7f891d9e9097760Tadashi G. Takaoka    private Locale mSystemLocale = Locale.getDefault();
54f2eadbb497a172f602e49226a7f891d9e9097760Tadashi G. Takaoka
55aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka    private void doTestActionKeysInLocaleWithStringResources(final InputMethodSubtype subtype,
565f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka            final Locale labelLocale, final Locale systemLocale) {
57f2eadbb497a172f602e49226a7f891d9e9097760Tadashi G. Takaoka        // Simulate system locale changing, see {@link SystemBroadcastReceiver}.
58f2eadbb497a172f602e49226a7f891d9e9097760Tadashi G. Takaoka        if (!systemLocale.equals(mSystemLocale)) {
59f2eadbb497a172f602e49226a7f891d9e9097760Tadashi G. Takaoka            KeyboardLayoutSet.onSystemLocaleChanged();
60f2eadbb497a172f602e49226a7f891d9e9097760Tadashi G. Takaoka            mSystemLocale = systemLocale;
61f2eadbb497a172f602e49226a7f891d9e9097760Tadashi G. Takaoka        }
6251333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka        final ExpectedActionKey enterKey = ExpectedActionKey.newIconKey(
6351333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka                KeyboardIconsSet.NAME_ENTER_KEY);
6451333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka        final ExpectedActionKey goKey = ExpectedActionKey.newLabelKey(
6551333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka                R.string.label_go_key, labelLocale, getContext());
6651333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka        final ExpectedActionKey searchKey = ExpectedActionKey.newIconKey(
6751333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka                KeyboardIconsSet.NAME_SEARCH_KEY);
6851333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka        final ExpectedActionKey sendKey = ExpectedActionKey.newLabelKey(
6951333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka                R.string.label_send_key, labelLocale, getContext());
7051333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka        final ExpectedActionKey nextKey = ExpectedActionKey.newLabelKey(
7151333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka                R.string.label_next_key, labelLocale, getContext());
7251333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka        final ExpectedActionKey doneKey = ExpectedActionKey.newLabelKey(
7351333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka                R.string.label_done_key, labelLocale, getContext());
7451333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka        final ExpectedActionKey previousKey = ExpectedActionKey.newLabelKey(
7551333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka                R.string.label_previous_key, labelLocale, getContext());
765f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka        final String tag = "label=" + labelLocale + " system=" + systemLocale
775f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka                + " " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype);
785f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka        final RunInLocale<Void> job = new RunInLocale<Void>() {
795f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka            @Override
805f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka            public Void job(final Resources res) {
8151333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka                doTestActionKeys(subtype, tag, enterKey, enterKey, goKey, searchKey, sendKey,
8251333ba4c36726a2f7acff859cd8ffb782e8f2b3Tadashi G. Takaoka                        nextKey, doneKey, previousKey);
835f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka                return null;
845f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka            }
855f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka        };
865f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka        job.runInLocale(getContext().getResources(), systemLocale);
875f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka    }
885f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka
895f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka    public void testActionLabelInOtherLocale() {
905f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka        final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
915f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka        final InputMethodSubtype italian = richImm.findSubtypeByLocaleAndKeyboardLayoutSet(
925f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka                Locale.ITALIAN.toString(), SubtypeLocaleUtils.QWERTY);
935f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka        // An action label should be displayed in subtype's locale regardless of the system locale.
94aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        doTestActionKeysInLocaleWithStringResources(italian, Locale.ITALIAN, Locale.US);
95aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        doTestActionKeysInLocaleWithStringResources(italian, Locale.ITALIAN, Locale.FRENCH);
96aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        doTestActionKeysInLocaleWithStringResources(italian, Locale.ITALIAN, Locale.ITALIAN);
97aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        doTestActionKeysInLocaleWithStringResources(italian, Locale.ITALIAN, Locale.JAPANESE);
985f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka    }
995f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka
1005f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka    public void testNoLanguageSubtypeActionLabel() {
1015f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka        final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
1025f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka        final InputMethodSubtype noLanguage = richImm.findSubtypeByLocaleAndKeyboardLayoutSet(
1035f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka                SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.QWERTY);
1045f19606d54266e55bb065880c77a74b1d47a52c8Tadashi G. Takaoka        // An action label of no language keyboard should be displayed in the system locale.
105aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        doTestActionKeysInLocaleWithStringResources(noLanguage, Locale.US, Locale.US);
106aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        doTestActionKeysInLocaleWithStringResources(noLanguage, Locale.FRENCH, Locale.FRENCH);
107aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        doTestActionKeysInLocaleWithStringResources(noLanguage, Locale.ITALIAN, Locale.ITALIAN);
108aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        doTestActionKeysInLocaleWithStringResources(noLanguage, Locale.JAPANESE, Locale.JAPANESE);
109aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka    }
110aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka
111aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka    private void doTestActionKeysInLocaleWithKeyboardTextsSet(final InputMethodSubtype subtype,
112aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka            final Locale labelLocale, final Locale systemLocale) {
113aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        // Simulate system locale changing, see {@link SystemBroadcastReceiver}.
114aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        if (!systemLocale.equals(mSystemLocale)) {
115aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka            KeyboardLayoutSet.onSystemLocaleChanged();
116aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka            mSystemLocale = systemLocale;
117aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        }
118aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        final KeyboardTextsSet textsSet = new KeyboardTextsSet();
119aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        textsSet.setLocale(labelLocale, getContext());
120aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        final ExpectedActionKey enterKey = ExpectedActionKey.newIconKey(
121aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka                KeyboardIconsSet.NAME_ENTER_KEY);
122aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        final ExpectedActionKey goKey = ExpectedActionKey.newLabelKey(
123aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka                textsSet.getText("label_go_key"));
124aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        final ExpectedActionKey searchKey = ExpectedActionKey.newIconKey(
125aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka                KeyboardIconsSet.NAME_SEARCH_KEY);
126aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        final ExpectedActionKey sendKey = ExpectedActionKey.newLabelKey(
127aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka                textsSet.getText("label_send_key"));
128aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        final ExpectedActionKey nextKey = ExpectedActionKey.newLabelKey(
129aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka                textsSet.getText("label_next_key"));
130aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        final ExpectedActionKey doneKey = ExpectedActionKey.newLabelKey(
131aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka                textsSet.getText("label_done_key"));
132aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        final ExpectedActionKey previousKey = ExpectedActionKey.newLabelKey(
133aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka                textsSet.getText("label_previous_key"));
134162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        final String tag = "label=" + subtype.getLocale() + " system=" + systemLocale
135aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka                + " " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype);
136aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        final RunInLocale<Void> job = new RunInLocale<Void>() {
137aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka            @Override
138aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka            public Void job(final Resources res) {
139aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka                doTestActionKeys(subtype, tag, enterKey, enterKey, goKey, searchKey, sendKey,
140aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka                        nextKey, doneKey, previousKey);
141aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka                return null;
142aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka            }
143aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        };
144aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        job.runInLocale(getContext().getResources(), systemLocale);
145aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka    }
146aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka
147aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka    public void testHinglishActionLabel() {
148aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
149aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        final Locale hi_ZZ = new Locale("hi", "ZZ");
150162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        final InputMethodSubtype hiLatn = richImm.findSubtypeByLocaleAndKeyboardLayoutSet(
151aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka                hi_ZZ.toString(), SubtypeLocaleUtils.QWERTY);
152162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        // This is a preliminary subtype and may not exist.
153162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        if (hiLatn == null) {
154162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka            return;
155162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        }
156aaefd5666112c4a6fff58783c25cf9a75b468eddTadashi G. Takaoka        // An action label should be displayed in subtype's locale regardless of the system locale.
157162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, new Locale("hi"));
158162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, Locale.US);
159162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, Locale.FRENCH);
160162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, Locale.ITALIAN);
161162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, Locale.JAPANESE);
162c5dc74067385f9ab6ec3086825d0b369c26a1ea3Tadashi G. Takaoka    }
1638108a3e1cdceb1874804f74ec24d824a7df1b669Tadashi G. Takaoka
1648108a3e1cdceb1874804f74ec24d824a7df1b669Tadashi G. Takaoka    public void testSerbianLatinActionLabel() {
1658108a3e1cdceb1874804f74ec24d824a7df1b669Tadashi G. Takaoka        final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
1668108a3e1cdceb1874804f74ec24d824a7df1b669Tadashi G. Takaoka        final Locale sr_ZZ = new Locale("sr", "ZZ");
167162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        final InputMethodSubtype srLatn = richImm.findSubtypeByLocaleAndKeyboardLayoutSet(
1688108a3e1cdceb1874804f74ec24d824a7df1b669Tadashi G. Takaoka                sr_ZZ.toString(), "serbian_qwertz");
169162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        // This is a preliminary subtype and may not exist.
170162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        if (srLatn == null) {
171162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka            return;
172162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        }
1738108a3e1cdceb1874804f74ec24d824a7df1b669Tadashi G. Takaoka        // An action label should be displayed in subtype's locale regardless of the system locale.
174162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        doTestActionKeysInLocaleWithKeyboardTextsSet(srLatn, sr_ZZ, new Locale("sr"));
175162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        doTestActionKeysInLocaleWithKeyboardTextsSet(srLatn, sr_ZZ, Locale.US);
176162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        doTestActionKeysInLocaleWithKeyboardTextsSet(srLatn, sr_ZZ, Locale.FRENCH);
177162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        doTestActionKeysInLocaleWithKeyboardTextsSet(srLatn, sr_ZZ, Locale.ITALIAN);
178162ca68051368c737fe1a105f1721e643b2884feTadashi G. Takaoka        doTestActionKeysInLocaleWithKeyboardTextsSet(srLatn, sr_ZZ, Locale.JAPANESE);
1798108a3e1cdceb1874804f74ec24d824a7df1b669Tadashi G. Takaoka    }
1803da9e4ade0d24c4c5d352dd60f49da818fcc82e6Tadashi G. Takaoka}
181