Search in sources :

Example 16 with LayoutBuilder

use of android.text.StaticLayoutTest.LayoutBuilder in project platform_frameworks_base by android.

the class StaticLayoutDirectionsTest method testNextToLeftOf.

public void testNextToLeftOf() {
    LayoutBuilder b = StaticLayoutTest.builder();
    b.setText(pseudoBidiToReal("aA1B2"));
    int[] expected = { 0, 1, 4, 3, 2, 5 };
    Layout l = b.build();
    int n = 5;
    for (int i = expected.length - 1; --i >= 0; ) {
        int t = l.getOffsetToLeftOf(n);
        if (t != expected[i]) {
            fail("offset[" + i + "] to left of: " + n + " expected: " + expected[i] + " got: " + t);
        }
        n = t;
    }
}
Also used : LayoutBuilder(android.text.StaticLayoutTest.LayoutBuilder)

Example 17 with LayoutBuilder

use of android.text.StaticLayoutTest.LayoutBuilder in project platform_frameworks_base by android.

the class StaticLayoutDirectionsTest method testNextToRightOf.

public void testNextToRightOf() {
    LayoutBuilder b = StaticLayoutTest.builder();
    b.setText(pseudoBidiToReal("aA1B2"));
    // visual a2B1A positions 04321
    // 0: |a2B1A, strong is sol, after -> 0
    // 1: a|2B1A, strong is a, after ->, 1
    // 2: a2|B1A, strong is B, after -> 4
    // 3: a2B|1A, strong is B, before -> 3
    // 4: a2B1|A, strong is A, after -> 2
    // 5: a2B1A|, strong is eol, before -> 5
    int[] expected = { 0, 1, 4, 3, 2, 5 };
    Layout l = b.build();
    int n = 0;
    for (int i = 1; i < expected.length; ++i) {
        int t = l.getOffsetToRightOf(n);
        if (t != expected[i]) {
            fail("offset[" + i + "] to right of: " + n + " expected: " + expected[i] + " got: " + t);
        }
        n = t;
    }
}
Also used : LayoutBuilder(android.text.StaticLayoutTest.LayoutBuilder)

Example 18 with LayoutBuilder

use of android.text.StaticLayoutTest.LayoutBuilder in project android_frameworks_base by AOSPA.

the class StaticLayoutDirectionsTest method testDirections.

// @SmallTest
public void testDirections() {
    StringBuilder buf = new StringBuilder("\n");
    Formatter f = new Formatter(buf);
    LayoutBuilder b = StaticLayoutTest.builder();
    for (int i = 0; i < texts.length; ++i) {
        b.setText(pseudoBidiToReal(texts[i]));
        checkDirections(b.build(), i, b.text, expected, f);
    }
    if (buf.length() > 1) {
        fail(buf.toString());
    }
}
Also used : LayoutBuilder(android.text.StaticLayoutTest.LayoutBuilder) Formatter(java.util.Formatter)

Example 19 with LayoutBuilder

use of android.text.StaticLayoutTest.LayoutBuilder in project android_frameworks_base by AOSPA.

the class StaticLayoutDirectionsTest method testNextToRightOf.

public void testNextToRightOf() {
    LayoutBuilder b = StaticLayoutTest.builder();
    b.setText(pseudoBidiToReal("aA1B2"));
    // visual a2B1A positions 04321
    // 0: |a2B1A, strong is sol, after -> 0
    // 1: a|2B1A, strong is a, after ->, 1
    // 2: a2|B1A, strong is B, after -> 4
    // 3: a2B|1A, strong is B, before -> 3
    // 4: a2B1|A, strong is A, after -> 2
    // 5: a2B1A|, strong is eol, before -> 5
    int[] expected = { 0, 1, 4, 3, 2, 5 };
    Layout l = b.build();
    int n = 0;
    for (int i = 1; i < expected.length; ++i) {
        int t = l.getOffsetToRightOf(n);
        if (t != expected[i]) {
            fail("offset[" + i + "] to right of: " + n + " expected: " + expected[i] + " got: " + t);
        }
        n = t;
    }
}
Also used : LayoutBuilder(android.text.StaticLayoutTest.LayoutBuilder)

Example 20 with LayoutBuilder

use of android.text.StaticLayoutTest.LayoutBuilder in project android_frameworks_base by ResurrectionRemix.

the class StaticLayoutDirectionsTest method testNextToLeftOf.

public void testNextToLeftOf() {
    LayoutBuilder b = StaticLayoutTest.builder();
    b.setText(pseudoBidiToReal("aA1B2"));
    int[] expected = { 0, 1, 4, 3, 2, 5 };
    Layout l = b.build();
    int n = 5;
    for (int i = expected.length - 1; --i >= 0; ) {
        int t = l.getOffsetToLeftOf(n);
        if (t != expected[i]) {
            fail("offset[" + i + "] to left of: " + n + " expected: " + expected[i] + " got: " + t);
        }
        n = t;
    }
}
Also used : LayoutBuilder(android.text.StaticLayoutTest.LayoutBuilder)

Aggregations

LayoutBuilder (android.text.StaticLayoutTest.LayoutBuilder)24 Directions (android.text.Layout.Directions)6 Formatter (java.util.Formatter)6