aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetActionLabelKlpTests.java (renamed from tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetActionLabelTests.java)38
-rw-r--r--tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetActionLabelLxxTests.java97
-rw-r--r--tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java5
-rw-r--r--tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java11
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/tests/LayoutTestsBase.java6
5 files changed, 144 insertions, 13 deletions
diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetActionLabelTests.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetActionLabelKlpTests.java
index 06139b808..96f925554 100644
--- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetActionLabelTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetActionLabelKlpTests.java
@@ -29,9 +29,14 @@ import com.android.inputmethod.latin.utils.RunInLocale;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@MediumTest
-public final class KeyboardLayoutSetActionLabelTests extends KeyboardLayoutSetTestsBase {
+public class KeyboardLayoutSetActionLabelKlpTests extends KeyboardLayoutSetTestsBase {
+ @Override
+ protected int getKeyboardThemeForTests() {
+ return KeyboardTheme.THEME_ID_KLP;
+ }
+
private static void doTestActionKey(final String tag, final KeyboardLayoutSet layoutSet,
- final int elementId, final String label, final int iconId) {
+ final int elementId, final CharSequence label, final int iconId) {
final Keyboard keyboard = layoutSet.getKeyboard(elementId);
final Key enterKey = keyboard.getKey(Constants.CODE_ENTER);
assertNotNull(tag + " enter key on " + keyboard.mId, enterKey);
@@ -39,7 +44,7 @@ public final class KeyboardLayoutSetActionLabelTests extends KeyboardLayoutSetTe
assertEquals(tag + " enter icon " + enterKey, iconId, enterKey.getIconId());
}
- private void doTestActionLabel(final String tag, final InputMethodSubtype subtype,
+ protected void doTestActionLabel(final String tag, final InputMethodSubtype subtype,
final int actionId, final int labelResId) {
final EditorInfo editorInfo = new EditorInfo();
editorInfo.imeOptions = actionId;
@@ -57,6 +62,11 @@ public final class KeyboardLayoutSetActionLabelTests extends KeyboardLayoutSetTe
} else {
label = job.runInLocale(res, SubtypeLocaleUtils.getSubtypeLocale(subtype));
}
+ doTestActionLabel(tag, subtype, editorInfo, label);
+ }
+
+ protected void doTestActionLabel(final String tag, final InputMethodSubtype subtype,
+ final EditorInfo editorInfo, final CharSequence label) {
// Test text layouts.
editorInfo.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL;
final KeyboardLayoutSet layoutSet = createKeyboardLayoutSet(subtype, editorInfo);
@@ -82,7 +92,7 @@ public final class KeyboardLayoutSetActionLabelTests extends KeyboardLayoutSetTe
label, KeyboardIconsSet.ICON_UNDEFINED);
}
- private void doTestActionKeyIcon(final String tag, final InputMethodSubtype subtype,
+ protected void doTestActionKeyIcon(final String tag, final InputMethodSubtype subtype,
final int actionId, final String iconName) {
final int iconId = KeyboardIconsSet.getIconId(iconName);
final EditorInfo editorInfo = new EditorInfo();
@@ -111,14 +121,16 @@ public final class KeyboardLayoutSetActionLabelTests extends KeyboardLayoutSetTe
for (final InputMethodSubtype subtype : getAllSubtypesList()) {
final String tag = "unspecifiled "
+ SubtypeLocaleUtils.getSubtypeNameForLogging(subtype);
- doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_UNSPECIFIED, "enter_key");
+ doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_UNSPECIFIED,
+ KeyboardIconsSet.NAME_ENTER_KEY);
}
}
public void testActionNone() {
for (final InputMethodSubtype subtype : getAllSubtypesList()) {
final String tag = "none " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype);
- doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_NONE, "enter_key");
+ doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_NONE,
+ KeyboardIconsSet.NAME_ENTER_KEY);
}
}
@@ -132,7 +144,8 @@ public final class KeyboardLayoutSetActionLabelTests extends KeyboardLayoutSetTe
public void testActionSearch() {
for (final InputMethodSubtype subtype : getAllSubtypesList()) {
final String tag = "search " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype);
- doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_SEARCH, "search_key");
+ doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_SEARCH,
+ KeyboardIconsSet.NAME_SEARCH_KEY);
}
}
@@ -164,4 +177,15 @@ public final class KeyboardLayoutSetActionLabelTests extends KeyboardLayoutSetTe
tag, subtype, EditorInfo.IME_ACTION_PREVIOUS, R.string.label_previous_key);
}
}
+
+ public void testActionCustom() {
+ for (final InputMethodSubtype subtype : getAllSubtypesList()) {
+ final String tag = "custom " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype);
+ final CharSequence customLabel = "customLabel";
+ final EditorInfo editorInfo = new EditorInfo();
+ editorInfo.imeOptions = EditorInfo.IME_ACTION_UNSPECIFIED;
+ editorInfo.actionLabel = customLabel;
+ doTestActionLabel(tag, subtype, editorInfo, customLabel);
+ }
+ }
}
diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetActionLabelLxxTests.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetActionLabelLxxTests.java
new file mode 100644
index 000000000..7747ac5f9
--- /dev/null
+++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetActionLabelLxxTests.java
@@ -0,0 +1,97 @@
+/*
+ * 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 com.android.inputmethod.keyboard;
+
+import android.test.suitebuilder.annotation.MediumTest;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodSubtype;
+
+import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
+import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
+
+@MediumTest
+public class KeyboardLayoutSetActionLabelLxxTests extends KeyboardLayoutSetActionLabelKlpTests {
+ @Override
+ protected int getKeyboardThemeForTests() {
+ return KeyboardTheme.THEME_ID_LXX_DARK;
+ }
+
+ @Override
+ public void testActionUnspecified() {
+ super.testActionUnspecified();
+ }
+
+ @Override
+ public void testActionNone() {
+ super.testActionNone();
+ }
+
+ @Override
+ public void testActionGo() {
+ for (final InputMethodSubtype subtype : getAllSubtypesList()) {
+ final String tag = "go " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype);
+ doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_GO,
+ KeyboardIconsSet.NAME_GO_KEY);
+ }
+ }
+
+ @Override
+ public void testActionSearch() {
+ super.testActionSearch();
+ }
+
+ @Override
+ public void testActionSend() {
+ for (final InputMethodSubtype subtype : getAllSubtypesList()) {
+ final String tag = "send " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype);
+ doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_SEND,
+ KeyboardIconsSet.NAME_SEND_KEY);
+ }
+ }
+
+ @Override
+ public void testActionNext() {
+ for (final InputMethodSubtype subtype : getAllSubtypesList()) {
+ final String tag = "next " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype);
+ doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_NEXT,
+ KeyboardIconsSet.NAME_NEXT_KEY);
+ }
+ }
+
+ @Override
+ public void testActionDone() {
+ for (final InputMethodSubtype subtype : getAllSubtypesList()) {
+ final String tag = "done " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype);
+ doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_DONE,
+ KeyboardIconsSet.NAME_DONE_KEY);
+ }
+ }
+
+ @Override
+ public void testActionPrevious() {
+ for (final InputMethodSubtype subtype : getAllSubtypesList()) {
+ final String tag = "previous " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype);
+ doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_PREVIOUS,
+ KeyboardIconsSet.NAME_PREVIOUS_KEY);
+ }
+ }
+
+ @Override
+ public void testActionCustom() {
+ super.testActionCustom();
+ }
+}
diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java
index 26402f8c7..bf19a8b46 100644
--- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java
@@ -29,6 +29,11 @@ public class KeyboardLayoutSetSubtypesCountTests extends KeyboardLayoutSetTestsB
private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 45;
private static final int NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES = 2;
+ @Override
+ protected int getKeyboardThemeForTests() {
+ return KeyboardTheme.THEME_ID_KLP;
+ }
+
private static String toString(final ArrayList<InputMethodSubtype> subtypeList) {
final StringBuilder sb = new StringBuilder();
for (int index = 0; index < subtypeList.size(); index++) {
diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java
index 1ccb58c0f..15e2647c6 100644
--- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java
+++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java
@@ -18,9 +18,7 @@ package com.android.inputmethod.keyboard;
import android.content.Context;
import android.content.res.Resources;
-import android.preference.PreferenceManager;
import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
import android.view.ContextThemeWrapper;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodInfo;
@@ -38,8 +36,7 @@ import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import java.util.ArrayList;
import java.util.Locale;
-@SmallTest
-public class KeyboardLayoutSetTestsBase extends AndroidTestCase {
+public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
// All input method subtypes of LatinIME.
private final ArrayList<InputMethodSubtype> mAllSubtypesList = new ArrayList<>();
private final ArrayList<InputMethodSubtype> mAsciiCapableSubtypesList = new ArrayList<>();
@@ -48,13 +45,15 @@ public class KeyboardLayoutSetTestsBase extends AndroidTestCase {
private Context mThemeContext;
private int mScreenMetrics;
+ protected abstract int getKeyboardThemeForTests();
+
@Override
protected void setUp() throws Exception {
super.setUp();
mScreenMetrics = mContext.getResources().getInteger(R.integer.config_screen_metrics);
- final KeyboardTheme keyboardTheme = KeyboardTheme.getKeyboardTheme(
- PreferenceManager.getDefaultSharedPreferences(mContext));
+ final KeyboardTheme keyboardTheme = KeyboardTheme.searchKeyboardThemeById(
+ getKeyboardThemeForTests());
mThemeContext = new ContextThemeWrapper(mContext, keyboardTheme.mStyleId);
RichInputMethodManager.init(mThemeContext);
final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/LayoutTestsBase.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/LayoutTestsBase.java
index d4e8fb647..0d90055ec 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/tests/LayoutTestsBase.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/LayoutTestsBase.java
@@ -24,6 +24,7 @@ import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.keyboard.KeyboardLayoutSet;
import com.android.inputmethod.keyboard.KeyboardLayoutSetTestsBase;
+import com.android.inputmethod.keyboard.KeyboardTheme;
import com.android.inputmethod.keyboard.layout.LayoutBase;
import com.android.inputmethod.keyboard.layout.expected.AbstractLayoutBase;
import com.android.inputmethod.keyboard.layout.expected.ActualKeyboardBuilder;
@@ -57,6 +58,11 @@ abstract class LayoutTestsBase extends KeyboardLayoutSetTestsBase {
true /* isLanguageSwitchKeyEnabled */);
}
+ @Override
+ protected int getKeyboardThemeForTests() {
+ return KeyboardTheme.THEME_ID_KLP;
+ }
+
// Those helper methods have a lower case name to be readable when defining expected keyboard
// layouts.