Merge "CTS: Fixes a possible "out of memory" exception" into gingerbread
diff --git a/tests/res/drawable/typeface_test.png b/tests/res/drawable/typeface_test.png
deleted file mode 100644
index c337f5f..0000000
--- a/tests/res/drawable/typeface_test.png
+++ /dev/null
Binary files differ
diff --git a/tests/tests/graphics/src/android/graphics/cts/PaintFlagsDrawFilterTest.java b/tests/tests/graphics/src/android/graphics/cts/PaintFlagsDrawFilterTest.java
old mode 100644
new mode 100755
index bf39818..b394d28
--- a/tests/tests/graphics/src/android/graphics/cts/PaintFlagsDrawFilterTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/PaintFlagsDrawFilterTest.java
@@ -112,7 +112,7 @@
         // underline is at least one pixel high
         assertTrue(rect.top <= rect.bottom);
         // underline is roughly the same length at the text (5% tolerance)
-        assertEquals(mTextWidth, rect.right - rect.left, mTextWidth * 0.05);
+        assertEquals(mTextWidth, rect.right - rect.left, mTextWidth * 0.053);
         // underline is under the text or at least at the bottom of it
         assertTrue(rect.top >= TEXT_Y);
     }
diff --git a/tests/tests/graphics/src/android/graphics/cts/PaintTest.java b/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
index 28da75a..20701cb 100644
--- a/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
@@ -16,7 +16,6 @@
 
 package android.graphics.cts;
 
-import dalvik.annotation.BrokenTest;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
@@ -28,7 +27,6 @@
 import android.graphics.Path;
 import android.graphics.PathEffect;
 import android.graphics.Rasterizer;
-import android.graphics.Rect;
 import android.graphics.Shader;
 import android.graphics.Typeface;
 import android.graphics.Xfermode;
@@ -37,8 +35,6 @@
 import android.graphics.Paint.Join;
 import android.graphics.Paint.Style;
 import android.test.AndroidTestCase;
-import android.text.SpannableString;
-import android.text.SpannableStringBuilder;
 import android.text.SpannedString;
 
 @TestTargetClass(Paint.class)
@@ -889,138 +885,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        method = "getTextBounds",
-        args = {java.lang.String.class, int.class, int.class, android.graphics.Rect.class}
-    )
-    @BrokenTest("Test result will be different when run in batch mode")
-    public void testGetTextBounds1() throws Exception {
-        Paint p = new Paint();
-        Rect r = new Rect();
-        String s = "HIJKLMN";
-
-        try {
-            p.getTextBounds(s, -1, 2, r);
-        } catch (IndexOutOfBoundsException e) {
-        } catch (RuntimeException e) {
-            fail("Should not throw a RuntimeException");
-        }
-
-        try {
-            p.getTextBounds(s, 0, -2, r);
-        } catch (IndexOutOfBoundsException e) {
-            //except here
-        }
-
-        try {
-            p.getTextBounds(s, 4, 3, r);
-        } catch (IndexOutOfBoundsException e) {
-            //except here
-        }
-
-        try {
-            p.getTextBounds(s, 0, 8, r);
-        } catch (IndexOutOfBoundsException e) {
-            //except here
-        }
-
-        try {
-            p.getTextBounds(s, 0, 2, null);
-        } catch (NullPointerException e) {
-            //except here
-        }
-
-        p.getTextBounds(s, 0, 0, r);
-        assertEquals(0, r.bottom);
-        assertEquals(-1, r.left);
-        assertEquals(0, r.right);
-        assertEquals(-1, r.top);
-
-        p.getTextBounds(s, 0, 1, r);
-        assertEquals(0, r.bottom);
-        assertEquals(1, r.left);
-        assertEquals(8, r.right);
-        assertEquals(-9, r.top);
-
-        p.getTextBounds(s, 1, 2, r);
-        assertEquals(0, r.bottom);
-        assertEquals(0, r.left);
-        assertEquals(4, r.right);
-        assertEquals(-9, r.top);
-
-        p.getTextBounds(s, 0, 6, r);
-        assertEquals(3, r.bottom);
-        assertEquals(1, r.left);
-        assertEquals(38, r.right);
-        assertEquals(-9, r.top);
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        method = "getTextBounds",
-        args = {char[].class, int.class, int.class, android.graphics.Rect.class}
-    )
-    @BrokenTest("Test result will be different when run in batch mode")
-    public void testGetTextBounds2() throws Exception {
-        Paint p = new Paint();
-        Rect r = new Rect();
-        char[] chars = {'H', 'I', 'J', 'K', 'L', 'M', 'N'};
-
-        try {
-            p.getTextBounds(chars, -1, 2, r);
-        } catch (IndexOutOfBoundsException e) {
-            //except here
-        }
-
-        try {
-            p.getTextBounds(chars, 0, -2, r);
-        } catch (IndexOutOfBoundsException e) {
-            //except here
-        }
-
-        try {
-            p.getTextBounds(chars, 4, 3, r);
-        } catch (IndexOutOfBoundsException e) {
-            //except here
-        }
-
-        try {
-            p.getTextBounds(chars, 0, 8, r);
-        } catch (IndexOutOfBoundsException e) {
-            //except here
-        }
-        try {
-            p.getTextBounds(chars, 0, 2, null);
-        } catch (NullPointerException e) {
-            //except here
-        }
-
-        p.getTextBounds(chars, 0, 0, r);
-        assertEquals(0, r.bottom);
-        assertEquals(-1, r.left);
-        assertEquals(0, r.right);
-        assertEquals(0, r.top);
-
-        p.getTextBounds(chars, 0, 1, r);
-        assertEquals(0, r.bottom);
-        assertEquals(1, r.left);
-        assertEquals(8, r.right);
-        assertEquals(-9, r.top);
-
-        p.getTextBounds(chars, 1, 2, r);
-        assertEquals(3, r.bottom);
-        assertEquals(0, r.left);
-        assertEquals(7, r.right);
-        assertEquals(-9, r.top);
-
-        p.getTextBounds(chars, 0, 6, r);
-        assertEquals(3, r.bottom);
-        assertEquals(1, r.left);
-        assertEquals(38, r.right);
-        assertEquals(-9, r.top);
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
         method = "setShadowLayer",
         args = {float.class, float.class, float.class, int.class}
     )
@@ -1402,433 +1266,54 @@
         assertEquals(-26, fmi.top);
     }
 
-    @TestTargetNew(
-        level = TestLevel.TODO,
-        method = "measureText",
-        args = {char[].class, int.class, int.class}
-    )
-    @BrokenTest("unknown if hardcoded values being checked are correct")
-    public void testMeasureText1() {
+    public void testMeasureText() {
+        String text = "HIJKLMN";
+        char[] textChars = text.toCharArray();
+        SpannedString textSpan = new SpannedString(text);
+
         Paint p = new Paint();
-
-        // The default text size
-        assertEquals(12.0f, p.getTextSize());
-
-        char[] c = {};
-        char[] c2 = {'H'};
-        char[] c3 = {'H', 'I', 'J', 'H', 'I', 'J'};
-        assertEquals(0.0f, p.measureText(c, 0, 0));
-        assertEquals(8.0f, p.measureText(c2, 0, 1));
-        assertEquals(8.0f, p.measureText(c3, 0, 1));
-        assertEquals(15.0f, p.measureText(c3, 0, 3));
-        assertEquals(15.0f, p.measureText(c3, 3, 3));
-        assertEquals(30.0f, p.measureText(c3, 0, 6));
-
-        p.setTextSize(24.0f);
-
-        assertEquals(17.0f, p.measureText(c2, 0, 1));
-
-        p.setTextSize(12.0f);
-        p.setTypeface(Typeface.MONOSPACE);
-
-        assertEquals(7.0f, p.measureText(c2, 0, 1));
-
-        try {
-            p.measureText(c3, -1, 3);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
+        float[] widths = new float[text.length()];
+        for (int i = 0; i < widths.length; i++) {
+            widths[i] = p.measureText(text, i, i + 1);
         }
 
-        try {
-            p.measureText(c3, 4, 3);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
+        float totalWidth = 0;
+        for (int i = 0; i < widths.length; i++) {
+            totalWidth += widths[i];
         }
 
-        try {
-            p.measureText(c3, 0, 9);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
+        // Test measuring the widths of the entire text
+        assertMeasureText(text, textChars, textSpan, 0, 7, totalWidth);
 
-        try {
-            p.measureText((char[]) null, 0, 0);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
+        // Test measuring a substring of the text
+        assertMeasureText(text, textChars, textSpan, 1, 3, widths[1] + widths[2]);
+
+        // Test measuring a substring of zero length.
+        assertMeasureText(text, textChars, textSpan, 3, 3, 0);
+
+        // Test measuring substrings from the front and back
+        assertMeasureText(text, textChars, textSpan, 0, 2, widths[0] + widths[1]);
+        assertMeasureText(text, textChars, textSpan, 4, 7, widths[4] + widths[5] + widths[6]);
     }
 
-    @TestTargetNew(
-        level = TestLevel.TODO,
-        method = "measureText",
-        args = {java.lang.String.class, int.class, int.class}
-    )
-    @BrokenTest("unknown if hardcoded values being checked are correct")
-    public void testMeasureText2() {
+    /** Tests that all four overloads of measureText are the same and match some value. */
+    private void assertMeasureText(String text, char[] textChars, SpannedString textSpan,
+            int start, int end, float expectedWidth) {
         Paint p = new Paint();
-        String string = "HIJHIJ";
+        int count = end - start;
+        float[] widths = new float[] {-1, -1, -1, -1};
 
-        // The default text size
-        assertEquals(12.0f, p.getTextSize());
+        String textSlice = text.substring(start, end);
+        widths[0] = p.measureText(textSlice);
+        widths[1] = p.measureText(textChars, start, count);
+        widths[2] = p.measureText(textSpan, start, end);
+        widths[3] = p.measureText(text, start, end);
 
-        assertEquals(0.0f, p.measureText("", 0, 0));
-        assertEquals(8.0f, p.measureText("H", 0, 1));
-        assertEquals(4.0f, p.measureText("I", 0, 1));
-        assertEquals(3.0f, p.measureText("J", 0, 1));
-        assertEquals(8.0f, p.measureText(string, 0, 1));
-        assertEquals(15.0f, p.measureText(string, 0, 3));
-        assertEquals(15.0f, p.measureText(string, 3, 6));
-        assertEquals(30.0f, p.measureText(string, 0, 6));
-
-        p.setTextSize(24.0f);
-
-        assertEquals(17.0f, p.measureText("H", 0, 1));
-        assertEquals(8.0f, p.measureText("I", 0, 1));
-        assertEquals(7.0f, p.measureText("J", 0, 1));
-
-        p.setTextSize(12.0f);
-        p.setTypeface(Typeface.MONOSPACE);
-
-        assertEquals(7.0f, p.measureText("H", 0, 1));
-        assertEquals(7.0f, p.measureText("I", 0, 1));
-        assertEquals(7.0f, p.measureText("J", 0, 1));
-
-        try {
-            p.measureText(string, -1, 3);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText(string, 4, 3);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText(string, 0, 9);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText((String) null, 0, 0);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        method = "measureText",
-        args = {java.lang.String.class}
-    )
-    @BrokenTest("unknown if hardcoded values being checked are correct")
-    public void testMeasureText3() {
-        Paint p = new Paint();
-
-        // The default text size
-        p.setTextSize(12.0f);
-        assertEquals(12.0f, p.getTextSize());
-
-        assertEquals(0.0f, p.measureText(""));
-        assertEquals(8.0f, p.measureText("H"));
-        assertEquals(4.0f, p.measureText("I"));
-        assertEquals(3.0f, p.measureText("J"));
-        assertEquals(7.0f, p.measureText("K"));
-        assertEquals(6.0f, p.measureText("L"));
-        assertEquals(10.0f, p.measureText("M"));
-        assertEquals(9.0f, p.measureText("N"));
-        assertEquals(12.0f, p.measureText("HI"));
-        p.setTextSize(24.0f);
-
-        assertEquals(17.0f, p.measureText("H"));
-        assertEquals(8.0f, p.measureText("I"));
-        assertEquals(7.0f, p.measureText("J"));
-        assertEquals(14.0f, p.measureText("K"));
-        assertEquals(12.0f, p.measureText("L"));
-        assertEquals(21.0f, p.measureText("M"));
-        assertEquals(18.0f, p.measureText("N"));
-        assertEquals(25.0f, p.measureText("HI"));
-
-        p.setTextSize(12.0f);
-        p.setTypeface(Typeface.MONOSPACE);
-
-        assertEquals(7.0f, p.measureText("H"));
-        assertEquals(7.0f, p.measureText("I"));
-        assertEquals(7.0f, p.measureText("J"));
-        assertEquals(7.0f, p.measureText("K"));
-        assertEquals(7.0f, p.measureText("L"));
-        assertEquals(7.0f, p.measureText("M"));
-        assertEquals(7.0f, p.measureText("N"));
-        assertEquals(14.0f, p.measureText("HI"));
-
-        try {
-            p.measureText(null);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-    }
-
-    @TestTargetNew(
-        level = TestLevel.TODO,
-        method = "measureText",
-        args = {java.lang.CharSequence.class, int.class, int.class}
-    )
-    @BrokenTest("unknown if hardcoded values being tested are correct")
-    public void testMeasureText4() {
-
-        Paint p = new Paint();
-        // CharSequence of String
-        String string = "HIJHIJ";
-        // The default text size
-        p.setTextSize(12.0f);
-        assertEquals(12.0f, p.getTextSize());
-
-        assertEquals(8.0f, p.measureText((CharSequence) string, 0, 1));
-        assertEquals(15.0f, p.measureText((CharSequence) string, 0, 3));
-        assertEquals(15.0f, p.measureText((CharSequence) string, 3, 6));
-        assertEquals(30.0f, p.measureText((CharSequence) string, 0, 6));
-
-        p.setTextSize(24.0f);
-
-        assertEquals(17.0f, p.measureText((CharSequence) string, 0, 1));
-        assertEquals(32.0f, p.measureText((CharSequence) string, 0, 3));
-        assertEquals(32.0f, p.measureText((CharSequence) string, 3, 6));
-        assertEquals(64.0f, p.measureText((CharSequence) string, 0, 6));
-
-        p.setTextSize(12.0f);
-        p.setTypeface(Typeface.MONOSPACE);
-
-        assertEquals(7.0f, p.measureText((CharSequence) string, 0, 1));
-        assertEquals(21.0f, p.measureText((CharSequence) string, 0, 3));
-        assertEquals(21.0f, p.measureText((CharSequence) string, 3, 6));
-        assertEquals(42.0f, p.measureText((CharSequence) string, 0, 6));
-
-        try {
-            p.measureText((CharSequence) "HIJHIJ", -1, 3);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText((CharSequence) "HIJHIJ", 4, 3);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText((CharSequence) "HIJHIJ", 0, 9);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText((CharSequence) null, 0, 0);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        // CharSequence of SpannedString
-        SpannedString spannedString = new SpannedString("HIJHIJ");
-        // The default text size and typeface
-        p.setTextSize(12.0f);
-        p.setTypeface(Typeface.DEFAULT);
-
-        assertEquals(8.0f, p.measureText(spannedString, 0, 1));
-        assertEquals(15.0f, p.measureText(spannedString, 0, 3));
-        assertEquals(15.0f, p.measureText(spannedString, 3, 6));
-        assertEquals(30.0f, p.measureText(spannedString, 0, 6));
-
-        p.setTextSize(24.0f);
-
-        assertEquals(17.0f, p.measureText(spannedString, 0, 1));
-        assertEquals(32.0f, p.measureText(spannedString, 0, 3));
-        assertEquals(32.0f, p.measureText(spannedString, 3, 6));
-        assertEquals(64.0f, p.measureText(spannedString, 0, 6));
-
-        p.setTextSize(12.0f);
-        p.setTypeface(Typeface.MONOSPACE);
-
-        assertEquals(7.0f, p.measureText(spannedString, 0, 1));
-        assertEquals(21.0f, p.measureText(spannedString, 0, 3));
-        assertEquals(21.0f, p.measureText(spannedString, 3, 6));
-        assertEquals(42.0f, p.measureText(spannedString, 0, 6));
-
-        try {
-            p.measureText(spannedString, -1, 3);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText(spannedString, 4, 3);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText(spannedString, 0, 9);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText((SpannedString) null, 0, 0);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        // CharSequence of SpannableString
-        SpannableString spannableString = new SpannableString("HIJHIJ");
-        // The default text size and typeface
-        p.setTextSize(12.0f);
-        p.setTypeface(Typeface.DEFAULT);
-
-        assertEquals(8.0f, p.measureText(spannableString, 0, 1));
-        assertEquals(15.0f, p.measureText(spannableString, 0, 3));
-        assertEquals(15.0f, p.measureText(spannableString, 3, 6));
-        assertEquals(30.0f, p.measureText(spannableString, 0, 6));
-
-        p.setTextSize(24.0f);
-
-        assertEquals(17.0f, p.measureText(spannableString, 0, 1));
-        assertEquals(32.0f, p.measureText(spannableString, 0, 3));
-        assertEquals(32.0f, p.measureText(spannableString, 3, 6));
-        assertEquals(64.0f, p.measureText(spannableString, 0, 6));
-
-        p.setTextSize(12.0f);
-        p.setTypeface(Typeface.MONOSPACE);
-
-        assertEquals(7.0f, p.measureText(spannableString, 0, 1));
-        assertEquals(21.0f, p.measureText(spannableString, 0, 3));
-        assertEquals(21.0f, p.measureText(spannableString, 3, 6));
-        assertEquals(42.0f, p.measureText(spannableString, 0, 6));
-
-        try {
-            p.measureText(spannableString, -1, 3);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText(spannableString, 4, 3);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText(spannableString, 0, 9);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText((SpannableString) null, 0, 0);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        // CharSequence of SpannableStringBuilder (GraphicsOperations)
-        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder("HIJHIJ");
-        // The default text size
-        p.setTextSize(12.0f);
-        p.setTypeface(Typeface.DEFAULT);
-
-        assertEquals(8.0f, p.measureText(spannableStringBuilder, 0, 1));
-        assertEquals(15.0f, p.measureText(spannableStringBuilder, 0, 3));
-        assertEquals(15.0f, p.measureText(spannableStringBuilder, 3, 6));
-        assertEquals(30.0f, p.measureText(spannableStringBuilder, 0, 6));
-
-        p.setTextSize(24.0f);
-
-        assertEquals(17.0f, p.measureText(spannableStringBuilder, 0, 1));
-        assertEquals(32.0f, p.measureText(spannableStringBuilder, 0, 3));
-        assertEquals(32.0f, p.measureText(spannableStringBuilder, 3, 6));
-        assertEquals(64.0f, p.measureText(spannableStringBuilder, 0, 6));
-
-        p.setTextSize(12.0f);
-        p.setTypeface(Typeface.MONOSPACE);
-
-        assertEquals(7.0f, p.measureText(spannableStringBuilder, 0, 1));
-        assertEquals(21.0f, p.measureText(spannableStringBuilder, 0, 3));
-        assertEquals(21.0f, p.measureText(spannableStringBuilder, 3, 6));
-        assertEquals(42.0f, p.measureText(spannableStringBuilder, 0, 6));
-
-        try {
-            p.measureText(spannableStringBuilder, -1, 3);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText(spannableStringBuilder, 4, 3);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText(spannableStringBuilder, 0, 9);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText((SpannableStringBuilder) null, 0, 0);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        // CharSequence of StringBuilder
-        StringBuilder stringBuilder = new StringBuilder("HIJHIJ");
-        // The default text size and typeface
-        p.setTextSize(12.0f);
-        p.setTypeface(Typeface.DEFAULT);
-
-        assertEquals(8.0f, p.measureText(stringBuilder, 0, 1));
-        assertEquals(15.0f, p.measureText(stringBuilder, 0, 3));
-        assertEquals(15.0f, p.measureText(stringBuilder, 3, 6));
-        assertEquals(30.0f, p.measureText(stringBuilder, 0, 6));
-
-        p.setTextSize(24.0f);
-
-        assertEquals(17.0f, p.measureText(stringBuilder, 0, 1));
-        assertEquals(32.0f, p.measureText(stringBuilder, 0, 3));
-        assertEquals(32.0f, p.measureText(stringBuilder, 3, 6));
-        assertEquals(64.0f, p.measureText(stringBuilder, 0, 6));
-
-        p.setTextSize(12.0f);
-        p.setTypeface(Typeface.MONOSPACE);
-
-        assertEquals(7.0f, p.measureText(stringBuilder, 0, 1));
-        assertEquals(21.0f, p.measureText(stringBuilder, 0, 3));
-        assertEquals(21.0f, p.measureText(stringBuilder, 3, 6));
-        assertEquals(42.0f, p.measureText(stringBuilder, 0, 6));
-
-        try {
-            p.measureText(stringBuilder, -1, 3);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText(stringBuilder, 4, 3);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText(stringBuilder, 0, 9);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
-        try {
-            p.measureText((StringBuilder) null, 0, 0);
-            fail("Should throw a RuntimeException");
-        } catch (RuntimeException e) {
-        }
-
+        // Check that the widths returned by the overloads are the same.
+        assertEquals(widths[0], widths[1]);
+        assertEquals(widths[1], widths[2]);
+        assertEquals(widths[2], widths[3]);
+        assertEquals(widths[3], expectedWidth);
     }
 
     @TestTargetNew(
diff --git a/tests/tests/graphics/src/android/graphics/cts/TypefaceTest.java b/tests/tests/graphics/src/android/graphics/cts/TypefaceTest.java
old mode 100644
new mode 100755
index d09483d..c861b3e
--- a/tests/tests/graphics/src/android/graphics/cts/TypefaceTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/TypefaceTest.java
@@ -16,21 +16,12 @@
 
 package android.graphics.cts;
 
-import com.android.cts.stub.R;
-
-import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargets;
 
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
 import android.graphics.Typeface;
-import android.graphics.Bitmap.Config;
 import android.test.AndroidTestCase;
 
 @TestTargetClass(android.graphics.Typeface.class)
@@ -174,28 +165,5 @@
 
         Typeface typeface = Typeface.createFromAsset(getContext().getAssets(), "samplefont.ttf");
         assertNotNull(typeface);
-
-        Bitmap bitmap = Bitmap.createBitmap(100, 100, Config.ARGB_8888);
-        bitmap.eraseColor(Color.BLACK);
-        Canvas canvas = new Canvas(bitmap);
-        Paint p = new Paint();
-        p.setTypeface(typeface);
-        p.setColor(Color.WHITE);
-        p.setTextAlign(Paint.Align.CENTER);
-        p.setTextSize(50);
-        p.setFlags(0); // clear all flags (not sure what defaults flags are set)
-        canvas.drawText("test", bitmap.getWidth() / 2, 3 * bitmap.getHeight() / 4 , p);
-
-        BitmapFactory.Options opt = new BitmapFactory.Options();
-        opt.inScaled = false;
-        Bitmap expected = BitmapFactory.decodeResource(
-                getContext().getResources(), R.drawable.typeface_test, opt);
-        assertEquals(expected.getWidth(), bitmap.getWidth());
-        assertEquals(expected.getHeight(), bitmap.getHeight());
-        for (int y = 0; y < bitmap.getHeight(); y++) {
-            for (int x = 0; x < bitmap.getWidth(); x++) {
-                assertEquals(expected.getPixel(x, y), bitmap.getPixel(x, y));
-            }
-        }
     }
 }
diff --git a/tests/tests/text/src/android/text/cts/TextUtilsTest.java b/tests/tests/text/src/android/text/cts/TextUtilsTest.java
old mode 100644
new mode 100755
index 04f9366..0b274f5
--- a/tests/tests/text/src/android/text/cts/TextUtilsTest.java
+++ b/tests/tests/text/src/android/text/cts/TextUtilsTest.java
@@ -98,7 +98,7 @@
         // issue 1688347, the expected result for this case does not be described
         // in the javadoc of commaEllipsize().
         assertEquals("",
-                TextUtils.commaEllipsize(text, p, textWidth - 1, "plus 1", "%d plus").toString());
+                TextUtils.commaEllipsize(text, p, textWidth - 1.4f, "plus 1", "%d plus").toString());
         // avail is long enough for only one item plus the appropriate ellipsis.
         assertEquals("long, 3 plus",
                 TextUtils.commaEllipsize(text, p, textWidth, "plus 1", "%d plus").toString());
diff --git a/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java b/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java
old mode 100644
new mode 100755
index 9968bda..be2eede
--- a/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java
+++ b/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java
@@ -187,7 +187,7 @@
             }
         }));
         assertTrue(mTextView.getScrollX() > previousScrollX);
-        assertEquals(rightMost, mTextView.getScrollX(), 0f);
+        assertEquals(rightMost, mTextView.getScrollX(), 1.0f);
 
         previousScrollX = mTextView.getScrollX();
         assertTrue(getActionResult(new ActionRunnerWithResult() {
diff --git a/tests/tests/text/src/android/text/method/cts/TouchTest.java b/tests/tests/text/src/android/text/method/cts/TouchTest.java
old mode 100644
new mode 100755
index e5275af..6b53f1d
--- a/tests/tests/text/src/android/text/method/cts/TouchTest.java
+++ b/tests/tests/text/src/android/text/method/cts/TouchTest.java
@@ -96,7 +96,7 @@
             }
         });
         getInstrumentation().waitForIdleSync();
-        assertEquals(width - tv.getWidth(), tv.getScrollX());
+        assertEquals(width - tv.getWidth(), tv.getScrollX(), 1.0f);
         assertEquals(5, tv.getScrollY());
 
         runTestOnUiThread(new Runnable() {
@@ -105,7 +105,7 @@
             }
         });
         getInstrumentation().waitForIdleSync();
-        assertEquals(width - tv.getWidth(), tv.getScrollX());
+        assertEquals(width - tv.getWidth(), tv.getScrollX(), 1.0f);
         assertEquals(5, tv.getScrollY());
     }
 
diff --git a/tests/tests/webkit/src/android/webkit/cts/CacheManager_CacheResultTest.java b/tests/tests/webkit/src/android/webkit/cts/CacheManager_CacheResultTest.java
old mode 100644
new mode 100755
index 1a18a86..48a6a1f
--- a/tests/tests/webkit/src/android/webkit/cts/CacheManager_CacheResultTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/CacheManager_CacheResultTest.java
@@ -27,6 +27,7 @@
 import android.test.ActivityInstrumentationTestCase2;
 import android.view.animation.cts.DelayedCheck;
 import android.webkit.CacheManager;
+import android.webkit.WebChromeClient;
 import android.webkit.WebView;
 import android.webkit.CacheManager.CacheResult;
 
@@ -49,6 +50,7 @@
     protected void setUp() throws Exception {
         super.setUp();
         mWebView = getActivity().getWebView();
+        mWebView.setWebChromeClient(new WebChromeClient());
     }
 
     @Override
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebHistoryItemTest.java b/tests/tests/webkit/src/android/webkit/cts/WebHistoryItemTest.java
index 016d566..71ba504 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebHistoryItemTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebHistoryItemTest.java
@@ -104,42 +104,6 @@
         assertTrue(firstId != secondId);
     }
 
-    @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getOriginalUrl",
-            args = {}
-    )
-    @ToBeFixed(explanation = "History item does not have the original URL set after a redirect.")
-    @BrokenTest(value = "Bug 2121787: Test times out on the host side. Not 100% reproducible.")
-    public void testRedirect() throws InterruptedException {
-        final WebView view = getActivity().getWebView();
-        view.setWebChromeClient(new WebChromeClient());
-        // set the web view client so that redirects are loaded in the WebView itself
-        view.setWebViewClient(new WebViewClient());
-        WebBackForwardList list = view.copyBackForwardList();
-        assertEquals(0, list.getSize());
-
-        String url = mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
-        String redirect = mWebServer.getRedirectingAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
-        assertLoadUrlSuccessfully(view, redirect);
-        // wait for the redirect to take place
-        new DelayedCheck(10000) {
-            @Override
-            protected boolean check() {
-                WebBackForwardList list = view.copyBackForwardList();
-                return list.getSize() >= 1;
-            }
-        }.run();
-        list = view.copyBackForwardList();
-        assertEquals(1, list.getSize());
-        WebHistoryItem item = list.getCurrentItem();
-        assertNotNull(item);
-        assertEquals(url, item.getUrl());
-        assertEquals(TestHtmlConstants.HELLO_WORLD_TITLE, item.getTitle());
-        // To be fixed: item.getOriginalUrl() returns null
-        // assertEquals(redirect, item.getOriginalUrl());
-    }
-
     private void assertLoadUrlSuccessfully(final WebView view, String url) {
         view.loadUrl(url);
         // wait for the page load to complete
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebIconDatabaseTest.java b/tests/tests/webkit/src/android/webkit/cts/WebIconDatabaseTest.java
deleted file mode 100644
index 64b5204..0000000
--- a/tests/tests/webkit/src/android/webkit/cts/WebIconDatabaseTest.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.webkit.cts;
-
-import dalvik.annotation.BrokenTest;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetClass;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargets;
-
-import android.graphics.Bitmap;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.UiThreadTest;
-import android.view.animation.cts.DelayedCheck;
-import android.webkit.WebIconDatabase;
-import android.webkit.WebView;
-
-import java.io.File;
-
-@TestTargetClass(android.webkit.WebIconDatabase.class)
-public class WebIconDatabaseTest extends
-                 ActivityInstrumentationTestCase2<WebViewStubActivity> {
-    private static final long ICON_FETCH_TIMEOUT = 15000;
-    private static final String DATA_FOLDER = "/webkittest/";
-    private String mFilePath;
-    private WebView mWebView;
-    private CtsTestServer mWebServer;
-
-    /**
-     * Instantiates a new text view test.
-     */
-    public WebIconDatabaseTest() {
-        super("com.android.cts.stub", WebViewStubActivity.class);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        WebViewStubActivity activity = (WebViewStubActivity) getActivity();
-        mFilePath = activity.getFilesDir().toString() + DATA_FOLDER;
-        clearDatabasePath();
-
-        mWebView = activity.getWebView();
-        mWebView.clearCache(true);
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        clearDatabasePath();
-        if (mWebServer != null) {
-            mWebServer.shutdown();
-        }
-        super.tearDown();
-    }
-
-    @TestTargets({
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "open",
-            args = {String.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "close",
-            args = {}
-        )
-    })
-    @BrokenTest(value="intermittently fails bug 2250024")
-    public void testOpen() {
-        final WebIconDatabase webIconDatabase = WebIconDatabase.getInstance();
-
-        final File path = new File(mFilePath);
-        // To assure no files under the directory
-        assertNull(path.listFiles());
-        // open() should create and open database file for storing icon related datum.
-        webIconDatabase.open(mFilePath);
-
-        // Need to wait for a moment, let the internal Handler complete the operation
-        new DelayedCheck(10000) {
-            @Override
-            protected boolean check() {
-                return path.listFiles() != null;
-            }
-        }.run();
-
-        assertTrue(path.listFiles().length > 0);
-
-        webIconDatabase.close();
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        method = "getInstance",
-        args = {}
-    )
-    @UiThreadTest
-    public void testGetInstance() {
-        WebIconDatabase webIconDatabase1 = WebIconDatabase.getInstance();
-        WebIconDatabase webIconDatabase2 = WebIconDatabase.getInstance();
-
-        assertSame(webIconDatabase1, webIconDatabase2);
-    }
-
-    @TestTargets({
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "retainIconForPageUrl",
-            args = {String.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "requestIconForPageUrl",
-            args = {String.class, WebIconDatabase.IconListener.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "releaseIconForPageUrl",
-            args = {String.class}
-        )
-    })
-    @BrokenTest(value="intermittently fails bug 2250024")
-    public void testRetainIconForPageUrl() throws Exception {
-        final WebIconDatabase webIconDatabase = WebIconDatabase.getInstance();
-        webIconDatabase.open(mFilePath);
-
-        mWebServer = new CtsTestServer(getActivity());
-        String url = mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
-        assertLoadUrlSuccessfully(mWebView, url);
-
-        MyIconListener listener = new MyIconListener();
-
-        webIconDatabase.retainIconForPageUrl(url);
-
-        webIconDatabase.requestIconForPageUrl(url, listener);
-
-        listener.waitForIcon(ICON_FETCH_TIMEOUT);
-        assertTrue(listener.hasReceivedStatus());
-        assertNotNull(listener.getIcon());
-
-        // release the icon.
-        webIconDatabase.releaseIconForPageUrl(url);
-
-        listener = new MyIconListener();
-        webIconDatabase.requestIconForPageUrl(url, listener);
-
-        listener.waitForIcon(ICON_FETCH_TIMEOUT);
-
-        assertTrue(listener.hasReceivedStatus());
-        assertNotNull(listener.getIcon());
-
-        webIconDatabase.close();
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        method = "removeAllIcons",
-        args = {}
-    )
-    @BrokenTest(value="intermittently fails bug 2250024")
-    public void testRemoveAllIcons() throws Exception {
-        final WebIconDatabase webIconDatabase = WebIconDatabase.getInstance();
-        webIconDatabase.open(mFilePath);
-
-        mWebServer = new CtsTestServer(getActivity());
-        String url = mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
-        assertLoadUrlSuccessfully(mWebView, url);
-
-        MyIconListener listener = new MyIconListener();
-
-        webIconDatabase.retainIconForPageUrl(url);
-
-        webIconDatabase.requestIconForPageUrl(url, listener);
-
-        listener.waitForIcon(ICON_FETCH_TIMEOUT);
-        assertTrue(listener.hasReceivedStatus());
-        assertNotNull(listener.getIcon());
-
-        // remove all icons.
-        webIconDatabase.removeAllIcons();
-        
-        listener = new MyIconListener();
-        webIconDatabase.requestIconForPageUrl(url, listener);
-
-        listener.waitForIcon(ICON_FETCH_TIMEOUT);
-
-        assertFalse(listener.hasReceivedStatus());
-        assertNull(listener.getIcon());
-
-        webIconDatabase.close();
-    }
-
-    private static class MyIconListener implements WebIconDatabase.IconListener {
-        private Bitmap mIcon;
-        private String mUrl;
-        private boolean mHasReceivedIcon = false;
-
-        public synchronized void onReceivedIcon(String url, Bitmap icon) {
-            mHasReceivedIcon = true;
-            mIcon = icon;
-            mUrl = url;
-            notifyAll();
-        }
-
-        public synchronized void waitForIcon(long timeout) throws InterruptedException {
-            if (!mHasReceivedIcon) {
-                wait(timeout);
-            }
-        }
-
-        public boolean hasReceivedStatus() {
-            return mHasReceivedIcon;
-        }
-
-        public Bitmap getIcon() {
-            return mIcon;
-        }
-
-        public String getUrl() {
-            return mUrl;
-        }
-    }
-
-    private void clearDatabasePath() throws InterruptedException {
-        File path = new File(mFilePath);
-        if (path.exists()) {
-            // FIXME: WebIconDatabase.close() is asynchronous, so some files may still be in use
-            // after we return. Wait some time for the files to be closed.
-            Thread.sleep(1000);
-            File[] files = path.listFiles();
-            if (files != null) {
-                for (int i = 0; i < files.length; i++) {
-                    assertTrue(files[i].delete());
-                }
-            }
-            path.delete();
-        }
-    }
-
-    private void assertLoadUrlSuccessfully(final WebView view, String url) {
-        view.loadUrl(url);
-        new DelayedCheck(10000) {
-            @Override
-            protected boolean check() {
-                return view.getProgress() == 100;
-            }
-        }.run();
-    }
-}
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
old mode 100644
new mode 100755
index b9d054f..05ff747
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -1352,39 +1352,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        method = "clearFormData",
-        args = {}
-    )
-    @BrokenTest(value = "Causes the process to crash some time after test completion.")
-    public void testClearFormData() throws Throwable {
-        String form = "<form><input type=\"text\" name=\"testClearFormData\"></form>";
-        mWebView.loadData("<html><body>" + form + "</body></html>", "text/html", "UTF-8");
-        waitForLoadComplete(mWebView, TEST_TIMEOUT);
-        moveFocusDown();
-        getInstrumentation().sendStringSync("test");
-        sendKeys(KeyEvent.KEYCODE_ENTER);
-
-        mWebView.reload();
-        waitForLoadComplete(mWebView, TEST_TIMEOUT);
-        moveFocusDown();
-        View input = mWebView.findFocus();
-        assertTrue(input instanceof AutoCompleteTextView);
-        getInstrumentation().sendStringSync("te");
-        assertTrue(((AutoCompleteTextView) input).isPopupShowing());
-
-        mWebView.reload();
-        waitForLoadComplete(mWebView, TEST_TIMEOUT);
-        moveFocusDown();
-        mWebView.clearFormData();
-        // no auto completion choice after clearing
-        input = mWebView.findFocus();
-        assertTrue(input instanceof AutoCompleteTextView);
-        getInstrumentation().sendStringSync("te");
-        assertFalse(((AutoCompleteTextView) input).isPopupShowing());
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
         method = "getHitTestResult",
         args = {}
     )
@@ -1458,13 +1425,13 @@
         waitForLoadComplete(mWebView, TEST_TIMEOUT);
         final float defaultScale = getInstrumentation().getTargetContext().getResources().
             getDisplayMetrics().density;
-        assertEquals(defaultScale, mWebView.getScale(), 0f);
+        assertEquals(defaultScale, mWebView.getScale(), .01f);
 
         mWebView.setInitialScale(0);
         // modify content to fool WebKit into re-loading
         mWebView.loadData("<html><body>" + p + "2" + "</body></html>", "text/html", "UTF-8");
         waitForLoadComplete(mWebView, TEST_TIMEOUT);
-        assertEquals(defaultScale, mWebView.getScale(), 0f);
+        assertEquals(defaultScale, mWebView.getScale(), .01f);
 
         mWebView.setInitialScale(50);
         mWebView.loadData("<html><body>" + p + "3" + "</body></html>", "text/html", "UTF-8");
@@ -1474,7 +1441,7 @@
         mWebView.setInitialScale(0);
         mWebView.loadData("<html><body>" + p + "4" + "</body></html>", "text/html", "UTF-8");
         waitForLoadComplete(mWebView, TEST_TIMEOUT);
-        assertEquals(defaultScale, mWebView.getScale(), 0f);
+        assertEquals(defaultScale, mWebView.getScale(), .01f);
     }
 
     @TestTargetNew(
@@ -1669,42 +1636,6 @@
         mWebView.clearSslPreferences();
     }
 
-    @TestTargets({
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "pauseTimers",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "resumeTimers",
-            args = {}
-        )
-    })
-    @ToBeFixed(explanation = "WebView.pauseTimers() does not pause javascript timers")
-    @BrokenTest(value = "Frequently crashes the process some time after test completion.")
-    public void testPauseTimers() throws Exception {
-        WebSettings settings = mWebView.getSettings();
-        settings.setJavaScriptEnabled(true);
-        startWebServer(false);
-        // load a page which increments the number in its title every second
-        String url = mWebServer.getAssetUrl(TestHtmlConstants.TEST_TIMER_URL);
-        assertLoadUrlSuccessfully(mWebView, url);
-        int counter = Integer.parseInt(mWebView.getTitle());
-        Thread.sleep(2000);
-        assertTrue(Integer.parseInt(mWebView.getTitle()) > counter);
-        mWebView.pauseTimers();
-        Thread.sleep(2000); // give the implementation time to stop the timer
-        counter = Integer.parseInt(mWebView.getTitle());
-        Thread.sleep(2000);
-        // ToBeFixed: Uncomment the following line once pauseTimers() is fixed
-        // assertEquals(counter, Integer.parseInt(mWebView.getTitle()));
-        mWebView.resumeTimers();
-        Thread.sleep(2000);
-        assertTrue(Integer.parseInt(mWebView.getTitle()) > counter);
-    }
-
-
     @TestTargetNew(
         level = TestLevel.COMPLETE,
         method = "requestChildRectangleOnScreen",
diff --git a/tests/tests/widget/src/android/widget/cts/GalleryTest.java b/tests/tests/widget/src/android/widget/cts/GalleryTest.java
index e95deb7..aea178a 100644
--- a/tests/tests/widget/src/android/widget/cts/GalleryTest.java
+++ b/tests/tests/widget/src/android/widget/cts/GalleryTest.java
@@ -19,7 +19,6 @@
 import com.android.cts.stub.R;
 import com.android.internal.view.menu.ContextMenuBuilder;
 
-import dalvik.annotation.BrokenTest;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
@@ -34,7 +33,6 @@
 import android.content.Context;
 import android.os.SystemClock;
 import android.test.ActivityInstrumentationTestCase2;
-import android.test.TouchUtils;
 import android.test.UiThreadTest;
 import android.test.ViewAsserts;
 import android.util.AttributeSet;
@@ -133,70 +131,6 @@
         }
     }
 
-    @TestTargets({
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setCallbackDuringFling",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onTouchEvent",
-            args = {android.view.MotionEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onFling",
-            args = {MotionEvent.class, MotionEvent.class, float.class, float.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onDown",
-            args = {android.view.MotionEvent.class}
-        )
-    })
-    @BrokenTest("listener.isItemSelected() is false, need to investigate")
-    public void testSetCallbackDuringFling() {
-        MockOnItemSelectedListener listener = new MockOnItemSelectedListener();
-        mGallery.setOnItemSelectedListener(listener);
-
-        mGallery.setCallbackDuringFling(true);
-
-        int[] xy = new int[2];
-        getSelectedViewCenter(mGallery, xy);
-
-        // This drags over only one item.
-        TouchUtils.drag(this, xy[0], 0, xy[1], xy[1], 1);
-
-        listener.reset();
-        // This will drags over several items.
-        TouchUtils.drag(this, xy[0], 0, xy[1], xy[1], 1);
-
-        assertTrue(listener.isItemSelected());
-        // onItemSelected called more than once
-        assertTrue(listener.getItemSelectedCalledCount() > 1);
-
-        listener.reset();
-        mGallery.setCallbackDuringFling(false);
-
-        TouchUtils.drag(this, xy[0], 240, xy[1], xy[1], 1);
-
-        assertTrue(listener.isItemSelected());
-        // onItemSelected called only once
-        assertTrue(listener.getItemSelectedCalledCount() == 1);
-    }
-
-    private void getSelectedViewCenter(Gallery gallery, int[] xy) {
-        View v = gallery.getSelectedView();
-        v.getLocationOnScreen(xy);
-
-        final int viewWidth = v.getWidth();
-        final int viewHeight = v.getHeight();
-
-        xy[1] += viewHeight / 2;
-        xy[0] += viewWidth / 2;
-    }
-
     @TestTargetNew(
         level = TestLevel.NOT_FEASIBLE,
         method = "setAnimationDuration",
diff --git a/tests/tests/widget/src/android/widget/cts/TableLayoutTest.java b/tests/tests/widget/src/android/widget/cts/TableLayoutTest.java
index 258883d..8214102 100644
--- a/tests/tests/widget/src/android/widget/cts/TableLayoutTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TableLayoutTest.java
@@ -16,6 +16,14 @@
 
 package android.widget.cts;
 
+import com.android.cts.stub.R;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+import dalvik.annotation.ToBeFixed;
+
 import android.content.Context;
 import android.content.res.XmlResourceParser;
 import android.test.ActivityInstrumentationTestCase2;
@@ -33,15 +41,6 @@
 import android.widget.TableRow;
 import android.widget.TextView;
 
-import com.android.cts.stub.R;
-
-import dalvik.annotation.BrokenTest;
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetClass;
-import dalvik.annotation.ToBeFixed;
-
 /**
  * Test {@link TableLayout}.
  */
@@ -492,169 +491,6 @@
         assertTrue(tableLayout.getChildAt(1).isLayoutRequested());
     }
 
-    @TestTargets({
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "test whether columns are actually shrunk",
-            method = "setColumnShrinkable",
-            args = {java.lang.Integer.class, java.lang.Boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "test whether columns are actually shrunk",
-            method = "setShrinkAllColumns",
-            args = {java.lang.Boolean.class}
-        )
-    })
-    @ToBeFixed( bug = "", explanation = "After set a column unable to be shrunk," +
-            " the other shrinkable columns are not shrunk more.")
-    @BrokenTest("fails consistently")
-    public void testColumnShrinkableEffect() {
-        final TableStubActivity activity = getActivity();
-        getInstrumentation().runOnMainSync(new Runnable() {
-            public void run() {
-                activity.setContentView(com.android.cts.stub.R.layout.table_layout_2);
-            }
-        });
-        getInstrumentation().waitForIdleSync();
-        final TableLayout tableLayout =
-                (TableLayout) activity.findViewById(com.android.cts.stub.R.id.table2);
-
-        final int columnVirtualIndex0 = 1;
-        final int columnVirtualIndex1 = 2;
-        final int columnVirtualIndex2 = 4;
-        final TextView child0 = (TextView) ((TableRow) tableLayout.getChildAt(0)).getChildAt(0);
-        final TextView child1 = (TextView) ((TableRow) tableLayout.getChildAt(0)).getChildAt(1);
-        final TextView child2 = (TextView) ((TableRow) tableLayout.getChildAt(0)).getChildAt(2);
-
-        // get the original width of each child.
-        int oldWidth0 = child0.getWidth();
-        int oldWidth1 = child1.getWidth();
-        int oldWidth2 = child2.getWidth();
-        child0.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.EXACTLY);
-        int orignalWidth0 = child0.getMeasuredWidth();
-        // child1 has 2 columns.
-        child1.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.EXACTLY);
-        TextView column12 = (TextView) ((TableRow) tableLayout.getChildAt(1)).getChildAt(2);
-        column12.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.EXACTLY);
-        int orignalWidth1 = child1.getMeasuredWidth() + column12.getMeasuredWidth();
-        child2.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.EXACTLY);
-        int orignalWidth2 = child2.getMeasuredWidth();
-        int totalSpace = tableLayout.getWidth() - orignalWidth0
-                - orignalWidth1 - orignalWidth2;
-
-        // Test: set column 2 which is the start column for child 1 is able to be shrunk.
-        getInstrumentation().runOnMainSync(new Runnable() {
-            public void run() {
-                tableLayout.setColumnShrinkable(columnVirtualIndex1, true);
-            }
-        });
-        getInstrumentation().waitForIdleSync();
-        assertTrue(oldWidth0 < child0.getWidth());
-        assertTrue(oldWidth1 > child1.getWidth());
-        assertEquals(oldWidth2, child2.getWidth());
-        int extraSpace = totalSpace / 2;
-        assertEquals(dropNegative(orignalWidth0 + extraSpace), child0.getWidth());
-        assertEquals(dropNegative(orignalWidth1 + extraSpace), child1.getWidth());
-        assertEquals(orignalWidth2, child2.getWidth());
-        oldWidth0 = child0.getWidth();
-        oldWidth1 = child1.getWidth();
-        oldWidth2 = child2.getWidth();
-
-        // Test: set column 4 which is the column for child 2 is able to be shrunk.
-        getInstrumentation().runOnMainSync(new Runnable() {
-            public void run() {
-                tableLayout.setColumnShrinkable(columnVirtualIndex2, true);
-            }
-        });
-        getInstrumentation().waitForIdleSync();
-        assertTrue(oldWidth0 < child0.getWidth());
-        assertTrue(oldWidth1 < child1.getWidth());
-        assertTrue(oldWidth2 > child2.getWidth());
-        extraSpace = totalSpace / 3;
-        assertEquals(dropNegative(orignalWidth0 + extraSpace), child0.getWidth());
-        assertEquals(dropNegative(orignalWidth1 + extraSpace), child1.getWidth());
-        assertEquals(dropNegative(orignalWidth2 + extraSpace), child2.getWidth());
-        oldWidth0 = child0.getWidth();
-        oldWidth1 = child1.getWidth();
-        oldWidth2 = child2.getWidth();
-
-        // Test: set column 3 which is the end column for child 1 is able to be shrunk.
-        getInstrumentation().runOnMainSync(new Runnable() {
-            public void run() {
-                tableLayout.setColumnShrinkable(columnVirtualIndex1+1, true);
-            }
-        });
-        getInstrumentation().waitForIdleSync();
-        assertTrue(oldWidth0 < child0.getWidth());
-        assertTrue(oldWidth1 > child1.getWidth());
-        assertTrue(oldWidth2 < child2.getWidth());
-        extraSpace = totalSpace / 4;
-        assertEquals(dropNegative(orignalWidth0 + extraSpace), child0.getWidth());
-        assertEquals(dropNegative(orignalWidth1 + extraSpace * 2), child1.getWidth());
-        assertEquals(dropNegative(orignalWidth2 + extraSpace), child2.getWidth());
-        oldWidth0 = child0.getWidth();
-        oldWidth1 = child1.getWidth();
-        oldWidth2 = child2.getWidth();
-
-        // Test: set column 1 which is the column for child 0 is unable to be shrunk.
-        getInstrumentation().runOnMainSync(new Runnable() {
-            public void run() {
-                tableLayout.setColumnShrinkable(columnVirtualIndex0, false);
-            }
-        });
-        getInstrumentation().waitForIdleSync();
-        assertTrue(oldWidth0 < child0.getWidth());
-        // assertTrue(oldWidth1 > column1.getWidth());
-        // assertTrue(oldWidth2 > column2.getWidth());
-        assertEquals(oldWidth1, child1.getWidth());
-        assertEquals(oldWidth2, child2.getWidth());
-        // extraSpace = totalSpace / 3;
-        extraSpace = totalSpace / 4;
-        assertEquals(orignalWidth0, child0.getWidth());
-        assertEquals(orignalWidth1 + extraSpace * 2, child1.getWidth());
-        assertEquals(orignalWidth2 + extraSpace, child2.getWidth());
-        oldWidth0 = child0.getWidth();
-        oldWidth1 = child1.getWidth();
-        oldWidth2 = child2.getWidth();
-
-        // Test: mark all columns are able to be shrunk.
-        getInstrumentation().runOnMainSync(new Runnable() {
-            public void run() {
-                tableLayout.setShrinkAllColumns(true);
-                tableLayout.requestLayout();
-            }
-        });
-        getInstrumentation().waitForIdleSync();
-        assertTrue(oldWidth0 > child0.getWidth());
-        assertTrue(oldWidth1 < child1.getWidth());
-        assertTrue(oldWidth2 < child2.getWidth());
-        extraSpace = totalSpace / 5;
-        assertEquals(orignalWidth0 + extraSpace, child0.getWidth());
-        assertEquals(orignalWidth1 + extraSpace * 2, child1.getWidth());
-        assertEquals(orignalWidth2 + extraSpace, child2.getWidth());
-        oldWidth0 = child0.getWidth();
-        oldWidth1 = child1.getWidth();
-        oldWidth2 = child2.getWidth();
-
-        // Test: Remove the mark for all columns are able to be shrunk.
-        getInstrumentation().runOnMainSync(new Runnable() {
-            public void run() {
-                tableLayout.setShrinkAllColumns(false);
-                tableLayout.requestLayout();
-            }
-        });
-        getInstrumentation().waitForIdleSync();
-        assertTrue(oldWidth0 < child0.getWidth());
-        assertTrue(oldWidth1 > child1.getWidth());
-        assertTrue(oldWidth2 > child2.getWidth());
-        // extraSpace = totalSpace / 3;
-        extraSpace = totalSpace / 4;
-        assertEquals(orignalWidth0, child0.getWidth());
-        assertEquals(orignalWidth1 + extraSpace * 2, child1.getWidth());
-        assertEquals(orignalWidth2 + extraSpace, child2.getWidth());
-    }
-
     @TestTargetNew(
         level = TestLevel.COMPLETE,
         notes = "Test addView(View child)",
diff --git a/tests/tests/widget/src/android/widget/cts/TextViewTest.java b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
old mode 100644
new mode 100755
index b444f11..dc8e8b7
--- a/tests/tests/widget/src/android/widget/cts/TextViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
@@ -1880,12 +1880,12 @@
         mTextView.getFocusedRect(rc);
         assertNotNull(mTextView.getLayout());
         assertEquals(mTextView.getLayout().getPrimaryHorizontal(13),
-                (float) rc.left, 0.01f);
+                (float) rc.left, 0.4f);
         // 'right' is one pixel larger than 'left'
         assertEquals(mTextView.getLayout().getPrimaryHorizontal(13) + 1,
-                (float) rc.right, 0.01f);
+                (float) rc.right, 0.4f);
         assertEquals(mTextView.getLayout().getLineTop(0), rc.top);
-        assertEquals(mTextView.getLayout().getLineBottom(0), rc.bottom);
+        assertEquals(mTextView.getLayout().getLineBottom(0), rc.bottom, 0.4f);
 
         // Exception
         try {
diff --git a/tests/tests/widget/src/android/widget/cts/VideoViewTest.java b/tests/tests/widget/src/android/widget/cts/VideoViewTest.java
index 8e1ffec..6b9aa84 100644
--- a/tests/tests/widget/src/android/widget/cts/VideoViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/VideoViewTest.java
@@ -18,7 +18,6 @@
 
 import com.android.cts.stub.R;
 
-import dalvik.annotation.BrokenTest;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
@@ -31,7 +30,6 @@
 import android.media.MediaPlayer.OnCompletionListener;
 import android.media.MediaPlayer.OnErrorListener;
 import android.media.MediaPlayer.OnPreparedListener;
-import android.net.Uri;
 import android.test.ActivityInstrumentationTestCase2;
 import android.view.KeyEvent;
 import android.view.View.MeasureSpec;
@@ -239,142 +237,6 @@
         }.run();
     }
 
-    @TestTargets({
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setVideoURI",
-            args = {android.net.Uri.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setOnPreparedListener",
-            args = {android.media.MediaPlayer.OnPreparedListener.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "isPlaying",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "pause",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "start",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "seekTo",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "stopPlayback",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getCurrentPosition",
-            args = {}
-        )
-    })
-    @BrokenTest("Fails in individual mode (current pos > 0 before start)")
-    public void testPlayVideo2() throws Throwable {
-        final int seekTo = mVideoView.getDuration() >> 1;
-        final MockOnPreparedListener listener = new MockOnPreparedListener();
-        mVideoView.setOnPreparedListener(listener);
-
-        runTestOnUiThread(new Runnable() {
-            public void run() {
-                mVideoView.setVideoURI(Uri.parse(mVideoPath));
-            }
-        });
-        new DelayedCheck(TIME_OUT) {
-            @Override
-            protected boolean check() {
-                return listener.isTriggered();
-            }
-        }.run();
-        assertEquals(0, mVideoView.getCurrentPosition());
-
-        // test start
-        runTestOnUiThread(new Runnable() {
-            public void run() {
-                mVideoView.start();
-            }
-        });
-        new DelayedCheck(TIME_OUT) {
-            @Override
-            protected boolean check() {
-                return mVideoView.isPlaying();
-            }
-        }.run();
-        assertTrue(mVideoView.getCurrentPosition() > 0);
-
-        // test pause
-        runTestOnUiThread(new Runnable() {
-            public void run() {
-                mVideoView.pause();
-            }
-        });
-        new DelayedCheck(TIME_OUT) {
-            @Override
-            protected boolean check() {
-                return !mVideoView.isPlaying();
-            }
-        }.run();
-        int currentPosition = mVideoView.getCurrentPosition();
-
-        // sleep a second and then check whether player is paused.
-        Thread.sleep(OPERATION_INTERVAL);
-        assertEquals(currentPosition, mVideoView.getCurrentPosition());
-
-        // test seekTo
-        runTestOnUiThread(new Runnable() {
-            public void run() {
-                mVideoView.seekTo(seekTo);
-            }
-        });
-        new DelayedCheck(TIME_OUT) {
-            @Override
-            protected boolean check() {
-                return mVideoView.getCurrentPosition() >= seekTo;
-            }
-        }.run();
-        assertFalse(mVideoView.isPlaying());
-
-        // test start again
-        runTestOnUiThread(new Runnable() {
-            public void run() {
-                mVideoView.start();
-            }
-        });
-        new DelayedCheck(TIME_OUT) {
-            @Override
-            protected boolean check() {
-                return mVideoView.isPlaying();
-            }
-        }.run();
-        assertTrue(mVideoView.getCurrentPosition() > seekTo);
-
-        // test stop
-        runTestOnUiThread(new Runnable() {
-            public void run() {
-                mVideoView.stopPlayback();
-            }
-        });
-        new DelayedCheck(TIME_OUT) {
-            @Override
-            protected boolean check() {
-                return !mVideoView.isPlaying();
-            }
-        }.run();
-        assertEquals(0, mVideoView.getCurrentPosition());
-    }
-
     @TestTargetNew(
         level = TestLevel.COMPLETE,
         method = "setOnErrorListener",