Enable Text core tests

Some of the tests were disabled because of the access permissions. This
CL:
* Removes @Suppress annotations
* Annotates the test classes with related annotations such as @SmallTest
* Removes unused imports
* Replaces android.test.sitebuilder.annotation.SmallTest annotations with
  android.support.test.filters.SmallTest

Bug: 29879498
Change-Id: I9e6e326bc6eaf365d7d5c6d1f7edec35e6957302
This commit is contained in:
Siyamed Sinir
2016-06-29 16:55:35 -07:00
parent fcef4a3b62
commit 68089c8106
20 changed files with 78 additions and 99 deletions

View File

@@ -16,18 +16,15 @@
package android.text;
import static android.text.Layout.Alignment.*;
import android.text.DynamicLayout;
import junit.framework.TestCase;
import static android.text.Layout.Alignment.ALIGN_NORMAL;
/**
* Tests DynamciLayout updateBlocks method.
*
* Requires disabling access checks in the vm since this calls package-private APIs.
*
* @Suppress
*/
public class DynamicLayoutBlocksTest extends TestCase {
private DynamicLayout dl = new DynamicLayout("", new TextPaint(), 0, ALIGN_NORMAL, 0, 0, false);

View File

@@ -16,13 +16,16 @@
package android.text;
import android.support.test.filters.SmallTest;
import junit.framework.TestCase;
/**
* PackedIntVectorTest tests the features of android.util.PackedIntVector.
*/
public class PackedIntVectorTest extends TestCase {
@SmallTest
public void testBasic() throws Exception {
for (int width = 0; width < 10; width++) {
PackedIntVector p = new PackedIntVector(width);

View File

@@ -16,9 +16,6 @@
package android.text;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
public class SpannableStringBuilderTest extends SpannableTest {
protected Spannable newSpannableWithText(String text) {

View File

@@ -16,9 +16,6 @@
package android.text;
import android.text.Spannable;
import android.text.SpannableString;
public class SpannableStringTest extends SpannableTest {
protected Spannable newSpannableWithText(String text) {

View File

@@ -19,7 +19,6 @@ package android.text;
import android.test.InstrumentationTestCase;
import android.test.MoreAsserts;
import android.test.suitebuilder.annotation.MediumTest;
import android.text.Spannable;
public abstract class SpannableTest extends InstrumentationTestCase {

View File

@@ -18,10 +18,11 @@ package android.text;
import android.graphics.Typeface;
import android.os.Parcel;
import android.test.suitebuilder.annotation.SmallTest;
import android.text.*;
import android.text.style.*;
import android.util.Log;
import android.support.test.filters.SmallTest;
import android.text.style.CharacterStyle;
import android.text.style.StyleSpan;
import android.text.style.TextAppearanceSpan;
import android.text.style.TypefaceSpan;
import junit.framework.TestCase;

View File

@@ -16,7 +16,7 @@
package android.text;
import android.test.suitebuilder.annotation.SmallTest;
import android.support.test.filters.SmallTest;
import android.util.Log;
import junit.framework.TestCase;
@@ -25,73 +25,73 @@ import junit.framework.TestCase;
* Quick check of native bidi implementation.
*/
public class StaticLayoutBidiTest extends TestCase {
public static final int REQ_DL = 2; // Layout.DIR_REQUEST_DEFAULT_LTR;
public static final int REQ_DR = -2; // Layout.DIR_REQUEST_DEFAULT_RTL;
public static final int REQ_L = 1; // Layout.DIR_REQUEST_LTR;
public static final int REQ_R = -1; // Layout.DIR_REQUEST_RTL;
public static final int L = Layout.DIR_LEFT_TO_RIGHT;
public static final int R = Layout.DIR_RIGHT_TO_LEFT;
public static final String SP = " ";
public static final String ALEF = "\u05d0";
public static final String BET = "\u05d1";
public static final String GIMEL = "\u05d2";
public static final String DALET = "\u05d3";
//@SmallTest
@SmallTest
public void testAllLtr() {
expectNativeBidi(REQ_DL, "a test", "000000", L);
}
//@SmallTest
@SmallTest
public void testLtrRtl() {
expectNativeBidi(REQ_DL, "abc " + ALEF + BET + GIMEL, "0000111", L);
}
//@SmallTest
@SmallTest
public void testAllRtl() {
expectNativeBidi(REQ_DL, ALEF + SP + ALEF + BET + GIMEL + DALET, "111111", R);
}
//@SmallTest
@SmallTest
public void testRtlLtr() {
expectNativeBidi(REQ_DL, ALEF + BET + GIMEL + " abc", "1111222", R);
}
//@SmallTest
@SmallTest
public void testRAllLtr() {
expectNativeBidi(REQ_R, "a test", "222222", R);
}
//@SmallTest
@SmallTest
public void testRLtrRtl() {
expectNativeBidi(REQ_R, "abc " + ALEF + BET + GIMEL, "2221111", R);
}
//@SmallTest
@SmallTest
public void testLAllRtl() {
expectNativeBidi(REQ_L, ALEF + SP + ALEF + BET + GIMEL + DALET, "111111", L);
}
//@SmallTest
@SmallTest
public void testLRtlLtr() {
expectNativeBidi(REQ_DL, ALEF + BET + GIMEL + " abc", "1111222", R);
}
//@SmallTest
@SmallTest
public void testNativeBidi() {
expectNativeBidi(REQ_L, ALEF + BET + GIMEL + " abc", "1110000", L);
}
private void expectNativeBidi(int dir, String text,
private void expectNativeBidi(int dir, String text,
String expectedLevels, int expectedDir) {
char[] chs = text.toCharArray();
int n = chs.length;
byte[] chInfo = new byte[n];
int resultDir = AndroidBidi.bidi(dir, chs, chInfo, n, false);
{
StringBuilder sb = new StringBuilder("info:");
for (int i = 0; i < n; ++i) {
@@ -99,7 +99,7 @@ public class StaticLayoutBidiTest extends TestCase {
}
Log.i("BIDI", sb.toString());
}
char[] resultLevelChars = new char[n];
for (int i = 0; i < n; ++i) {
resultLevelChars[i] = (char)('0' + chInfo[i]);

View File

@@ -16,14 +16,15 @@
package android.text;
import android.support.test.filters.SmallTest;
import android.text.Layout.Directions;
import android.text.StaticLayoutTest.LayoutBuilder;
import junit.framework.TestCase;
import java.util.Arrays;
import java.util.Formatter;
import junit.framework.TestCase;
public class StaticLayoutDirectionsTest extends TestCase {
private static final char ALEF = '\u05d0';
@@ -106,7 +107,7 @@ public class StaticLayoutDirectionsTest extends TestCase {
return new String(chars, 0, chars.length);
}
// @SmallTest
@SmallTest
public void testDirections() {
StringBuilder buf = new StringBuilder("\n");
Formatter f = new Formatter(buf);
@@ -121,7 +122,7 @@ public class StaticLayoutDirectionsTest extends TestCase {
}
}
// @SmallTest
@SmallTest
public void testTrailingWhitespace() {
LayoutBuilder b = StaticLayoutTest.builder();
b.setText(pseudoBidiToReal("Ab c"));
@@ -136,6 +137,7 @@ public class StaticLayoutDirectionsTest extends TestCase {
expectDirections("split line", expected, result);
}
@SmallTest
public void testNextToRightOf() {
LayoutBuilder b = StaticLayoutTest.builder();
b.setText(pseudoBidiToReal("aA1B2"));
@@ -159,6 +161,7 @@ public class StaticLayoutDirectionsTest extends TestCase {
}
}
@SmallTest
public void testNextToLeftOf() {
LayoutBuilder b = StaticLayoutTest.builder();
b.setText(pseudoBidiToReal("aA1B2"));

View File

@@ -17,34 +17,24 @@
package android.text;
import android.graphics.Paint.FontMetricsInt;
import android.test.suitebuilder.annotation.SmallTest;
import android.support.test.filters.SmallTest;
import android.text.Layout.Alignment;
import static android.text.Layout.Alignment.*;
import android.text.TextPaint;
import android.text.method.EditorState;
import android.util.Log;
import junit.framework.TestCase;
import static android.text.Layout.Alignment.ALIGN_NORMAL;
/**
* Tests StaticLayout vertical metrics behavior.
*
* Requires disabling access checks in the vm since this calls package-private
* APIs.
*
* @Suppress
*/
public class StaticLayoutTest extends TestCase {
private static final int DEFAULT_OUTER_WIDTH = 150;
private static final Alignment DEFAULT_ALIGN = Alignment.ALIGN_CENTER;
private static final float SPACE_MULTI = 1.0f;
private static final float SPACE_ADD = 0.0f;
/**
* Basic test showing expected behavior and relationship between font
* metrics and line metrics.
*/
//@SmallTest
@SmallTest
public void testGetters1() {
LayoutBuilder b = builder();
FontMetricsInt fmi = b.paint.getFontMetricsInt();
@@ -70,7 +60,7 @@ public class StaticLayoutTest extends TestCase {
* Basic test showing effect of includePad = true with 1 line.
* Top and bottom padding are affected, as is the line descent and height.
*/
//@SmallTest
@SmallTest
public void testGetters2() {
LayoutBuilder b = builder()
.setIncludePad(true);
@@ -85,7 +75,7 @@ public class StaticLayoutTest extends TestCase {
* Basic test showing effect of includePad = true wrapping to 2 lines.
* Ascent of top line and descent of bottom line are affected.
*/
//@SmallTest
@SmallTest
public void testGetters3() {
LayoutBuilder b = builder()
.setIncludePad(true)
@@ -102,7 +92,7 @@ public class StaticLayoutTest extends TestCase {
* Basic test showing effect of includePad = true wrapping to 3 lines.
* First line ascent is top, bottom line descent is bottom.
*/
//@SmallTest
@SmallTest
public void testGetters4() {
LayoutBuilder b = builder()
.setText("This is a longer test")
@@ -122,7 +112,7 @@ public class StaticLayoutTest extends TestCase {
* large text. See effect of leading. Currently, we don't expect there to
* even be non-zero leading.
*/
//@SmallTest
@SmallTest
public void testGetters5() {
LayoutBuilder b = builder()
.setText("This is a longer test")
@@ -149,7 +139,7 @@ public class StaticLayoutTest extends TestCase {
* Basic test showing effect of includePad = true, spacingAdd = 2, wrapping
* to 3 lines.
*/
//@SmallTest
@SmallTest
public void testGetters6() {
int spacingAdd = 2; // int so expressions return int
LayoutBuilder b = builder()
@@ -170,7 +160,7 @@ public class StaticLayoutTest extends TestCase {
* Basic test showing effect of includePad = true, spacingAdd = 2,
* spacingMult = 1.5, wrapping to 3 lines.
*/
//@SmallTest
@SmallTest
public void testGetters7() {
LayoutBuilder b = builder()
.setText("This is a longer test")
@@ -192,7 +182,7 @@ public class StaticLayoutTest extends TestCase {
* Basic test showing effect of includePad = true, spacingAdd = 0,
* spacingMult = 0.8 when wrapping to 3 lines.
*/
//@SmallTest
@SmallTest
public void testGetters8() {
LayoutBuilder b = builder()
.setText("This is a longer test")

View File

@@ -16,7 +16,9 @@
package android.text;
import android.support.test.filters.SmallTest;
import android.text.Layout.Alignment;
import junit.framework.TestCase;
/**
@@ -38,6 +40,7 @@ public class StaticLayoutTextMeasuringTest extends TestCase {
}
}
@SmallTest
public void testGetPrimaryHorizontal_zwnbsp() {
// a, ZERO WIDTH NO-BREAK SPACE
String testString = "a\uFEFF";
@@ -48,6 +51,7 @@ public class StaticLayoutTextMeasuringTest extends TestCase {
assertEquals(layout.getPrimaryHorizontal(2), layout.getPrimaryHorizontal(1));
}
@SmallTest
public void testGetPrimaryHorizontal_devanagari() {
// DEVANAGARI LETTER KA, DEVANAGARI VOWEL SIGN AA
String testString = "\u0915\u093E";
@@ -58,6 +62,7 @@ public class StaticLayoutTextMeasuringTest extends TestCase {
assertEquals(layout.getPrimaryHorizontal(2), layout.getPrimaryHorizontal(1));
}
@SmallTest
public void testGetPrimaryHorizontal_flagEmoji() {
// REGIONAL INDICATOR SYMBOL LETTER U, REGIONAL INDICATOR SYMBOL LETTER S, REGIONAL
// INDICATOR SYMBOL LETTER Z

View File

@@ -16,11 +16,8 @@
package android.text;
import android.test.suitebuilder.annotation.SmallTest;
import android.text.DynamicLayout;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.support.test.filters.SmallTest;
import junit.framework.TestCase;

View File

@@ -18,21 +18,21 @@ package android.text;
import com.google.android.collect.Lists;
import android.test.MoreAsserts;
import android.os.Parcel;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.SmallTest;
import android.support.test.filters.LargeTest;
import android.support.test.filters.SmallTest;
import android.test.MoreAsserts;
import android.text.style.StyleSpan;
import android.text.util.Rfc822Token;
import android.text.util.Rfc822Tokenizer;
import android.view.View;
import junit.framework.TestCase;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import junit.framework.TestCase;
/**
* TextUtilsTest tests {@link TextUtils}.
*/

View File

@@ -16,11 +16,12 @@
package android.text.format;
import android.test.suitebuilder.annotation.SmallTest;
import android.support.test.filters.SmallTest;
import junit.framework.TestCase;
public class DateFormatTest extends TestCase {
@SmallTest
public void testHasDesignator() throws Exception {
assertTrue(DateFormat.hasDesignator("hh:mm:ss", DateFormat.MINUTE));

View File

@@ -16,7 +16,7 @@
package android.text.format;
import android.test.suitebuilder.annotation.SmallTest;
import android.support.test.filters.SmallTest;
import junit.framework.TestCase;

View File

@@ -18,8 +18,8 @@ package android.text.format;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.support.test.filters.SmallTest;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import android.text.format.Formatter.BytesResult;
import java.util.Locale;

View File

@@ -16,9 +16,8 @@
package android.text.format;
import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.Suppress;
import android.text.format.Time;
import android.support.test.filters.SmallTest;
import android.support.test.filters.Suppress;
import android.util.Log;
import android.util.TimeFormatException;

View File

@@ -16,18 +16,13 @@
package android.text.method;
import android.app.Activity;
import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.Suppress;
import android.support.test.filters.SmallTest;
import android.text.InputType;
import android.text.method.BaseKeyListener;
import android.text.method.KeyListenerTestCase;
import android.view.KeyEvent;
import android.widget.EditText;
import android.widget.TextView.BufferType;
/**
* Test backspace key handling of {@link android.text.method.BaseKeyListner}.
* Test backspace key handling of {@link android.text.method.BaseKeyListener}.
*
* Only contains edge cases. For normal cases, see {@see android.text.method.cts.BackspaceTest}.
* TODO: introduce test cases for surrogate pairs and replacement span.

View File

@@ -16,14 +16,9 @@
package android.text.method;
import android.app.Activity;
import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.Suppress;
import android.support.test.filters.SmallTest;
import android.text.InputType;
import android.text.method.BaseKeyListener;
import android.text.method.KeyListenerTestCase;
import android.view.KeyEvent;
import android.widget.EditText;
import android.widget.TextView.BufferType;
/**

View File

@@ -16,8 +16,8 @@
package android.text.util;
import android.support.test.filters.SmallTest;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import android.text.method.LinkMovementMethod;
import android.widget.TextView;

View File

@@ -15,7 +15,7 @@
*/
package android.util;
import android.test.suitebuilder.annotation.SmallTest;
import android.support.test.filters.SmallTest;
import java.util.regex.Matcher;
import java.util.regex.Pattern;