use of android.text.StaticLayoutTest.LayoutBuilder in project android_frameworks_base by ResurrectionRemix.
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;
}
}
use of android.text.StaticLayoutTest.LayoutBuilder in project android_frameworks_base by crdroidandroid.
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());
}
}
use of android.text.StaticLayoutTest.LayoutBuilder in project android_frameworks_base by crdroidandroid.
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;
}
}
use of android.text.StaticLayoutTest.LayoutBuilder in project android_frameworks_base by crdroidandroid.
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);
}
use of android.text.StaticLayoutTest.LayoutBuilder in project android_frameworks_base by ParanoidAndroid.
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;
}
}
Aggregations