aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java4
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSpanish419.java36
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/StringAndJsonUtilsTests.java64
3 files changed, 102 insertions, 2 deletions
diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java
index 57d295058..18390b2cd 100644
--- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java
@@ -25,8 +25,8 @@ import java.util.ArrayList;
@SmallTest
public class KeyboardLayoutSetSubtypesCountTests extends KeyboardLayoutSetTestsBase {
- private static final int NUMBER_OF_SUBTYPES = 68;
- private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 43;
+ private static final int NUMBER_OF_SUBTYPES = 69;
+ private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 44;
private static final int NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES = 2;
private static String toString(final ArrayList<InputMethodSubtype> subtypeList) {
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSpanish419.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSpanish419.java
new file mode 100644
index 000000000..75aad136f
--- /dev/null
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSpanish419.java
@@ -0,0 +1,36 @@
+/*
+ * 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.layout.tests;
+
+import android.test.suitebuilder.annotation.SmallTest;
+
+import com.android.inputmethod.keyboard.layout.LayoutBase;
+import com.android.inputmethod.keyboard.layout.Spanish;
+
+import java.util.Locale;
+
+/**
+ * es_419: Spanish (Latin America)/spanish
+ */
+@SmallTest
+public class TestsSpanish419 extends LayoutTestsBase {
+ private static final Locale LOCALE = new Locale("es", "419");
+ private static final LayoutBase LAYOUT = new Spanish(new SpanishCustomizer(LOCALE));
+
+ @Override
+ LayoutBase getLayout() { return LAYOUT; }
+}
diff --git a/tests/src/com/android/inputmethod/latin/utils/StringAndJsonUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/StringAndJsonUtilsTests.java
index e55c32bd0..2a4ead383 100644
--- a/tests/src/com/android/inputmethod/latin/utils/StringAndJsonUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/StringAndJsonUtilsTests.java
@@ -308,4 +308,68 @@ public class StringAndJsonUtilsTests extends AndroidTestCase {
assertEquals(objs[i], newObjArray.get(i));
}
}
+
+ public void testToCodePointArray() {
+ final String STR_WITH_SUPPLEMENTARY_CHAR = "abcde\uD861\uDED7fgh\u0000\u2002\u2003\u3000xx";
+ final int[] EXPECTED_RESULT = new int[] { 'a', 'b', 'c', 'd', 'e', 0x286D7, 'f', 'g', 'h',
+ 0, 0x2002, 0x2003, 0x3000, 'x', 'x'};
+ final int[] codePointArray = StringUtils.toCodePointArray(STR_WITH_SUPPLEMENTARY_CHAR, 0,
+ STR_WITH_SUPPLEMENTARY_CHAR.length());
+ assertEquals("toCodePointArray, size matches", codePointArray.length,
+ EXPECTED_RESULT.length);
+ for (int i = 0; i < EXPECTED_RESULT.length; ++i) {
+ assertEquals("toCodePointArray position " + i, codePointArray[i], EXPECTED_RESULT[i]);
+ }
+ }
+
+ public void testCopyCodePointsAndReturnCodePointCount() {
+ final String STR_WITH_SUPPLEMENTARY_CHAR = "AbcDE\uD861\uDED7fGh\u0000\u2002\u3000あx";
+ final int[] EXPECTED_RESULT = new int[] { 'A', 'b', 'c', 'D', 'E', 0x286D7,
+ 'f', 'G', 'h', 0, 0x2002, 0x3000, 'あ', 'x'};
+ final int[] EXPECTED_RESULT_DOWNCASE = new int[] { 'a', 'b', 'c', 'd', 'e', 0x286D7,
+ 'f', 'g', 'h', 0, 0x2002, 0x3000, 'あ', 'x'};
+
+ int[] codePointArray = new int[50];
+ int codePointCount = StringUtils.copyCodePointsAndReturnCodePointCount(codePointArray,
+ STR_WITH_SUPPLEMENTARY_CHAR, 0,
+ STR_WITH_SUPPLEMENTARY_CHAR.length(), false /* downCase */);
+ assertEquals("copyCodePointsAndReturnCodePointCount, size matches", codePointCount,
+ EXPECTED_RESULT.length);
+ for (int i = 0; i < codePointCount; ++i) {
+ assertEquals("copyCodePointsAndReturnCodePointCount position " + i, codePointArray[i],
+ EXPECTED_RESULT[i]);
+ }
+
+ codePointCount = StringUtils.copyCodePointsAndReturnCodePointCount(codePointArray,
+ STR_WITH_SUPPLEMENTARY_CHAR, 0,
+ STR_WITH_SUPPLEMENTARY_CHAR.length(), true /* downCase */);
+ assertEquals("copyCodePointsAndReturnCodePointCount downcase, size matches", codePointCount,
+ EXPECTED_RESULT_DOWNCASE.length);
+ for (int i = 0; i < codePointCount; ++i) {
+ assertEquals("copyCodePointsAndReturnCodePointCount position " + i, codePointArray[i],
+ EXPECTED_RESULT_DOWNCASE[i]);
+ }
+
+ final int JAVA_CHAR_COUNT = 8;
+ final int CODEPOINT_COUNT = 7;
+ codePointCount = StringUtils.copyCodePointsAndReturnCodePointCount(codePointArray,
+ STR_WITH_SUPPLEMENTARY_CHAR, 0, JAVA_CHAR_COUNT, false /* downCase */);
+ assertEquals("copyCodePointsAndReturnCodePointCount, size matches", codePointCount,
+ CODEPOINT_COUNT);
+ for (int i = 0; i < codePointCount; ++i) {
+ assertEquals("copyCodePointsAndReturnCodePointCount position " + i, codePointArray[i],
+ EXPECTED_RESULT[i]);
+ }
+
+ boolean exceptionHappened = false;
+ codePointArray = new int[5];
+ try {
+ codePointCount = StringUtils.copyCodePointsAndReturnCodePointCount(codePointArray,
+ STR_WITH_SUPPLEMENTARY_CHAR, 0, JAVA_CHAR_COUNT, false /* downCase */);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ exceptionHappened = true;
+ }
+ assertTrue("copyCodePointsAndReturnCodePointCount throws when array is too small",
+ exceptionHappened);
+ }
}