From 8c6b34e51dfd139d55ad1ea7d6e39a7223117fc3 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 7 Mar 2014 19:01:25 +0900 Subject: [PATCH] Filter Spacer before keyboard layout test Bug: 13017434 Change-Id: I836d2f79a839ee77325535c08d7a59bb02b83c28 --- .../expected/ActualKeyboardBuilder.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) 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 b918d47f8..577f43e17 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java @@ -24,7 +24,6 @@ import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.utils.StringUtils; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.Comparator; @@ -44,15 +43,27 @@ public final class ActualKeyboardBuilder extends AbstractKeyboardBuilder { } }; + private static ArrayList filterOutSpacerAndSortKeys(final Key[] keys) { + final ArrayList filteredKeys = CollectionUtils.newArrayList(); + for (final Key key : keys) { + if (key.isSpacer()) { + continue; + } + filteredKeys.add(key); + } + Collections.sort(filteredKeys, ROW_COLUMN_COMPARATOR); + return filteredKeys; + } + /** * Create the keyboard that consists of the array of rows of the actual keyboard's keys. * @param keys the array of keys of the actual keyboard. * @return the actual keyboard grouped with rows. */ public static Key[][] buildKeyboard(final Key[] keys) { - // Sort keys from top-left to bottom-right order to prepare to create rows. - final ArrayList sortedKeys = CollectionUtils.newArrayList(Arrays.asList(keys)); - Collections.sort(sortedKeys, ROW_COLUMN_COMPARATOR); + // Filter out spacer and sort keys from top-left to bottom-right order to prepare to + // create rows. + final ArrayList sortedKeys = filterOutSpacerAndSortKeys(keys); // Grouping keys into rows. final ArrayList> rows = CollectionUtils.newArrayList();