FileDocCategorySizeDatePackage
StaticLayoutBidiTest.javaAPI DocAndroid 5.1 API3621Thu Mar 12 22:22:12 GMT 2015android.text

StaticLayoutBidiTest

public 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
Constructors Summary
Methods Summary
private voidexpectNativeBidi(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 voidtestAllLtr()

    
    //@SmallTest
       
        expectNativeBidi(REQ_DL, "a test", "000000", L);
    
public voidtestAllRtl()

        expectNativeBidi(REQ_DL, ALEF + SP + ALEF + BET + GIMEL + DALET, "111111", R);
    
public voidtestLAllRtl()

        expectNativeBidi(REQ_L, ALEF + SP + ALEF + BET + GIMEL + DALET, "111111", L);
    
public voidtestLRtlLtr()

        expectNativeBidi(REQ_DL,  ALEF + BET + GIMEL + " abc", "1111222", R);
    
public voidtestLtrRtl()

        expectNativeBidi(REQ_DL, "abc " + ALEF + BET + GIMEL, "0000111", L);
    
public voidtestNativeBidi()

        expectNativeBidi(REQ_L,  ALEF + BET + GIMEL + " abc", "1110000", L);
    
public voidtestRAllLtr()

        expectNativeBidi(REQ_R, "a test", "222222", R);
    
public voidtestRLtrRtl()

        expectNativeBidi(REQ_R, "abc " + ALEF + BET + GIMEL, "2221111", R);
    
public voidtestRtlLtr()

        expectNativeBidi(REQ_DL,  ALEF + BET + GIMEL + " abc", "1111222", R);