StaticLayoutBidiTestpublic class StaticLayoutBidiTest extends TestCase Quick check of native bidi implementation. |
Fields Summary |
---|
public static final int | REQ_DL | public static final int | REQ_DR | public static final int | REQ_L | public static final int | REQ_R | public static final int | L | public static final int | R | public static final String | SP | public static final String | ALEF | public static final String | BET | public static final String | GIMEL | public static final String | DALET |
Methods Summary |
---|
private void | expectNativeBidi(int dir, java.lang.String text, java.lang.String expectedLevels, int expectedDir)
char[] chs = text.toCharArray();
int n = chs.length;
byte[] chInfo = new byte[n];
int resultDir = AndroidBidi.bidi(dir, chs, chInfo, n, false);
{
StringBuilder sb = new StringBuilder("info:");
for (int i = 0; i < n; ++i) {
sb.append(" ").append(String.valueOf(chInfo[i]));
}
Log.i("BIDI", sb.toString());
}
char[] resultLevelChars = new char[n];
for (int i = 0; i < n; ++i) {
resultLevelChars[i] = (char)('0" + chInfo[i]);
}
String resultLevels = new String(resultLevelChars);
assertEquals("direction", expectedDir, resultDir);
assertEquals("levels", expectedLevels, resultLevels);
| public void | testAllLtr()
//@SmallTest
expectNativeBidi(REQ_DL, "a test", "000000", L);
| public void | testAllRtl()
expectNativeBidi(REQ_DL, ALEF + SP + ALEF + BET + GIMEL + DALET, "111111", R);
| public void | testLAllRtl()
expectNativeBidi(REQ_L, ALEF + SP + ALEF + BET + GIMEL + DALET, "111111", L);
| public void | testLRtlLtr()
expectNativeBidi(REQ_DL, ALEF + BET + GIMEL + " abc", "1111222", R);
| public void | testLtrRtl()
expectNativeBidi(REQ_DL, "abc " + ALEF + BET + GIMEL, "0000111", L);
| public void | testNativeBidi()
expectNativeBidi(REQ_L, ALEF + BET + GIMEL + " abc", "1110000", L);
| public void | testRAllLtr()
expectNativeBidi(REQ_R, "a test", "222222", R);
| public void | testRLtrRtl()
expectNativeBidi(REQ_R, "abc " + ALEF + BET + GIMEL, "2221111", R);
| public void | testRtlLtr()
expectNativeBidi(REQ_DL, ALEF + BET + GIMEL + " abc", "1111222", R);
|
|