Fix action tests, remove no longer relevant Klp action tests

This commit is contained in:
Aleksandras Kostarevas 2024-08-31 18:52:32 +03:00
parent 6a76537d3b
commit 32b95f11f6
14 changed files with 15 additions and 569 deletions

View File

@ -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

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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<Void> job = new RunInLocale<Void>() {
@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<Void> job = new RunInLocale<Void>() {
@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);
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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<InputMethodSubtype> 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;
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}

View File

@ -64,7 +64,7 @@ public abstract class ExpectedKeyVisual {
@Override
public String getLabel() {
return mIconId;
return "";
}
@Override