Search in sources :

Example 1 with Directions

use of android.text.Layout.Directions in project android_frameworks_base by ParanoidAndroid.

the class StaticLayoutDirectionsTest method checkDirections.

private void checkDirections(Layout l, int i, String text, Directions[] expectedDirs, Formatter f) {
    Directions expected = expectedDirs[i];
    Directions result = l.getLineDirections(0);
    if (!Arrays.equals(expected.mDirections, result.mDirections)) {
        f.format("%n[%2d] '%s', %s != %s", i, text, hexArray(expected.mDirections), hexArray(result.mDirections));
    }
}
Also used : Directions(android.text.Layout.Directions)

Example 2 with Directions

use of android.text.Layout.Directions in project android_frameworks_base by ParanoidAndroid.

the class StaticLayoutDirectionsTest method testTrailingWhitespace.

// @SmallTest
public void testTrailingWhitespace() {
    LayoutBuilder b = StaticLayoutTest.builder();
    b.setText(pseudoBidiToReal("Ab   c"));
    // exclude 'c'
    float width = b.paint.measureText(b.text, 0, 5);
    b.setWidth(Math.round(width));
    Layout l = b.build();
    if (l.getLineCount() != 2) {
        throw new RuntimeException("expected 2 lines, got: " + l.getLineCount());
    }
    Directions result = l.getLineDirections(0);
    Directions expected = dirs(0, LVL1_1, 1, LVL2_1, 2, 3 | (1 << Layout.RUN_LEVEL_SHIFT));
    expectDirections("split line", expected, result);
}
Also used : LayoutBuilder(android.text.StaticLayoutTest.LayoutBuilder) Directions(android.text.Layout.Directions)

Example 3 with Directions

use of android.text.Layout.Directions in project platform_frameworks_base by android.

the class StaticLayoutDirectionsTest method checkDirections.

private void checkDirections(Layout l, int i, String text, Directions[] expectedDirs, Formatter f) {
    Directions expected = expectedDirs[i];
    Directions result = l.getLineDirections(0);
    if (!Arrays.equals(expected.mDirections, result.mDirections)) {
        f.format("%n[%2d] '%s', %s != %s", i, text, hexArray(expected.mDirections), hexArray(result.mDirections));
    }
}
Also used : Directions(android.text.Layout.Directions)

Example 4 with Directions

use of android.text.Layout.Directions in project platform_frameworks_base by android.

the class StaticLayoutDirectionsTest method testTrailingWhitespace.

// @SmallTest
public void testTrailingWhitespace() {
    LayoutBuilder b = StaticLayoutTest.builder();
    b.setText(pseudoBidiToReal("Ab   c"));
    // exclude 'c'
    float width = b.paint.measureText(b.text, 0, 5);
    b.setWidth(Math.round(width));
    Layout l = b.build();
    if (l.getLineCount() != 2) {
        throw new RuntimeException("expected 2 lines, got: " + l.getLineCount());
    }
    Directions result = l.getLineDirections(0);
    Directions expected = dirs(0, LVL1_1, 1, LVL2_1, 2, 3 | (1 << Layout.RUN_LEVEL_SHIFT));
    expectDirections("split line", expected, result);
}
Also used : LayoutBuilder(android.text.StaticLayoutTest.LayoutBuilder) Directions(android.text.Layout.Directions)

Example 5 with Directions

use of android.text.Layout.Directions in project android_frameworks_base by DirtyUnicorns.

the class StaticLayoutDirectionsTest method testTrailingWhitespace.

// @SmallTest
public void testTrailingWhitespace() {
    LayoutBuilder b = StaticLayoutTest.builder();
    b.setText(pseudoBidiToReal("Ab   c"));
    // exclude 'c'
    float width = b.paint.measureText(b.text, 0, 5);
    b.setWidth(Math.round(width));
    Layout l = b.build();
    if (l.getLineCount() != 2) {
        throw new RuntimeException("expected 2 lines, got: " + l.getLineCount());
    }
    Directions result = l.getLineDirections(0);
    Directions expected = dirs(0, LVL1_1, 1, LVL2_1, 2, 3 | (1 << Layout.RUN_LEVEL_SHIFT));
    expectDirections("split line", expected, result);
}
Also used : LayoutBuilder(android.text.StaticLayoutTest.LayoutBuilder) Directions(android.text.Layout.Directions)

Aggregations

Directions (android.text.Layout.Directions)12 LayoutBuilder (android.text.StaticLayoutTest.LayoutBuilder)6