Loading core/tests/coretests/src/android/text/StaticLayoutDirectionsTest.java +33 −23 Original line number Diff line number Diff line Loading @@ -16,10 +16,8 @@ package android.text; import android.test.suitebuilder.annotation.SmallTest; import android.text.Layout.Directions; import android.text.StaticLayoutTest.LayoutBuilder; import android.util.Log; import java.util.Arrays; import java.util.Formatter; Loading @@ -33,9 +31,20 @@ public class StaticLayoutDirectionsTest extends TestCase { return new Directions(dirs); } private static final int LVL1_1 = 1 | (1 << Layout.RUN_LEVEL_SHIFT); private static final int LVL2_1 = 1 | (2 << Layout.RUN_LEVEL_SHIFT); private static final int LVL2_2 = 2 | (2 << Layout.RUN_LEVEL_SHIFT); // constants from Layout that are package-protected private static final int RUN_LENGTH_MASK = 0x03ffffff; private static final int RUN_LEVEL_SHIFT = 26; private static final int RUN_LEVEL_MASK = 0x3f; private static final int RUN_RTL_FLAG = 1 << RUN_LEVEL_SHIFT; private static final Directions DIRS_ALL_LEFT_TO_RIGHT = new Directions(new int[] { 0, RUN_LENGTH_MASK }); private static final Directions DIRS_ALL_RIGHT_TO_LEFT = new Directions(new int[] { 0, RUN_LENGTH_MASK | RUN_RTL_FLAG }); private static final int LVL1_1 = 1 | (1 << RUN_LEVEL_SHIFT); private static final int LVL2_1 = 1 | (2 << RUN_LEVEL_SHIFT); private static final int LVL2_2 = 2 | (2 << RUN_LEVEL_SHIFT); private static String[] texts = { "", Loading Loading @@ -63,12 +72,12 @@ public class StaticLayoutDirectionsTest extends TestCase { // Expected directions are an array of start/length+level pairs, // in visual order from the leading margin. private static Directions[] expected = { Layout.DIRS_ALL_LEFT_TO_RIGHT, Layout.DIRS_ALL_LEFT_TO_RIGHT, Layout.DIRS_ALL_LEFT_TO_RIGHT, Layout.DIRS_ALL_LEFT_TO_RIGHT, DIRS_ALL_LEFT_TO_RIGHT, DIRS_ALL_LEFT_TO_RIGHT, DIRS_ALL_LEFT_TO_RIGHT, DIRS_ALL_LEFT_TO_RIGHT, dirs(0, 1, 1, LVL1_1), Layout.DIRS_ALL_LEFT_TO_RIGHT, DIRS_ALL_LEFT_TO_RIGHT, dirs(0, 2, 2, LVL1_1), dirs(0, 1, 2, LVL2_1, 1, LVL1_1), dirs(0, 1, 1, LVL1_1, 2, 1), Loading @@ -76,7 +85,7 @@ public class StaticLayoutDirectionsTest extends TestCase { dirs(0, 1, 4, LVL2_1, 3, LVL1_1, 2, LVL2_1, 1, LVL1_1), // rtl Layout.DIRS_ALL_RIGHT_TO_LEFT, DIRS_ALL_RIGHT_TO_LEFT, dirs(0, LVL1_1, 1, LVL2_1), dirs(0, LVL1_1, 1, LVL2_1), dirs(0, LVL1_1, 1, LVL2_1, 2, LVL1_1), Loading Loading @@ -167,6 +176,7 @@ public class StaticLayoutDirectionsTest extends TestCase { } // utility, not really a test /* public void testMeasureText1() { LayoutBuilder b = StaticLayoutTest.builder(); String text = "ABC"; // "abAB" Loading Loading @@ -196,8 +206,8 @@ public class StaticLayoutDirectionsTest extends TestCase { } } while (!trailing); } while (dir > 0); } */ // utility for displaying arrays in hex private static String hexArray(int[] array) { Loading Loading
core/tests/coretests/src/android/text/StaticLayoutDirectionsTest.java +33 −23 Original line number Diff line number Diff line Loading @@ -16,10 +16,8 @@ package android.text; import android.test.suitebuilder.annotation.SmallTest; import android.text.Layout.Directions; import android.text.StaticLayoutTest.LayoutBuilder; import android.util.Log; import java.util.Arrays; import java.util.Formatter; Loading @@ -33,9 +31,20 @@ public class StaticLayoutDirectionsTest extends TestCase { return new Directions(dirs); } private static final int LVL1_1 = 1 | (1 << Layout.RUN_LEVEL_SHIFT); private static final int LVL2_1 = 1 | (2 << Layout.RUN_LEVEL_SHIFT); private static final int LVL2_2 = 2 | (2 << Layout.RUN_LEVEL_SHIFT); // constants from Layout that are package-protected private static final int RUN_LENGTH_MASK = 0x03ffffff; private static final int RUN_LEVEL_SHIFT = 26; private static final int RUN_LEVEL_MASK = 0x3f; private static final int RUN_RTL_FLAG = 1 << RUN_LEVEL_SHIFT; private static final Directions DIRS_ALL_LEFT_TO_RIGHT = new Directions(new int[] { 0, RUN_LENGTH_MASK }); private static final Directions DIRS_ALL_RIGHT_TO_LEFT = new Directions(new int[] { 0, RUN_LENGTH_MASK | RUN_RTL_FLAG }); private static final int LVL1_1 = 1 | (1 << RUN_LEVEL_SHIFT); private static final int LVL2_1 = 1 | (2 << RUN_LEVEL_SHIFT); private static final int LVL2_2 = 2 | (2 << RUN_LEVEL_SHIFT); private static String[] texts = { "", Loading Loading @@ -63,12 +72,12 @@ public class StaticLayoutDirectionsTest extends TestCase { // Expected directions are an array of start/length+level pairs, // in visual order from the leading margin. private static Directions[] expected = { Layout.DIRS_ALL_LEFT_TO_RIGHT, Layout.DIRS_ALL_LEFT_TO_RIGHT, Layout.DIRS_ALL_LEFT_TO_RIGHT, Layout.DIRS_ALL_LEFT_TO_RIGHT, DIRS_ALL_LEFT_TO_RIGHT, DIRS_ALL_LEFT_TO_RIGHT, DIRS_ALL_LEFT_TO_RIGHT, DIRS_ALL_LEFT_TO_RIGHT, dirs(0, 1, 1, LVL1_1), Layout.DIRS_ALL_LEFT_TO_RIGHT, DIRS_ALL_LEFT_TO_RIGHT, dirs(0, 2, 2, LVL1_1), dirs(0, 1, 2, LVL2_1, 1, LVL1_1), dirs(0, 1, 1, LVL1_1, 2, 1), Loading @@ -76,7 +85,7 @@ public class StaticLayoutDirectionsTest extends TestCase { dirs(0, 1, 4, LVL2_1, 3, LVL1_1, 2, LVL2_1, 1, LVL1_1), // rtl Layout.DIRS_ALL_RIGHT_TO_LEFT, DIRS_ALL_RIGHT_TO_LEFT, dirs(0, LVL1_1, 1, LVL2_1), dirs(0, LVL1_1, 1, LVL2_1), dirs(0, LVL1_1, 1, LVL2_1, 2, LVL1_1), Loading Loading @@ -167,6 +176,7 @@ public class StaticLayoutDirectionsTest extends TestCase { } // utility, not really a test /* public void testMeasureText1() { LayoutBuilder b = StaticLayoutTest.builder(); String text = "ABC"; // "abAB" Loading Loading @@ -196,8 +206,8 @@ public class StaticLayoutDirectionsTest extends TestCase { } } while (!trailing); } while (dir > 0); } */ // utility for displaying arrays in hex private static String hexArray(int[] array) { Loading