am dd5737b0: Merge "Fix unit test breakage"
* commit 'dd5737b0fa3bf68f90534457ed8d23437caf5420': Fix unit test breakagemain
commit
ffd9d64f3d
|
@ -16,9 +16,13 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.common;
|
package com.android.inputmethod.latin.common;
|
||||||
|
|
||||||
|
import com.android.inputmethod.annotations.UsedForTesting;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
// Utility methods related with code points used for tests.
|
// Utility methods related with code points used for tests.
|
||||||
|
// TODO: Figure out where this class should be.
|
||||||
|
@UsedForTesting
|
||||||
public class CodePointUtils {
|
public class CodePointUtils {
|
||||||
private CodePointUtils() {
|
private CodePointUtils() {
|
||||||
// This utility class is not publicly instantiable.
|
// This utility class is not publicly instantiable.
|
||||||
|
@ -60,6 +64,7 @@ public class CodePointUtils {
|
||||||
0x00FF /* LATIN SMALL LETTER Y WITH DIAERESIS */
|
0x00FF /* LATIN SMALL LETTER Y WITH DIAERESIS */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@UsedForTesting
|
||||||
public static int[] generateCodePointSet(final int codePointSetSize, final Random random) {
|
public static int[] generateCodePointSet(final int codePointSetSize, final Random random) {
|
||||||
final int[] codePointSet = new int[codePointSetSize];
|
final int[] codePointSet = new int[codePointSetSize];
|
||||||
for (int i = codePointSet.length - 1; i >= 0; ) {
|
for (int i = codePointSet.length - 1; i >= 0; ) {
|
||||||
|
@ -80,6 +85,7 @@ public class CodePointUtils {
|
||||||
/**
|
/**
|
||||||
* Generates a random word.
|
* Generates a random word.
|
||||||
*/
|
*/
|
||||||
|
@UsedForTesting
|
||||||
public static String generateWord(final Random random, final int[] codePointSet) {
|
public static String generateWord(final Random random, final int[] codePointSet) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
// 8 * 4 = 32 chars max, but we do it the following way so as to bias the random toward
|
// 8 * 4 = 32 chars max, but we do it the following way so as to bias the random toward
|
||||||
|
|
|
@ -300,7 +300,7 @@ public final class Constants {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Screen metrics (a.k.a. Device form factor) constants of
|
* 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_SMALL_PHONE = 0;
|
||||||
public static final int SCREEN_METRICS_LARGE_PHONE = 1;
|
public static final int SCREEN_METRICS_LARGE_PHONE = 1;
|
||||||
|
|
|
@ -218,17 +218,17 @@ public class DeadKeyCombiner implements Combiner {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private static Event createEventChainFromSequence(final @Nonnull CharSequence text,
|
private static Event createEventChainFromSequence(final @Nonnull CharSequence text,
|
||||||
@Nonnull final Event originalEvent) {
|
@Nonnull final Event originalEvent) {
|
||||||
if (text.length() <= 0) {
|
int index = text.length();
|
||||||
|
if (index <= 0) {
|
||||||
return originalEvent;
|
return originalEvent;
|
||||||
}
|
}
|
||||||
Event lastEvent = null;
|
Event lastEvent = null;
|
||||||
int codePoint = 0;
|
do {
|
||||||
for (int i = text.length(); i > 0; i -= Character.charCount(codePoint)) {
|
final int codePoint = Character.codePointBefore(text, index);
|
||||||
codePoint = Character.codePointBefore(text, i);
|
lastEvent = Event.createHardwareKeypressEvent(codePoint,
|
||||||
final Event thisEvent = Event.createHardwareKeypressEvent(codePoint,
|
|
||||||
originalEvent.mKeyCode, lastEvent, false /* isKeyRepeat */);
|
originalEvent.mKeyCode, lastEvent, false /* isKeyRepeat */);
|
||||||
lastEvent = thisEvent;
|
index -= Character.charCount(codePoint);
|
||||||
}
|
} while (index > 0);
|
||||||
return lastEvent;
|
return lastEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class grouping utilities for offline dictionary making.
|
* Class grouping utilities for offline dictionary making.
|
||||||
|
|
Loading…
Reference in New Issue