diff options
Diffstat (limited to 'core/tests')
-rw-r--r-- | core/tests/coretests/src/android/text/TextUtilsTest.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/core/tests/coretests/src/android/text/TextUtilsTest.java b/core/tests/coretests/src/android/text/TextUtilsTest.java index 79d57f1..63dd0cc 100644 --- a/core/tests/coretests/src/android/text/TextUtilsTest.java +++ b/core/tests/coretests/src/android/text/TextUtilsTest.java @@ -17,6 +17,7 @@ package android.text; import android.graphics.Paint; +import android.os.Parcel; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.SmallTest; import android.text.Spannable; @@ -352,6 +353,51 @@ public class TextUtilsTest extends TestCase { assertFalse(TextUtils.delimitedStringContains("network,mock,gpsx", ',', "gps")); } + @SmallTest + public void testCharSequenceCreator() { + Parcel p = Parcel.obtain(); + TextUtils.writeToParcel(null, p, 0); + CharSequence text = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(p); + assertNull("null CharSequence should generate null from parcel", text); + p = Parcel.obtain(); + TextUtils.writeToParcel("test", p, 0); + text = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(p); + assertEquals("conversion to/from parcel failed", "test", text); + } + + @SmallTest + public void testCharSequenceCreatorNull() { + Parcel p; + CharSequence text; + p = Parcel.obtain(); + TextUtils.writeToParcel(null, p, 0); + p.setDataPosition(0); + text = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(p); + assertNull("null CharSequence should generate null from parcel", text); + } + + @SmallTest + public void testCharSequenceCreatorSpannable() { + Parcel p; + CharSequence text; + p = Parcel.obtain(); + TextUtils.writeToParcel(new SpannableString("test"), p, 0); + p.setDataPosition(0); + text = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(p); + assertEquals("conversion to/from parcel failed", "test", text.toString()); + } + + @SmallTest + public void testCharSequenceCreatorString() { + Parcel p; + CharSequence text; + p = Parcel.obtain(); + TextUtils.writeToParcel("test", p, 0); + p.setDataPosition(0); + text = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(p); + assertEquals("conversion to/from parcel failed", "test", text.toString()); + } + /** * CharSequence wrapper for testing the cases where text is copied into * a char array instead of working from a String or a Spanned. |