aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/Qwerty.java2
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/Symbols.java2
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/SymbolsShifted.java3
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractKeyboardBuilder.java30
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java6
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java4
6 files changed, 22 insertions, 25 deletions
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Qwerty.java b/tests/src/com/android/inputmethod/keyboard/layout/Qwerty.java
index f17c59d8f..4070837c9 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/Qwerty.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/Qwerty.java
@@ -35,7 +35,7 @@ public final class Qwerty extends LayoutBase {
@Override
ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; }
- private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder(10, 9, 7, 3)
+ private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder()
.setLabelsOfRow(1, "q", "w", "e", "r", "t", "y", "u", "i", "o", "p")
.setMoreKeysOf("q", "1")
.setMoreKeysOf("w", "2")
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Symbols.java b/tests/src/com/android/inputmethod/keyboard/layout/Symbols.java
index 3edf041f8..127d81aad 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/Symbols.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/Symbols.java
@@ -114,7 +114,7 @@ public class Symbols extends AbstractLayoutBase {
public static ExpectedKey[] SINGLE_ANGLE_QUOTES_RL = { SAQUOTE_RIGHT, SAQUOTE_LEFT };
// Common symbols keyboard layout.
- private static final ExpectedKey[][] SYMBOLS_COMMON = new ExpectedKeyboardBuilder(10, 9, 7, 5)
+ private static final ExpectedKey[][] SYMBOLS_COMMON = new ExpectedKeyboardBuilder()
.setKeysOfRow(1,
// U+00B9: "¹" SUPERSCRIPT ONE
// U+00BD: "½" VULGAR FRACTION ONE HALF
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/SymbolsShifted.java b/tests/src/com/android/inputmethod/keyboard/layout/SymbolsShifted.java
index 2403f0fd7..7cbd2fbb0 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/SymbolsShifted.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/SymbolsShifted.java
@@ -70,8 +70,7 @@ public class SymbolsShifted extends AbstractLayoutBase {
};
// Common symbols shifted keyboard layout.
- private static final ExpectedKey[][] SYMBOLS_SHIFTED_COMMON = new ExpectedKeyboardBuilder(
- 10, 1 /* other_currencies */+ 5, 7, 5)
+ private static final ExpectedKey[][] SYMBOLS_SHIFTED_COMMON = new ExpectedKeyboardBuilder()
.setKeysOfRow(1,
key("~"),
// U+0060: "`" GRAVE ACCENT
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractKeyboardBuilder.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractKeyboardBuilder.java
index 682ac20a1..3365b92ec 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractKeyboardBuilder.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractKeyboardBuilder.java
@@ -29,7 +29,7 @@ import java.util.Arrays;
*/
abstract class AbstractKeyboardBuilder<E> {
// A building array of rows.
- private final E[][] mRows;
+ private E[][] mRows;
// Returns an instance of default element.
abstract E defaultElement();
@@ -42,12 +42,8 @@ abstract class AbstractKeyboardBuilder<E> {
* Construct a builder filled with the default element.
* @param dimensions the integer array of each row's size.
*/
- AbstractKeyboardBuilder(final int ... dimensions) {
- mRows = newArrayOfArray(dimensions.length);
- for (int rowIndex = 0; rowIndex < dimensions.length; rowIndex++) {
- mRows[rowIndex] = newArray(dimensions[rowIndex]);
- Arrays.fill(mRows[rowIndex], defaultElement());
- }
+ AbstractKeyboardBuilder() {
+ mRows = newArrayOfArray(0);
}
/**
@@ -102,10 +98,13 @@ abstract class AbstractKeyboardBuilder<E> {
*/
void setRowAt(final int row, final E[] elements) {
final int rowIndex = row - 1;
- if (rowIndex < 0 || rowIndex >= mRows.length) {
+ if (rowIndex < 0) {
throw new RuntimeException("Illegal row number: " + row);
}
- mRows[rowIndex] = elements;
+ final E[][] newRows = (rowIndex < mRows.length) ? mRows
+ : Arrays.copyOf(mRows, rowIndex + 1);
+ newRows[rowIndex] = elements;
+ mRows = newRows;
}
/**
@@ -120,8 +119,11 @@ abstract class AbstractKeyboardBuilder<E> {
void setElementAt(final int row, final int column, final E element, final boolean insert) {
final E[] elements = getRowAt(row);
final int columnIndex = column - 1;
+ if (columnIndex < 0) {
+ throw new RuntimeException("Illegal column number: " + column);
+ }
if (insert) {
- if (columnIndex < 0 || columnIndex >= elements.length + 1) {
+ if (columnIndex >= elements.length + 1) {
throw new RuntimeException("Illegal column number: " + column);
}
final E[] newElements = Arrays.copyOf(elements, elements.length + 1);
@@ -134,9 +136,9 @@ abstract class AbstractKeyboardBuilder<E> {
setRowAt(row, newElements);
return;
}
- if (columnIndex < 0 || columnIndex >= elements.length) {
- throw new RuntimeException("Illegal column number: " + column);
- }
- elements[columnIndex] = element;
+ final E[] newElements = (columnIndex < elements.length) ? elements
+ : Arrays.copyOf(elements, columnIndex + 1);
+ newElements[columnIndex] = element;
+ setRowAt(row, newElements);
}
}
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java
index 577f43e17..050bc4c5a 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java
@@ -85,7 +85,7 @@ public final class ActualKeyboardBuilder extends AbstractKeyboardBuilder<Key> {
for (int rowIndex = 0; rowIndex < dimensions.length; rowIndex++) {
dimensions[rowIndex] = rows.get(rowIndex).size();
}
- final ActualKeyboardBuilder builder = new ActualKeyboardBuilder(dimensions);
+ final ActualKeyboardBuilder builder = new ActualKeyboardBuilder();
for (int rowIndex = 0; rowIndex < rows.size(); rowIndex++) {
final int row = rowIndex + 1;
@@ -95,10 +95,6 @@ public final class ActualKeyboardBuilder extends AbstractKeyboardBuilder<Key> {
return builder.build();
}
- private ActualKeyboardBuilder(final int ... dimensions) {
- super(dimensions);
- }
-
@Override
Key defaultElement() { return null; }
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java
index 795bcb28e..176e0eb92 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java
@@ -23,8 +23,8 @@ import java.util.Locale;
* This class builds an expected keyboard for unit test.
*/
public final class ExpectedKeyboardBuilder extends AbstractKeyboardBuilder<ExpectedKey> {
- public ExpectedKeyboardBuilder(final int ... dimensions) {
- super(dimensions);
+ public ExpectedKeyboardBuilder() {
+ super();
}
public ExpectedKeyboardBuilder(final ExpectedKey[][] rows) {