From 067d8cdf56580c6aaf0fd98ff8f7b6bf837a8814 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 24 Oct 2014 16:21:53 +0900 Subject: [PATCH] Fix unit test breakage Change-Id: I538288054a58eb2c81ce3cbe5c9bef900fb653a5 --- .../inputmethod/latin/common/CodePointUtils.java | 6 ++++++ .../inputmethod/latin/common/Constants.java | 2 +- .../android/inputmethod/event/DeadKeyCombiner.java | 14 +++++++------- .../latin/dicttool/BinaryDictOffdeviceUtils.java | 1 - 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/common/src/com/android/inputmethod/latin/common/CodePointUtils.java b/common/src/com/android/inputmethod/latin/common/CodePointUtils.java index 38aba7bd2..592da5c1f 100644 --- a/common/src/com/android/inputmethod/latin/common/CodePointUtils.java +++ b/common/src/com/android/inputmethod/latin/common/CodePointUtils.java @@ -16,9 +16,13 @@ package com.android.inputmethod.latin.common; +import com.android.inputmethod.annotations.UsedForTesting; + import java.util.Random; // Utility methods related with code points used for tests. +// TODO: Figure out where this class should be. +@UsedForTesting public class CodePointUtils { private CodePointUtils() { // This utility class is not publicly instantiable. @@ -60,6 +64,7 @@ public class CodePointUtils { 0x00FF /* LATIN SMALL LETTER Y WITH DIAERESIS */ }; + @UsedForTesting public static int[] generateCodePointSet(final int codePointSetSize, final Random random) { final int[] codePointSet = new int[codePointSetSize]; for (int i = codePointSet.length - 1; i >= 0; ) { @@ -80,6 +85,7 @@ public class CodePointUtils { /** * Generates a random word. */ + @UsedForTesting public static String generateWord(final Random random, final int[] codePointSet) { StringBuilder builder = new StringBuilder(); // 8 * 4 = 32 chars max, but we do it the following way so as to bias the random toward diff --git a/common/src/com/android/inputmethod/latin/common/Constants.java b/common/src/com/android/inputmethod/latin/common/Constants.java index 0b3b014f9..a0cbd2c38 100644 --- a/common/src/com/android/inputmethod/latin/common/Constants.java +++ b/common/src/com/android/inputmethod/latin/common/Constants.java @@ -300,7 +300,7 @@ public final class Constants { /** * Screen metrics (a.k.a. Device form factor) constants of - * {@link R.integer#config_screen_metrics}. + * {@link com.android.inputmethod.latin.R.integer#config_screen_metrics}. */ public static final int SCREEN_METRICS_SMALL_PHONE = 0; public static final int SCREEN_METRICS_LARGE_PHONE = 1; diff --git a/java/src/com/android/inputmethod/event/DeadKeyCombiner.java b/java/src/com/android/inputmethod/event/DeadKeyCombiner.java index a3e4ad833..1a28bb1d5 100644 --- a/java/src/com/android/inputmethod/event/DeadKeyCombiner.java +++ b/java/src/com/android/inputmethod/event/DeadKeyCombiner.java @@ -218,17 +218,17 @@ public class DeadKeyCombiner implements Combiner { @Nonnull private static Event createEventChainFromSequence(final @Nonnull CharSequence text, @Nonnull final Event originalEvent) { - if (text.length() <= 0) { + int index = text.length(); + if (index <= 0) { return originalEvent; } Event lastEvent = null; - int codePoint = 0; - for (int i = text.length(); i > 0; i -= Character.charCount(codePoint)) { - codePoint = Character.codePointBefore(text, i); - final Event thisEvent = Event.createHardwareKeypressEvent(codePoint, + do { + final int codePoint = Character.codePointBefore(text, index); + lastEvent = Event.createHardwareKeypressEvent(codePoint, originalEvent.mKeyCode, lastEvent, false /* isKeyRepeat */); - lastEvent = thisEvent; - } + index -= Character.charCount(codePoint); + } while (index > 0); return lastEvent; } diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java index f169641f0..1c5dfa9fb 100644 --- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java +++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java @@ -33,7 +33,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.util.Arrays; -import java.util.ArrayList; /** * Class grouping utilities for offline dictionary making.