diff --git a/tests/src/org/futo/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java b/tests/src/org/futo/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java index 406511c0f..59779bcb8 100644 --- a/tests/src/org/futo/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java +++ b/tests/src/org/futo/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java @@ -28,6 +28,7 @@ import org.futo.inputmethod.compat.InputMethodSubtypeCompatUtils; import org.futo.inputmethod.latin.R; import org.futo.inputmethod.latin.RichInputMethodManager; import org.futo.inputmethod.latin.RichInputMethodSubtype; +import org.futo.inputmethod.latin.Subtypes; import org.futo.inputmethod.latin.common.Constants; import org.futo.inputmethod.latin.settings.Settings; import org.futo.inputmethod.latin.utils.AdditionalSubtypeUtils; @@ -89,11 +90,14 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase { mScreenMetrics = Settings.readScreenMetrics(res); - final InputMethodInfo imi = mRichImm.getInputMethodInfoOfThisIme(); - final int subtypeCount = imi.getSubtypeCount(); - for (int index = 0; index < subtypeCount; index++) { - mAllSubtypesList.add(imi.getSubtypeAt(index)); - } + mAllSubtypesList.add(Subtypes.INSTANCE.makeSubtype(Locale.US.toString(), "qwerty")); + mAllSubtypesList.add(Subtypes.INSTANCE.makeSubtype(Locale.US.toString(), "pcqwerty")); + mAllSubtypesList.add(Subtypes.INSTANCE.makeSubtype(Locale.US.toString(), "azerty")); + mAllSubtypesList.add(Subtypes.INSTANCE.makeSubtype(Locale.US.toString(), "colemak")); + mAllSubtypesList.add(Subtypes.INSTANCE.makeSubtype(Locale.GERMANY.toString(), "qwertz")); + mAllSubtypesList.add(Subtypes.INSTANCE.makeSubtype(Locale.GERMANY.toString(), "german")); + mAllSubtypesList.add(Subtypes.INSTANCE.makeSubtype(Locale.GERMANY.toString(), "swiss")); + mAllSubtypesList.add(Subtypes.INSTANCE.makeSubtype(new Locale("ar").toString(), "arabic")); } @Override diff --git a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionCustomTests.java b/tests/src/org/futo/inputmethod/keyboard/action/KlpActionCustomTests.java deleted file mode 100644 index 4bff2a7c0..000000000 --- a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionCustomTests.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.futo.inputmethod.keyboard.action; - -import android.test.suitebuilder.annotation.LargeTest; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodSubtype; - -import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils; - -@LargeTest -public class KlpActionCustomTests extends KlpActionTestsBase { - public void testActionCustom() { - for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { - final String tag = "custom " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); - final EditorInfo editorInfo = new EditorInfo(); - editorInfo.imeOptions = EditorInfo.IME_ACTION_UNSPECIFIED; - editorInfo.actionLabel = "customLabel"; - final ExpectedActionKey expectedKey = ExpectedActionKey.newLabelKey("customLabel"); - doTestActionKey(tag, subtype, editorInfo, expectedKey); - } - } -} diff --git a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionDoneTests.java b/tests/src/org/futo/inputmethod/keyboard/action/KlpActionDoneTests.java deleted file mode 100644 index f0b5087e1..000000000 --- a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionDoneTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.futo.inputmethod.keyboard.action; - -import android.test.suitebuilder.annotation.LargeTest; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodSubtype; - -import org.futo.inputmethod.latin.R; -import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils; - -@LargeTest -public class KlpActionDoneTests extends KlpActionTestsBase { - public void testActionDone() { - for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { - final String tag = "done " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); - final ExpectedActionKey expectedKey = ExpectedActionKey.newLabelKey( - R.string.label_done_key, getLabelLocale(subtype), getContext()); - doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_DONE, expectedKey); - } - } -} diff --git a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionGoTests.java b/tests/src/org/futo/inputmethod/keyboard/action/KlpActionGoTests.java deleted file mode 100644 index 40cf4f8f1..000000000 --- a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionGoTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.futo.inputmethod.keyboard.action; - -import android.test.suitebuilder.annotation.LargeTest; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodSubtype; - -import org.futo.inputmethod.latin.R; -import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils; - -@LargeTest -public class KlpActionGoTests extends KlpActionTestsBase { - public void testActionGo() { - for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { - final String tag = "go " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); - final ExpectedActionKey expectedKey = ExpectedActionKey.newLabelKey( - R.string.label_go_key, getLabelLocale(subtype), getContext()); - doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_GO, expectedKey); - } - } -} diff --git a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionLabelTests.java b/tests/src/org/futo/inputmethod/keyboard/action/KlpActionLabelTests.java deleted file mode 100644 index 8bcb0e08a..000000000 --- a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionLabelTests.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.futo.inputmethod.keyboard.action; - -import android.content.res.Resources; -import android.test.suitebuilder.annotation.MediumTest; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodSubtype; - -import org.futo.inputmethod.keyboard.internal.KeyboardIconsSet; -import org.futo.inputmethod.keyboard.internal.KeyboardTextsSet; -import org.futo.inputmethod.latin.R; -import org.futo.inputmethod.latin.RichInputMethodManager; -import org.futo.inputmethod.latin.Subtypes; -import org.futo.inputmethod.latin.utils.RunInLocale; -import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils; -import org.futo.inputmethod.v2keyboard.KeyboardLayoutSetV2; - -import java.util.Locale; - -@MediumTest -public class KlpActionLabelTests extends KlpActionTestsBase { - void doTestActionKeys(final InputMethodSubtype subtype, final String tag, - final ExpectedActionKey unspecifiedKey, final ExpectedActionKey noneKey, - final ExpectedActionKey goKey, final ExpectedActionKey searchKey, - final ExpectedActionKey sendKey, final ExpectedActionKey nextKey, - final ExpectedActionKey doneKey, final ExpectedActionKey previousKey) { - doTestActionKey( - tag + " unspecified", subtype, EditorInfo.IME_ACTION_UNSPECIFIED, unspecifiedKey); - doTestActionKey(tag + " none", subtype, EditorInfo.IME_ACTION_NONE, noneKey); - doTestActionKey(tag + " go", subtype, EditorInfo.IME_ACTION_GO, goKey); - doTestActionKey(tag + " search", subtype, EditorInfo.IME_ACTION_SEARCH, searchKey); - doTestActionKey(tag + " send", subtype, EditorInfo.IME_ACTION_SEND, sendKey); - doTestActionKey(tag + " next", subtype, EditorInfo.IME_ACTION_NEXT, nextKey); - doTestActionKey(tag + " done", subtype, EditorInfo.IME_ACTION_DONE, doneKey); - doTestActionKey(tag + " previous", subtype, EditorInfo.IME_ACTION_PREVIOUS, previousKey); - } - - // Working variable to simulate system locale changing. - private Locale mSystemLocale = Locale.getDefault(); - - private void doTestActionKeysInLocaleWithStringResources(final InputMethodSubtype subtype, - final Locale labelLocale, final Locale systemLocale) { - // Simulate system locale changing, see {@link SystemBroadcastReceiver}. - if (!systemLocale.equals(mSystemLocale)) { - KeyboardLayoutSetV2.onSystemLocaleChanged(); - mSystemLocale = systemLocale; - } - final ExpectedActionKey enterKey = ExpectedActionKey.newIconKey( - KeyboardIconsSet.NAME_ENTER_KEY); - final ExpectedActionKey goKey = ExpectedActionKey.newLabelKey( - R.string.label_go_key, labelLocale, getContext()); - final ExpectedActionKey searchKey = ExpectedActionKey.newIconKey( - KeyboardIconsSet.NAME_SEARCH_KEY); - final ExpectedActionKey sendKey = ExpectedActionKey.newLabelKey( - R.string.label_send_key, labelLocale, getContext()); - final ExpectedActionKey nextKey = ExpectedActionKey.newLabelKey( - R.string.label_next_key, labelLocale, getContext()); - final ExpectedActionKey doneKey = ExpectedActionKey.newLabelKey( - R.string.label_done_key, labelLocale, getContext()); - final ExpectedActionKey previousKey = ExpectedActionKey.newLabelKey( - R.string.label_previous_key, labelLocale, getContext()); - final String tag = "label=" + labelLocale + " system=" + systemLocale - + " " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); - final RunInLocale job = new RunInLocale() { - @Override - public Void job(final Resources res) { - doTestActionKeys(subtype, tag, enterKey, enterKey, goKey, searchKey, sendKey, - nextKey, doneKey, previousKey); - return null; - } - }; - job.runInLocale(getContext().getResources(), systemLocale); - } - - public void testActionLabelInOtherLocale() { - final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); - final InputMethodSubtype italian = Subtypes.INSTANCE.makeSubtype( - Locale.ITALIAN.toString(), SubtypeLocaleUtils.QWERTY); - // An action label should be displayed in subtype's locale regardless of the system locale. - doTestActionKeysInLocaleWithStringResources(italian, Locale.ITALIAN, Locale.US); - doTestActionKeysInLocaleWithStringResources(italian, Locale.ITALIAN, Locale.FRENCH); - doTestActionKeysInLocaleWithStringResources(italian, Locale.ITALIAN, Locale.ITALIAN); - doTestActionKeysInLocaleWithStringResources(italian, Locale.ITALIAN, Locale.JAPANESE); - } - - public void testNoLanguageSubtypeActionLabel() { - final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); - final InputMethodSubtype noLanguage = Subtypes.INSTANCE.makeSubtype( - SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.QWERTY); - // An action label of no language keyboard should be displayed in the system locale. - doTestActionKeysInLocaleWithStringResources(noLanguage, Locale.US, Locale.US); - doTestActionKeysInLocaleWithStringResources(noLanguage, Locale.FRENCH, Locale.FRENCH); - doTestActionKeysInLocaleWithStringResources(noLanguage, Locale.ITALIAN, Locale.ITALIAN); - doTestActionKeysInLocaleWithStringResources(noLanguage, Locale.JAPANESE, Locale.JAPANESE); - } - - private void doTestActionKeysInLocaleWithKeyboardTextsSet(final InputMethodSubtype subtype, - final Locale labelLocale, final Locale systemLocale) { - // Simulate system locale changing, see {@link SystemBroadcastReceiver}. - if (!systemLocale.equals(mSystemLocale)) { - KeyboardLayoutSetV2.onSystemLocaleChanged(); - mSystemLocale = systemLocale; - } - final KeyboardTextsSet textsSet = new KeyboardTextsSet(); - textsSet.setLocale(labelLocale, getContext()); - final ExpectedActionKey enterKey = ExpectedActionKey.newIconKey( - KeyboardIconsSet.NAME_ENTER_KEY); - final ExpectedActionKey goKey = ExpectedActionKey.newLabelKey( - textsSet.getText("label_go_key")); - final ExpectedActionKey searchKey = ExpectedActionKey.newIconKey( - KeyboardIconsSet.NAME_SEARCH_KEY); - final ExpectedActionKey sendKey = ExpectedActionKey.newLabelKey( - textsSet.getText("label_send_key")); - final ExpectedActionKey nextKey = ExpectedActionKey.newLabelKey( - textsSet.getText("label_next_key")); - final ExpectedActionKey doneKey = ExpectedActionKey.newLabelKey( - textsSet.getText("label_done_key")); - final ExpectedActionKey previousKey = ExpectedActionKey.newLabelKey( - textsSet.getText("label_previous_key")); - final String tag = "label=" + subtype.getLocale() + " system=" + systemLocale - + " " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); - final RunInLocale job = new RunInLocale() { - @Override - public Void job(final Resources res) { - doTestActionKeys(subtype, tag, enterKey, enterKey, goKey, searchKey, sendKey, - nextKey, doneKey, previousKey); - return null; - } - }; - job.runInLocale(getContext().getResources(), systemLocale); - } - - public void testHinglishActionLabel() { - final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); - final Locale hi_ZZ = new Locale("hi", "ZZ"); - final InputMethodSubtype hiLatn = Subtypes.INSTANCE.makeSubtype( - hi_ZZ.toString(), SubtypeLocaleUtils.QWERTY); - // This is a preliminary subtype and may not exist. - if (hiLatn == null) { - return; - } - // An action label should be displayed in subtype's locale regardless of the system locale. - doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, new Locale("hi")); - doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, Locale.US); - doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, Locale.FRENCH); - doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, Locale.ITALIAN); - doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, Locale.JAPANESE); - } - - public void testSerbianLatinActionLabel() { - final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); - final Locale sr_ZZ = new Locale("sr", "ZZ"); - final InputMethodSubtype srLatn = Subtypes.INSTANCE.makeSubtype( - sr_ZZ.toString(), "serbian_qwertz"); - // This is a preliminary subtype and may not exist. - if (srLatn == null) { - return; - } - // An action label should be displayed in subtype's locale regardless of the system locale. - doTestActionKeysInLocaleWithKeyboardTextsSet(srLatn, sr_ZZ, new Locale("sr")); - doTestActionKeysInLocaleWithKeyboardTextsSet(srLatn, sr_ZZ, Locale.US); - doTestActionKeysInLocaleWithKeyboardTextsSet(srLatn, sr_ZZ, Locale.FRENCH); - doTestActionKeysInLocaleWithKeyboardTextsSet(srLatn, sr_ZZ, Locale.ITALIAN); - doTestActionKeysInLocaleWithKeyboardTextsSet(srLatn, sr_ZZ, Locale.JAPANESE); - } -} diff --git a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionNextTests.java b/tests/src/org/futo/inputmethod/keyboard/action/KlpActionNextTests.java deleted file mode 100644 index 18c96010d..000000000 --- a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionNextTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.futo.inputmethod.keyboard.action; - -import android.test.suitebuilder.annotation.LargeTest; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodSubtype; - -import org.futo.inputmethod.latin.R; -import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils; - -@LargeTest -public class KlpActionNextTests extends KlpActionTestsBase { - public void testActionNext() { - for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { - final String tag = "next " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); - final ExpectedActionKey expectedKey = ExpectedActionKey.newLabelKey( - R.string.label_next_key, getLabelLocale(subtype), getContext()); - doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_NEXT, expectedKey); - } - } -} diff --git a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionNoneTests.java b/tests/src/org/futo/inputmethod/keyboard/action/KlpActionNoneTests.java deleted file mode 100644 index 425503e93..000000000 --- a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionNoneTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.futo.inputmethod.keyboard.action; - -import android.test.suitebuilder.annotation.LargeTest; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodSubtype; - -import org.futo.inputmethod.keyboard.internal.KeyboardIconsSet; -import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils; - -@LargeTest -public class KlpActionNoneTests extends KlpActionTestsBase { - public void testActionNone() { - final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey( - KeyboardIconsSet.NAME_ENTER_KEY); - for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { - final String tag = "none " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); - doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_NONE, expectedKey); - } - } -} diff --git a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionPreviousTests.java b/tests/src/org/futo/inputmethod/keyboard/action/KlpActionPreviousTests.java deleted file mode 100644 index 194c3a000..000000000 --- a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionPreviousTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.futo.inputmethod.keyboard.action; - -import android.test.suitebuilder.annotation.LargeTest; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodSubtype; - -import org.futo.inputmethod.latin.R; -import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils; - -@LargeTest -public class KlpActionPreviousTests extends KlpActionTestsBase { - public void testActionPrevious() { - for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { - final String tag = "previous " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); - final ExpectedActionKey expectedKey = ExpectedActionKey.newLabelKey( - R.string.label_previous_key, getLabelLocale(subtype), getContext()); - doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_PREVIOUS, expectedKey); - } - } -} diff --git a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionSearchTests.java b/tests/src/org/futo/inputmethod/keyboard/action/KlpActionSearchTests.java deleted file mode 100644 index 1095e5e48..000000000 --- a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionSearchTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.futo.inputmethod.keyboard.action; - -import android.test.suitebuilder.annotation.LargeTest; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodSubtype; - -import org.futo.inputmethod.keyboard.internal.KeyboardIconsSet; -import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils; - -@LargeTest -public class KlpActionSearchTests extends KlpActionTestsBase { - public void testActionSearch() { - final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey( - KeyboardIconsSet.NAME_SEARCH_KEY); - for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { - final String tag = "search " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); - doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_SEARCH, expectedKey); - } - } -} diff --git a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionSendTests.java b/tests/src/org/futo/inputmethod/keyboard/action/KlpActionSendTests.java deleted file mode 100644 index d993b433f..000000000 --- a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionSendTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.futo.inputmethod.keyboard.action; - -import android.test.suitebuilder.annotation.LargeTest; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodSubtype; - -import org.futo.inputmethod.latin.R; -import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils; - -@LargeTest -public class KlpActionSendTests extends KlpActionTestsBase { - public void testActionSend() { - for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { - final String tag = "send " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); - final ExpectedActionKey expectedKey = ExpectedActionKey.newLabelKey( - R.string.label_send_key, getLabelLocale(subtype), getContext()); - doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_SEND, expectedKey); - } - } -} diff --git a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionTestsBase.java b/tests/src/org/futo/inputmethod/keyboard/action/KlpActionTestsBase.java deleted file mode 100644 index 8ffef76e7..000000000 --- a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionTestsBase.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.futo.inputmethod.keyboard.action; - -import android.view.inputmethod.InputMethodSubtype; - -import org.futo.inputmethod.keyboard.KeyboardTheme; -import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils; - -import java.util.ArrayList; -import java.util.Locale; - -abstract class KlpActionTestsBase extends ActionTestsBase { - // Filter a subtype whose name should be displayed using {@link Locale#ROOT}, such like - // Hinglish (hi_ZZ) and Serbian-Latn (sr_ZZ). - static final SubtypeFilter SUBTYPE_FILTER_NAME_IN_BASE_LOCALE = new SubtypeFilter() { - @Override - public boolean accept(final InputMethodSubtype subtype) { - return Locale.ROOT.equals( - SubtypeLocaleUtils.getDisplayLocaleOfSubtypeLocale(subtype.getLocale())); - } - }; - - protected ArrayList mSubtypesWhoseNameIsDisplayedInItsLocale; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mSubtypesWhoseNameIsDisplayedInItsLocale = getSubtypesFilteredBy(new SubtypeFilter() { - @Override - public boolean accept(final InputMethodSubtype subtype) { - return !SUBTYPE_FILTER_NAME_IN_BASE_LOCALE.accept(subtype); - } - }); - } - - @Override - protected int getKeyboardThemeForTests() { - return KeyboardTheme.THEME_ID_LXX_LIGHT; - } -} diff --git a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionUnspecifiedTests.java b/tests/src/org/futo/inputmethod/keyboard/action/KlpActionUnspecifiedTests.java deleted file mode 100644 index ed9a8bf4f..000000000 --- a/tests/src/org/futo/inputmethod/keyboard/action/KlpActionUnspecifiedTests.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.futo.inputmethod.keyboard.action; - -import android.test.suitebuilder.annotation.LargeTest; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodSubtype; - -import org.futo.inputmethod.keyboard.internal.KeyboardIconsSet; -import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils; - -@LargeTest -public class KlpActionUnspecifiedTests extends KlpActionTestsBase { - public void testActionUnspecified() { - final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey( - KeyboardIconsSet.NAME_ENTER_KEY); - for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { - final String tag = "unspecifiled " - + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); - doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_UNSPECIFIED, expectedKey); - } - } -} diff --git a/tests/src/org/futo/inputmethod/keyboard/action/LxxActionCustomTests.java b/tests/src/org/futo/inputmethod/keyboard/action/LxxActionCustomTests.java index fb60df775..aacf3c249 100644 --- a/tests/src/org/futo/inputmethod/keyboard/action/LxxActionCustomTests.java +++ b/tests/src/org/futo/inputmethod/keyboard/action/LxxActionCustomTests.java @@ -20,6 +20,7 @@ import android.test.suitebuilder.annotation.LargeTest; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodSubtype; +import org.futo.inputmethod.keyboard.internal.KeyboardIconsSet; import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils; @LargeTest @@ -30,7 +31,10 @@ public class LxxActionCustomTests extends LxxActionTestsBase { final EditorInfo editorInfo = new EditorInfo(); editorInfo.imeOptions = EditorInfo.IME_ACTION_UNSPECIFIED; editorInfo.actionLabel = "customLabel"; - final ExpectedActionKey expectedKey = ExpectedActionKey.newLabelKey("customLabel"); + + // Changed from AOSP: Action labels are unused, most modern keyboards don't use them + // anymore + final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey(KeyboardIconsSet.NAME_ENTER_KEY); doTestActionKey(tag, subtype, editorInfo, expectedKey); } } diff --git a/tests/src/org/futo/inputmethod/keyboard/layout/expected/ExpectedKeyVisual.java b/tests/src/org/futo/inputmethod/keyboard/layout/expected/ExpectedKeyVisual.java index c3af63853..a89dd8530 100644 --- a/tests/src/org/futo/inputmethod/keyboard/layout/expected/ExpectedKeyVisual.java +++ b/tests/src/org/futo/inputmethod/keyboard/layout/expected/ExpectedKeyVisual.java @@ -64,7 +64,7 @@ public abstract class ExpectedKeyVisual { @Override public String getLabel() { - return mIconId; + return ""; } @Override