merge in ics-mr0-release history after reset to ics-mr0
diff --git a/tests/tests/text/src/android/text/cts/AnnotationTest.java b/tests/tests/text/src/android/text/cts/AnnotationTest.java
index 2e412b3..9447e49 100644
--- a/tests/tests/text/src/android/text/cts/AnnotationTest.java
+++ b/tests/tests/text/src/android/text/cts/AnnotationTest.java
@@ -107,13 +107,17 @@
})
public void testWriteToParcel() {
Parcel dest = Parcel.obtain();
- mAnnotation = new Annotation(KEY1, VALUE1);
- mAnnotation.writeToParcel(dest, NOFLAG);
- dest.setDataPosition(0);
- Annotation out = new Annotation(dest);
- assertEquals(out.getKey(), mAnnotation.getKey());
- assertEquals(out.getValue(), mAnnotation.getValue());
+ try {
+ mAnnotation = new Annotation(KEY1, VALUE1);
+ mAnnotation.writeToParcel(dest, NOFLAG);
+ dest.setDataPosition(0);
+ Annotation out = new Annotation(dest);
+ assertEquals(out.getKey(), mAnnotation.getKey());
+ assertEquals(out.getValue(), mAnnotation.getValue());
- assertEquals(0, out.describeContents());
+ assertEquals(0, out.describeContents());
+ } finally {
+ dest.recycle();
+ }
}
}
diff --git a/tests/tests/text/src/android/text/cts/TextUtilsTest.java b/tests/tests/text/src/android/text/cts/TextUtilsTest.java
index 99f4f40..2e675ff 100755
--- a/tests/tests/text/src/android/text/cts/TextUtilsTest.java
+++ b/tests/tests/text/src/android/text/cts/TextUtilsTest.java
@@ -2056,73 +2056,83 @@
"1. doesn't explain @param and @return" +
"2. not clear is it the supposed result when the CharSequence is null.")
public void testWriteToParcel() {
- Parcel p = Parcel.obtain();
-
Parcelable.Creator<CharSequence> creator = TextUtils.CHAR_SEQUENCE_CREATOR;
-
String string = "String";
- TextUtils.writeToParcel(string, p, 0);
- p.setDataPosition(0);
- assertEquals(string, creator.createFromParcel(p).toString());
- p.recycle();
+ Parcel p = Parcel.obtain();
+ try {
+ TextUtils.writeToParcel(string, p, 0);
+ p.setDataPosition(0);
+ assertEquals(string, creator.createFromParcel(p).toString());
+ } finally {
+ p.recycle();
+ }
p = Parcel.obtain();
- TextUtils.writeToParcel(null, p, 0);
- p.setDataPosition(0);
- assertNull(creator.createFromParcel(p));
- p.recycle();
+ try {
+ TextUtils.writeToParcel(null, p, 0);
+ p.setDataPosition(0);
+ assertNull(creator.createFromParcel(p));
+ } finally {
+ p.recycle();
+ }
- p = Parcel.obtain();
SpannableString spannableString = new SpannableString("Spannable String");
- URLSpan urlSpan = new URLSpan("URL Span");
int urlSpanStart = spannableString.length() >> 1;
int urlSpanEnd = spannableString.length();
- spannableString.setSpan(urlSpan, urlSpanStart, urlSpanEnd,
- Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- TextUtils.writeToParcel(spannableString, p, 0);
- p.setDataPosition(0);
- SpannableString ret = (SpannableString) creator.createFromParcel(p);
- assertEquals("Spannable String", ret.toString());
- Object[] spans = ret.getSpans(0, ret.length(), Object.class);
- assertEquals(1, spans.length);
- assertEquals("URL Span", ((URLSpan) spans[0]).getURL());
- assertEquals(urlSpanStart, ret.getSpanStart(spans[0]));
- assertEquals(urlSpanEnd, ret.getSpanEnd(spans[0]));
- assertEquals(Spanned.SPAN_INCLUSIVE_INCLUSIVE, ret.getSpanFlags(spans[0]));
- p.recycle();
+ p = Parcel.obtain();
+ try {
+ URLSpan urlSpan = new URLSpan("URL Span");
+ spannableString.setSpan(urlSpan, urlSpanStart, urlSpanEnd,
+ Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ TextUtils.writeToParcel(spannableString, p, 0);
+ p.setDataPosition(0);
+ SpannableString ret = (SpannableString) creator.createFromParcel(p);
+ assertEquals("Spannable String", ret.toString());
+ Object[] spans = ret.getSpans(0, ret.length(), Object.class);
+ assertEquals(1, spans.length);
+ assertEquals("URL Span", ((URLSpan) spans[0]).getURL());
+ assertEquals(urlSpanStart, ret.getSpanStart(spans[0]));
+ assertEquals(urlSpanEnd, ret.getSpanEnd(spans[0]));
+ assertEquals(Spanned.SPAN_INCLUSIVE_INCLUSIVE, ret.getSpanFlags(spans[0]));
+ } finally {
+ p.recycle();
+ }
p = Parcel.obtain();
- ColorStateList colors = new ColorStateList(new int[][] {
- new int[] {android.R.attr.state_focused}, new int[0]},
- new int[] {Color.rgb(0, 255, 0), Color.BLACK});
- int textSize = 20;
- TextAppearanceSpan textAppearanceSpan = new TextAppearanceSpan(
- null, Typeface.ITALIC, textSize, colors, null);
- int textAppearanceSpanStart = 0;
- int textAppearanceSpanEnd = spannableString.length() >> 1;
- spannableString.setSpan(textAppearanceSpan, textAppearanceSpanStart,
- textAppearanceSpanEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
- TextUtils.writeToParcel(spannableString, p, -1);
- p.setDataPosition(0);
- ret = (SpannableString) creator.createFromParcel(p);
- assertEquals("Spannable String", ret.toString());
- spans = ret.getSpans(0, ret.length(), Object.class);
- assertEquals(2, spans.length);
- assertEquals("URL Span", ((URLSpan) spans[0]).getURL());
- assertEquals(urlSpanStart, ret.getSpanStart(spans[0]));
- assertEquals(urlSpanEnd, ret.getSpanEnd(spans[0]));
- assertEquals(Spanned.SPAN_INCLUSIVE_INCLUSIVE, ret.getSpanFlags(spans[0]));
- assertEquals(null, ((TextAppearanceSpan) spans[1]).getFamily());
+ try {
+ ColorStateList colors = new ColorStateList(new int[][] {
+ new int[] {android.R.attr.state_focused}, new int[0]},
+ new int[] {Color.rgb(0, 255, 0), Color.BLACK});
+ int textSize = 20;
+ TextAppearanceSpan textAppearanceSpan = new TextAppearanceSpan(
+ null, Typeface.ITALIC, textSize, colors, null);
+ int textAppearanceSpanStart = 0;
+ int textAppearanceSpanEnd = spannableString.length() >> 1;
+ spannableString.setSpan(textAppearanceSpan, textAppearanceSpanStart,
+ textAppearanceSpanEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ TextUtils.writeToParcel(spannableString, p, -1);
+ p.setDataPosition(0);
+ SpannableString ret = (SpannableString) creator.createFromParcel(p);
+ assertEquals("Spannable String", ret.toString());
+ Object[] spans = ret.getSpans(0, ret.length(), Object.class);
+ assertEquals(2, spans.length);
+ assertEquals("URL Span", ((URLSpan) spans[0]).getURL());
+ assertEquals(urlSpanStart, ret.getSpanStart(spans[0]));
+ assertEquals(urlSpanEnd, ret.getSpanEnd(spans[0]));
+ assertEquals(Spanned.SPAN_INCLUSIVE_INCLUSIVE, ret.getSpanFlags(spans[0]));
+ assertEquals(null, ((TextAppearanceSpan) spans[1]).getFamily());
- assertEquals(Typeface.ITALIC, ((TextAppearanceSpan) spans[1]).getTextStyle());
- assertEquals(textSize, ((TextAppearanceSpan) spans[1]).getTextSize());
+ assertEquals(Typeface.ITALIC, ((TextAppearanceSpan) spans[1]).getTextStyle());
+ assertEquals(textSize, ((TextAppearanceSpan) spans[1]).getTextSize());
- assertEquals(colors.toString(), ((TextAppearanceSpan) spans[1]).getTextColor().toString());
- assertEquals(null, ((TextAppearanceSpan) spans[1]).getLinkTextColor());
- assertEquals(textAppearanceSpanStart, ret.getSpanStart(spans[1]));
- assertEquals(textAppearanceSpanEnd, ret.getSpanEnd(spans[1]));
- assertEquals(Spanned.SPAN_INCLUSIVE_EXCLUSIVE, ret.getSpanFlags(spans[1]));
- p.recycle();
+ assertEquals(colors.toString(), ((TextAppearanceSpan) spans[1]).getTextColor().toString());
+ assertEquals(null, ((TextAppearanceSpan) spans[1]).getLinkTextColor());
+ assertEquals(textAppearanceSpanStart, ret.getSpanStart(spans[1]));
+ assertEquals(textAppearanceSpanEnd, ret.getSpanEnd(spans[1]));
+ assertEquals(Spanned.SPAN_INCLUSIVE_EXCLUSIVE, ret.getSpanFlags(spans[1]));
+ } finally {
+ p.recycle();
+ }
try {
TextUtils.writeToParcel(spannableString, null, 0);
diff --git a/tests/tests/text/src/android/text/style/cts/AbsoluteSizeSpanTest.java b/tests/tests/text/src/android/text/style/cts/AbsoluteSizeSpanTest.java
index 8d56f38..9794cd3 100644
--- a/tests/tests/text/src/android/text/style/cts/AbsoluteSizeSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/AbsoluteSizeSpanTest.java
@@ -51,10 +51,13 @@
AbsoluteSizeSpan asp = new AbsoluteSizeSpan(10);
final Parcel p = Parcel.obtain();
- asp.writeToParcel(p, 0);
- p.setDataPosition(0);
- new AbsoluteSizeSpan(p);
- p.recycle();
+ try {
+ asp.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new AbsoluteSizeSpan(p);
+ } finally {
+ p.recycle();
+ }
}
@TestTargetNew(
@@ -161,19 +164,25 @@
@ToBeFixed(bug = "1695243", explanation = "miss javadoc")
public void testWriteToParcel() {
Parcel p = Parcel.obtain();
- AbsoluteSizeSpan asp = new AbsoluteSizeSpan(2);
- asp.writeToParcel(p, 0);
- p.setDataPosition(0);
- AbsoluteSizeSpan absoluteSizeSpan = new AbsoluteSizeSpan(p);
- assertEquals(2, absoluteSizeSpan.getSize());
- p.recycle();
+ try {
+ AbsoluteSizeSpan asp = new AbsoluteSizeSpan(2);
+ asp.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ AbsoluteSizeSpan absoluteSizeSpan = new AbsoluteSizeSpan(p);
+ assertEquals(2, absoluteSizeSpan.getSize());
+ } finally {
+ p.recycle();
+ }
p = Parcel.obtain();
- asp = new AbsoluteSizeSpan(-5);
- asp.writeToParcel(p, 0);
- p.setDataPosition(0);
- absoluteSizeSpan = new AbsoluteSizeSpan(p);
- assertEquals(-5, absoluteSizeSpan.getSize());
- p.recycle();
+ try {
+ AbsoluteSizeSpan asp = new AbsoluteSizeSpan(-5);
+ asp.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ AbsoluteSizeSpan absoluteSizeSpan = new AbsoluteSizeSpan(p);
+ assertEquals(-5, absoluteSizeSpan.getSize());
+ } finally {
+ p.recycle();
+ }
}
}
diff --git a/tests/tests/text/src/android/text/style/cts/AlignmentSpan_StandardTest.java b/tests/tests/text/src/android/text/style/cts/AlignmentSpan_StandardTest.java
index 32c58b7..7f4aab1 100644
--- a/tests/tests/text/src/android/text/style/cts/AlignmentSpan_StandardTest.java
+++ b/tests/tests/text/src/android/text/style/cts/AlignmentSpan_StandardTest.java
@@ -53,10 +53,13 @@
Standard standard = new Standard(Alignment.ALIGN_NORMAL);
final Parcel p = Parcel.obtain();
- standard.writeToParcel(p, 0);
- p.setDataPosition(0);
- new Standard(p);
- p.recycle();
+ try {
+ standard.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new Standard(p);
+ } finally {
+ p.recycle();
+ }
}
@TestTargetNew(
@@ -110,25 +113,36 @@
@ToBeFixed(bug = "1695243", explanation = "miss javadoc")
public void testWriteToParcel() {
Parcel p = Parcel.obtain();
- Standard s = new Standard(Alignment.ALIGN_NORMAL);
- s.writeToParcel(p, 0);
- p.setDataPosition(0);
- Standard standard = new Standard(p);
- assertEquals(Alignment.ALIGN_NORMAL, standard.getAlignment());
- p.recycle();
+ try {
+ Standard s = new Standard(Alignment.ALIGN_NORMAL);
+ s.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ Standard standard = new Standard(p);
+ assertEquals(Alignment.ALIGN_NORMAL, standard.getAlignment());
+ } finally {
+ p.recycle();
+ }
- s = new Standard(Alignment.ALIGN_OPPOSITE);
- s.writeToParcel(p, 0);
- p.setDataPosition(0);
- standard = new Standard(p);
- assertEquals(Alignment.ALIGN_OPPOSITE, standard.getAlignment());
- p.recycle();
+ p = Parcel.obtain();
+ try {
+ Standard s = new Standard(Alignment.ALIGN_OPPOSITE);
+ s.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ Standard standard = new Standard(p);
+ assertEquals(Alignment.ALIGN_OPPOSITE, standard.getAlignment());
+ } finally {
+ p.recycle();
+ }
- s = new Standard(Alignment.ALIGN_CENTER);
- s.writeToParcel(p, 0);
- p.setDataPosition(0);
- standard = new Standard(p);
- assertEquals(Alignment.ALIGN_CENTER, standard.getAlignment());
- p.recycle();
+ p = Parcel.obtain();
+ try {
+ Standard s = new Standard(Alignment.ALIGN_CENTER);
+ s.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ Standard standard = new Standard(p);
+ assertEquals(Alignment.ALIGN_CENTER, standard.getAlignment());
+ } finally {
+ p.recycle();
+ }
}
}
diff --git a/tests/tests/text/src/android/text/style/cts/BackgroundColorSpanTest.java b/tests/tests/text/src/android/text/style/cts/BackgroundColorSpanTest.java
index 4ebc5ed..9624d3a 100644
--- a/tests/tests/text/src/android/text/style/cts/BackgroundColorSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/BackgroundColorSpanTest.java
@@ -50,10 +50,13 @@
BackgroundColorSpan b = new BackgroundColorSpan(Color.GREEN);
final Parcel p = Parcel.obtain();
- b.writeToParcel(p, 0);
- p.setDataPosition(0);
- new BackgroundColorSpan(p);
- p.recycle();
+ try {
+ b.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new BackgroundColorSpan(p);
+ } finally {
+ p.recycle();
+ }
}
@TestTargetNew(
@@ -131,19 +134,25 @@
@ToBeFixed(bug = "1695243", explanation = "miss javadoc")
public void testWriteToParcel() {
Parcel p = Parcel.obtain();
- BackgroundColorSpan backgroundColorSpan = new BackgroundColorSpan(Color.RED);
- backgroundColorSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- BackgroundColorSpan b = new BackgroundColorSpan(p);
- assertEquals(Color.RED, b.getBackgroundColor());
- p.recycle();
+ try {
+ BackgroundColorSpan backgroundColorSpan = new BackgroundColorSpan(Color.RED);
+ backgroundColorSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ BackgroundColorSpan b = new BackgroundColorSpan(p);
+ assertEquals(Color.RED, b.getBackgroundColor());
+ } finally {
+ p.recycle();
+ }
p = Parcel.obtain();
- backgroundColorSpan = new BackgroundColorSpan(Color.MAGENTA);
- backgroundColorSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- b = new BackgroundColorSpan(p);
- assertEquals(Color.MAGENTA, b.getBackgroundColor());
- p.recycle();
+ try {
+ BackgroundColorSpan backgroundColorSpan = new BackgroundColorSpan(Color.MAGENTA);
+ backgroundColorSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ BackgroundColorSpan b = new BackgroundColorSpan(p);
+ assertEquals(Color.MAGENTA, b.getBackgroundColor());
+ } finally {
+ p.recycle();
+ }
}
}
diff --git a/tests/tests/text/src/android/text/style/cts/BulletSpanTest.java b/tests/tests/text/src/android/text/style/cts/BulletSpanTest.java
index 237eddd..7a32cdd 100644
--- a/tests/tests/text/src/android/text/style/cts/BulletSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/BulletSpanTest.java
@@ -67,10 +67,13 @@
BulletSpan b = new BulletSpan(BulletSpan.STANDARD_GAP_WIDTH, Color.RED);
final Parcel p = Parcel.obtain();
- b.writeToParcel(p, 0);
- p.setDataPosition(0);
- new BulletSpan(p);
- p.recycle();
+ try {
+ b.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new BulletSpan(p);
+ } finally {
+ p.recycle();
+ }
}
@TestTargetNew(
@@ -178,21 +181,30 @@
)
@ToBeFixed(bug = "1695243", explanation = "miss javadoc")
public void testWriteToParcel() {
+ int leadingMargin1 = 0;
+ int leadingMargin2 = 0;
+
Parcel p = Parcel.obtain();
- BulletSpan bulletSpan = new BulletSpan(BulletSpan.STANDARD_GAP_WIDTH, Color.RED);
- bulletSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- BulletSpan b = new BulletSpan(p);
- int leadingMargin1 = b.getLeadingMargin(true);
- p.recycle();
+ try {
+ BulletSpan bulletSpan = new BulletSpan(BulletSpan.STANDARD_GAP_WIDTH, Color.RED);
+ bulletSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ BulletSpan b = new BulletSpan(p);
+ leadingMargin1 = b.getLeadingMargin(true);
+ } finally {
+ p.recycle();
+ }
p = Parcel.obtain();
- bulletSpan = new BulletSpan(10, Color.BLACK);
- bulletSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- b = new BulletSpan(p);
- int leadingMargin2 = b.getLeadingMargin(true);
- p.recycle();
+ try {
+ BulletSpan bulletSpan = new BulletSpan(10, Color.BLACK);
+ bulletSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ BulletSpan b = new BulletSpan(p);
+ leadingMargin2 = b.getLeadingMargin(true);
+ } finally {
+ p.recycle();
+ }
assertTrue(leadingMargin2 > leadingMargin1);
// TODO: Test color. How?
diff --git a/tests/tests/text/src/android/text/style/cts/ForegroundColorSpanTest.java b/tests/tests/text/src/android/text/style/cts/ForegroundColorSpanTest.java
index c650978..d7f84d5 100644
--- a/tests/tests/text/src/android/text/style/cts/ForegroundColorSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/ForegroundColorSpanTest.java
@@ -50,10 +50,13 @@
ForegroundColorSpan f = new ForegroundColorSpan(Color.GREEN);
final Parcel p = Parcel.obtain();
- f.writeToParcel(p, 0);
- p.setDataPosition(0);
- new ForegroundColorSpan(p);
- p.recycle();
+ try {
+ f.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new ForegroundColorSpan(p);
+ } finally {
+ p.recycle();
+ }
}
@TestTargetNew(
@@ -132,19 +135,25 @@
@ToBeFixed(bug = "1695243", explanation = "miss javadoc")
public void testWriteToParcel() {
Parcel p = Parcel.obtain();
- ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(Color.RED);
- foregroundColorSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- ForegroundColorSpan f = new ForegroundColorSpan(p);
- assertEquals(Color.RED, f.getForegroundColor());
- p.recycle();
+ try {
+ ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(Color.RED);
+ foregroundColorSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ ForegroundColorSpan f = new ForegroundColorSpan(p);
+ assertEquals(Color.RED, f.getForegroundColor());
+ } finally {
+ p.recycle();
+ }
p = Parcel.obtain();
- foregroundColorSpan = new ForegroundColorSpan(Color.MAGENTA);
- foregroundColorSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- f = new ForegroundColorSpan(p);
- assertEquals(Color.MAGENTA, f.getForegroundColor());
- p.recycle();
+ try {
+ ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(Color.MAGENTA);
+ foregroundColorSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ ForegroundColorSpan f = new ForegroundColorSpan(p);
+ assertEquals(Color.MAGENTA, f.getForegroundColor());
+ } finally {
+ p.recycle();
+ }
}
}
diff --git a/tests/tests/text/src/android/text/style/cts/LeadingMarginSpan_StandardTest.java b/tests/tests/text/src/android/text/style/cts/LeadingMarginSpan_StandardTest.java
index 606d5f4..9ebd8e8 100644
--- a/tests/tests/text/src/android/text/style/cts/LeadingMarginSpan_StandardTest.java
+++ b/tests/tests/text/src/android/text/style/cts/LeadingMarginSpan_StandardTest.java
@@ -59,10 +59,13 @@
Standard standard = new Standard(10, 20);
final Parcel p = Parcel.obtain();
- standard.writeToParcel(p, 0);
- p.setDataPosition(0);
- new Standard(p);
- p.recycle();
+ try {
+ standard.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new Standard(p);
+ } finally {
+ p.recycle();
+ }
}
@TestTargetNew(
@@ -133,20 +136,27 @@
)
public void testWriteToParcel() {
Parcel p = Parcel.obtain();
- Standard s = new Standard(10, 20);
- s.writeToParcel(p, 0);
- p.setDataPosition(0);
- Standard standard = new Standard(p);
- assertEquals(10, standard.getLeadingMargin(true));
- assertEquals(20, standard.getLeadingMargin(false));
- p.recycle();
+ try {
+ Standard s = new Standard(10, 20);
+ s.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ Standard standard = new Standard(p);
+ assertEquals(10, standard.getLeadingMargin(true));
+ assertEquals(20, standard.getLeadingMargin(false));
+ } finally {
+ p.recycle();
+ }
- s = new Standard(3);
- s.writeToParcel(p, 0);
- p.setDataPosition(0);
- standard = new Standard(p);
- assertEquals(3, standard.getLeadingMargin(true));
- assertEquals(3, standard.getLeadingMargin(false));
- p.recycle();
+ p = Parcel.obtain();
+ try {
+ Standard s = new Standard(3);
+ s.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ Standard standard = new Standard(p);
+ assertEquals(3, standard.getLeadingMargin(true));
+ assertEquals(3, standard.getLeadingMargin(false));
+ } finally {
+ p.recycle();
+ }
}
}
diff --git a/tests/tests/text/src/android/text/style/cts/QuoteSpanTest.java b/tests/tests/text/src/android/text/style/cts/QuoteSpanTest.java
index 793b2b7..8f99fa6 100644
--- a/tests/tests/text/src/android/text/style/cts/QuoteSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/QuoteSpanTest.java
@@ -58,10 +58,13 @@
QuoteSpan q = new QuoteSpan(Color.RED);
final Parcel p = Parcel.obtain();
- q.writeToParcel(p, 0);
- p.setDataPosition(0);
- new QuoteSpan(p);
- p.recycle();
+ try {
+ q.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new QuoteSpan(p);
+ } finally {
+ p.recycle();
+ }
}
@TestTargetNew(
@@ -152,19 +155,24 @@
)
public void testWriteToParcel() {
Parcel p = Parcel.obtain();
- QuoteSpan quoteSpan = new QuoteSpan(Color.RED);
- quoteSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- QuoteSpan q = new QuoteSpan(p);
- assertEquals(Color.RED, q.getColor());
- p.recycle();
-
+ try {
+ QuoteSpan quoteSpan = new QuoteSpan(Color.RED);
+ quoteSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ QuoteSpan q = new QuoteSpan(p);
+ assertEquals(Color.RED, q.getColor());
+ } finally {
+ p.recycle();
+ }
p = Parcel.obtain();
- quoteSpan = new QuoteSpan(Color.MAGENTA);
- quoteSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- q = new QuoteSpan(p);
- assertEquals(Color.MAGENTA, q.getColor());
- p.recycle();
+ try {
+ QuoteSpan quoteSpan = new QuoteSpan(Color.MAGENTA);
+ quoteSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ QuoteSpan q = new QuoteSpan(p);
+ assertEquals(Color.MAGENTA, q.getColor());
+ } finally {
+ p.recycle();
+ }
}
}
diff --git a/tests/tests/text/src/android/text/style/cts/RelativeSizeSpanTest.java b/tests/tests/text/src/android/text/style/cts/RelativeSizeSpanTest.java
index 5effa7f..712ccd2 100644
--- a/tests/tests/text/src/android/text/style/cts/RelativeSizeSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/RelativeSizeSpanTest.java
@@ -46,11 +46,15 @@
RelativeSizeSpan relativeSizeSpan = new RelativeSizeSpan(1.0f);
Parcel p = Parcel.obtain();
- relativeSizeSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- new RelativeSizeSpan(p);
+ try {
+ relativeSizeSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new RelativeSizeSpan(p);
- new RelativeSizeSpan(-1.0f);
+ new RelativeSizeSpan(-1.0f);
+ } finally {
+ p.recycle();
+ }
}
@TestTargetNew(
@@ -153,12 +157,15 @@
)
public void testWriteToParcel() {
Parcel p = Parcel.obtain();
- float proportion = 3.0f;
- RelativeSizeSpan relativeSizeSpan = new RelativeSizeSpan(proportion);
- relativeSizeSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- RelativeSizeSpan newSpan = new RelativeSizeSpan(p);
- assertEquals(proportion, newSpan.getSizeChange());
- p.recycle();
+ try {
+ float proportion = 3.0f;
+ RelativeSizeSpan relativeSizeSpan = new RelativeSizeSpan(proportion);
+ relativeSizeSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ RelativeSizeSpan newSpan = new RelativeSizeSpan(p);
+ assertEquals(proportion, newSpan.getSizeChange());
+ } finally {
+ p.recycle();
+ }
}
}
diff --git a/tests/tests/text/src/android/text/style/cts/ScaleXSpanTest.java b/tests/tests/text/src/android/text/style/cts/ScaleXSpanTest.java
index cf2a3f4..d9feb55 100644
--- a/tests/tests/text/src/android/text/style/cts/ScaleXSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/ScaleXSpanTest.java
@@ -46,11 +46,15 @@
ScaleXSpan scaleXSpan = new ScaleXSpan(1.5f);
Parcel p = Parcel.obtain();
- scaleXSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- new ScaleXSpan(p);
+ try {
+ scaleXSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new ScaleXSpan(p);
- new ScaleXSpan(-2.5f);
+ new ScaleXSpan(-2.5f);
+ } finally {
+ p.recycle();
+ }
}
@TestTargetNew(
@@ -148,12 +152,15 @@
)
public void testWriteToParcel() {
Parcel p = Parcel.obtain();
- float proportion = 3.0f;
- ScaleXSpan scaleXSpan = new ScaleXSpan(proportion);
- scaleXSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- ScaleXSpan newSpan = new ScaleXSpan(p);
- assertEquals(proportion, newSpan.getScaleX());
- p.recycle();
+ try {
+ float proportion = 3.0f;
+ ScaleXSpan scaleXSpan = new ScaleXSpan(proportion);
+ scaleXSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ ScaleXSpan newSpan = new ScaleXSpan(p);
+ assertEquals(proportion, newSpan.getScaleX());
+ } finally {
+ p.recycle();
+ }
}
}
diff --git a/tests/tests/text/src/android/text/style/cts/StrikethroughSpanTest.java b/tests/tests/text/src/android/text/style/cts/StrikethroughSpanTest.java
index e5e29ea..f3ede8d 100644
--- a/tests/tests/text/src/android/text/style/cts/StrikethroughSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/StrikethroughSpanTest.java
@@ -46,9 +46,13 @@
StrikethroughSpan strikethroughSpan = new StrikethroughSpan();
Parcel p = Parcel.obtain();
- strikethroughSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- new StrikethroughSpan(p);
+ try {
+ strikethroughSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new StrikethroughSpan(p);
+ } finally {
+ p.recycle();
+ }
}
@TestTargetNew(
@@ -102,10 +106,13 @@
)
public void testWriteToParcel() {
Parcel p = Parcel.obtain();
- StrikethroughSpan strikethroughSpan = new StrikethroughSpan();
- strikethroughSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- new StrikethroughSpan(p);
- p.recycle();
+ try {
+ StrikethroughSpan strikethroughSpan = new StrikethroughSpan();
+ strikethroughSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new StrikethroughSpan(p);
+ } finally {
+ p.recycle();
+ }
}
}
diff --git a/tests/tests/text/src/android/text/style/cts/StyleSpanTest.java b/tests/tests/text/src/android/text/style/cts/StyleSpanTest.java
index 4723693..c5098b4 100644
--- a/tests/tests/text/src/android/text/style/cts/StyleSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/StyleSpanTest.java
@@ -47,11 +47,15 @@
StyleSpan styleSpan = new StyleSpan(2);
Parcel p = Parcel.obtain();
- styleSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- new StyleSpan(p);
-
- new StyleSpan(-2);
+ try {
+ styleSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ StyleSpan fromParcel = new StyleSpan(p);
+ assertEquals(2, fromParcel.getStyle());
+ new StyleSpan(-2);
+ } finally {
+ p.recycle();
+ }
}
@TestTargetNew(
@@ -151,11 +155,14 @@
)
public void testWriteToParcel() {
Parcel p = Parcel.obtain();
- StyleSpan styleSpan = new StyleSpan(Typeface.BOLD);
- styleSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- StyleSpan newSpan = new StyleSpan(p);
- assertEquals(Typeface.BOLD, newSpan.getStyle());
- p.recycle();
+ try {
+ StyleSpan styleSpan = new StyleSpan(Typeface.BOLD);
+ styleSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ StyleSpan newSpan = new StyleSpan(p);
+ assertEquals(Typeface.BOLD, newSpan.getStyle());
+ } finally {
+ p.recycle();
+ }
}
}
diff --git a/tests/tests/text/src/android/text/style/cts/SubscriptSpanTest.java b/tests/tests/text/src/android/text/style/cts/SubscriptSpanTest.java
index 2b80184..3201400 100644
--- a/tests/tests/text/src/android/text/style/cts/SubscriptSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/SubscriptSpanTest.java
@@ -46,9 +46,13 @@
SubscriptSpan subscriptSpan = new SubscriptSpan();
Parcel p = Parcel.obtain();
- subscriptSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- new SubscriptSpan(p);
+ try {
+ subscriptSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new SubscriptSpan(p);
+ } finally {
+ p.recycle();
+ }
}
@TestTargetNew(
@@ -130,10 +134,13 @@
)
public void testWriteToParcel() {
Parcel p = Parcel.obtain();
- SubscriptSpan subscriptSpan = new SubscriptSpan();
- subscriptSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- new SubscriptSpan(p);
- p.recycle();
+ try {
+ SubscriptSpan subscriptSpan = new SubscriptSpan();
+ subscriptSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new SubscriptSpan(p);
+ } finally {
+ p.recycle();
+ }
}
}
diff --git a/tests/tests/text/src/android/text/style/cts/SuperscriptSpanTest.java b/tests/tests/text/src/android/text/style/cts/SuperscriptSpanTest.java
index 33ed6e6..3628d08 100644
--- a/tests/tests/text/src/android/text/style/cts/SuperscriptSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/SuperscriptSpanTest.java
@@ -46,9 +46,13 @@
SuperscriptSpan superscriptSpan = new SuperscriptSpan();
Parcel p = Parcel.obtain();
- superscriptSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- new SuperscriptSpan(p);
+ try {
+ superscriptSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new SuperscriptSpan(p);
+ } finally {
+ p.recycle();
+ }
}
@TestTargetNew(
@@ -130,10 +134,13 @@
)
public void testWriteToParcel() {
Parcel p = Parcel.obtain();
- SuperscriptSpan superscriptSpan = new SuperscriptSpan();
- superscriptSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- new SuperscriptSpan(p);
- p.recycle();
+ try {
+ SuperscriptSpan superscriptSpan = new SuperscriptSpan();
+ superscriptSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new SuperscriptSpan(p);
+ } finally {
+ p.recycle();
+ }
}
}
diff --git a/tests/tests/text/src/android/text/style/cts/TextAppearanceSpanTest.java b/tests/tests/text/src/android/text/style/cts/TextAppearanceSpanTest.java
index ef5ed04..4e03848 100644
--- a/tests/tests/text/src/android/text/style/cts/TextAppearanceSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/TextAppearanceSpanTest.java
@@ -67,10 +67,13 @@
TextAppearanceSpan textAppearanceSpan = new TextAppearanceSpan("sans", 1, 6, csl, csl);
Parcel p = Parcel.obtain();
- textAppearanceSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- new TextAppearanceSpan(p);
-
+ try {
+ textAppearanceSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new TextAppearanceSpan(p);
+ } finally {
+ p.recycle();
+ }
try {
new TextAppearanceSpan(null, -1);
fail("should throw NullPointerException.");
diff --git a/tests/tests/text/src/android/text/style/cts/TypefaceSpanTest.java b/tests/tests/text/src/android/text/style/cts/TypefaceSpanTest.java
index 10922a5..651b55f 100644
--- a/tests/tests/text/src/android/text/style/cts/TypefaceSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/TypefaceSpanTest.java
@@ -52,10 +52,13 @@
TypefaceSpan t = new TypefaceSpan(FAMILY);
final Parcel p = Parcel.obtain();
- t.writeToParcel(p, 0);
- p.setDataPosition(0);
- new TypefaceSpan(p);
- p.recycle();
+ try {
+ t.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new TypefaceSpan(p);
+ } finally {
+ p.recycle();
+ }
}
@TestTargetNew(
@@ -158,11 +161,14 @@
@ToBeFixed(bug = "1695243", explanation = "miss javadoc")
public void testWriteToParcel() {
Parcel p = Parcel.obtain();
- TypefaceSpan typefaceSpan = new TypefaceSpan(FAMILY);
- typefaceSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- TypefaceSpan t = new TypefaceSpan(p);
- assertEquals(FAMILY, t.getFamily());
- p.recycle();
+ try {
+ TypefaceSpan typefaceSpan = new TypefaceSpan(FAMILY);
+ typefaceSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ TypefaceSpan t = new TypefaceSpan(p);
+ assertEquals(FAMILY, t.getFamily());
+ } finally {
+ p.recycle();
+ }
}
}
diff --git a/tests/tests/text/src/android/text/style/cts/URLSpanTest.java b/tests/tests/text/src/android/text/style/cts/URLSpanTest.java
index dfe5631..db5b7be 100644
--- a/tests/tests/text/src/android/text/style/cts/URLSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/URLSpanTest.java
@@ -67,10 +67,13 @@
URLSpan urlSpan = new URLSpan(TEST_URL);
final Parcel p = Parcel.obtain();
- urlSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- new URLSpan(p);
- p.recycle();
+ try {
+ urlSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ new URLSpan(p);
+ } finally {
+ p.recycle();
+ }
}
@TestTargetNew(
@@ -163,11 +166,14 @@
)
public void testWriteToParcel() {
Parcel p = Parcel.obtain();
- URLSpan urlSpan = new URLSpan(TEST_URL);
- urlSpan.writeToParcel(p, 0);
- p.setDataPosition(0);
- URLSpan u = new URLSpan(p);
- assertEquals(TEST_URL, u.getURL());
- p.recycle();
+ try {
+ URLSpan urlSpan = new URLSpan(TEST_URL);
+ urlSpan.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ URLSpan u = new URLSpan(p);
+ assertEquals(TEST_URL, u.getURL());
+ } finally {
+ p.recycle();
+ }
}
}
diff --git a/tests/tests/text/src/android/text/style/cts/UnderlineSpanTest.java b/tests/tests/text/src/android/text/style/cts/UnderlineSpanTest.java
index bc1fab8..1d7e02d 100644
--- a/tests/tests/text/src/android/text/style/cts/UnderlineSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/UnderlineSpanTest.java
@@ -49,8 +49,11 @@
new UnderlineSpan();
final Parcel p = Parcel.obtain();
- new UnderlineSpan(p);
- p.recycle();
+ try {
+ new UnderlineSpan(p);
+ } finally {
+ p.recycle();
+ }
}
@TestTargetNew(
@@ -109,9 +112,12 @@
)
public void testWriteToParcel() {
Parcel p = Parcel.obtain();
- UnderlineSpan underlineSpan = new UnderlineSpan();
- underlineSpan.writeToParcel(p, 0);
- new UnderlineSpan(p);
- p.recycle();
+ try {
+ UnderlineSpan underlineSpan = new UnderlineSpan();
+ underlineSpan.writeToParcel(p, 0);
+ new UnderlineSpan(p);
+ } finally {
+ p.recycle();
+ }
}
}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildHelper.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildHelper.java
index b1ace51..5945cd8 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildHelper.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildHelper.java
@@ -119,6 +119,13 @@
}
/**
+ * @return a {@link File} representing the directory to store result logs.
+ */
+ public File getLogsDir() {
+ return new File(getRepositoryDir(), "logs");
+ }
+
+ /**
* @return a {@link File} representing the test cases directory
*/
public File getTestCasesDir() {
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java b/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java
index 72451f1..9c87e68 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java
@@ -146,7 +146,7 @@
helpBuilder.append(" run cts --package/-p : run a CTS test package\n");
helpBuilder.append(" run cts --class/-c [--method/-m] : run a specific test class and/or");
helpBuilder.append("method\n");
- helpBuilder.append(" run cts --continue-session-id session_ID: run all not executed ");
+ helpBuilder.append(" run cts --continue-session session_ID: run all not executed ");
helpBuilder.append("tests from a previous CTS session\n");
helpBuilder.append(" run cts [options] --serial/s device_ID: run CTS on specified ");
helpBuilder.append("device\n");
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
index 11b4b1c..1335365 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
@@ -53,7 +53,6 @@
* Outputs xml in format governed by the cts_result.xsd
*/
public class CtsXmlResultReporter implements ITestInvocationListener {
-
private static final String LOG_TAG = "CtsXmlResultReporter";
static final String TEST_RESULT_FILE_NAME = "testResult.xml";
@@ -66,6 +65,7 @@
static final String RESULT_TAG = "TestResult";
static final String PLAN_ATTR = "testPlan";
+ static final String STARTTIME_ATTR = "starttime";
private static final String REPORT_DIR_NAME = "output-file-path";
@Option(name=REPORT_DIR_NAME, description="root file system path to directory to store xml " +
@@ -91,6 +91,8 @@
private TestPackageResult mCurrentPkgResult = null;
private boolean mIsDeviceInfoRun = false;
+ private File mLogDir;
+
public void setReportDir(File reportDir) {
mReportDir = reportDir;
}
@@ -117,7 +119,7 @@
mContinueSessionId));
}
mPlanName = resultRepo.getSummaries().get(mContinueSessionId).getTestPlan();
- mStartTime = resultRepo.getSummaries().get(mContinueSessionId).getTimestamp();
+ mStartTime = resultRepo.getSummaries().get(mContinueSessionId).getStartTime();
mReportDir = resultRepo.getReportDir(mContinueSessionId);
} else {
if (mReportDir == null) {
@@ -130,6 +132,11 @@
mStartTime = getTimestamp();
logResult("Created result dir %s", mReportDir.getName());
}
+ // TODO: allow customization of log dir
+ // create a unique directory for saving logs, with same name as result dir
+ File rootLogDir = getBuildHelper(ctsBuild).getLogsDir();
+ mLogDir = new File(rootLogDir, mReportDir.getName());
+ mLogDir.mkdirs();
}
/**
@@ -166,7 +173,7 @@
* Exposed for unit testing.
*/
ILogFileSaver getLogFileSaver() {
- return new LogFileSaver(mReportDir);
+ return new LogFileSaver(mLogDir);
}
/**
@@ -309,7 +316,7 @@
throws IOException {
serializer.startTag(ns, RESULT_TAG);
serializer.attribute(ns, PLAN_ATTR, mPlanName);
- serializer.attribute(ns, "starttime", startTime);
+ serializer.attribute(ns, STARTTIME_ATTR, startTime);
serializer.attribute(ns, "endtime", endTime);
serializer.attribute(ns, "version", CTS_RESULT_FILE_VERSION);
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/ITestSummary.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/ITestSummary.java
index ee7b67f..509e564 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/ITestSummary.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/result/ITestSummary.java
@@ -26,7 +26,7 @@
int getId();
/**
- * @return the starting timestamp
+ * @return the starting timestamp, also known as result directory name
*/
String getTimestamp();
@@ -50,4 +50,11 @@
*/
String getTestPlan();
+ /**
+ * Return the user-friendly displayed start time stored in result XML.
+ * <p/>
+ * Expected format: {@link TimeUtil#getTimestamp()}
+ */
+ String getStartTime();
+
}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestSummaryXml.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestSummaryXml.java
index 4f0b59b..af37184 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestSummaryXml.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestSummaryXml.java
@@ -34,6 +34,7 @@
private int mNumNotExecuted = 0;
private int mNumPassed = 0;
private String mPlan = "NA";
+ private String mStartTime = "unknown";
/**
* @param id
@@ -102,6 +103,7 @@
if (eventType == XmlPullParser.START_TAG && parser.getName().equals(
CtsXmlResultReporter.RESULT_TAG)) {
mPlan = getAttribute(parser, CtsXmlResultReporter.PLAN_ATTR);
+ mStartTime = getAttribute(parser, CtsXmlResultReporter.STARTTIME_ATTR);
} else if (eventType == XmlPullParser.START_TAG && parser.getName().equals(
TestResults.SUMMARY_TAG)) {
mNumFailed = parseIntAttr(parser, TestResults.FAILED_ATTR) +
@@ -114,5 +116,13 @@
}
throw new XmlPullParserException("Could not find Summary tag");
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getStartTime() {
+ return mStartTime;
+ }
}