Fix unit test breakage

Change-Id: I538288054a58eb2c81ce3cbe5c9bef900fb653a5
This commit is contained in:
Tadashi G. Takaoka 2014-10-24 16:21:53 +09:00
parent a2b4bfb0f5
commit 067d8cdf56
4 changed files with 14 additions and 9 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;
}

View File

@ -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.