|
17 | 17 | package android.text; |
18 | 18 |
|
19 | 19 | import android.graphics.Paint; |
| 20 | +import android.os.Parcel; |
20 | 21 | import android.test.suitebuilder.annotation.LargeTest; |
21 | 22 | import android.test.suitebuilder.annotation.SmallTest; |
22 | 23 | import android.text.Spannable; |
@@ -352,6 +353,51 @@ public void testDelimitedStringContains() { |
352 | 353 | assertFalse(TextUtils.delimitedStringContains("network,mock,gpsx", ',', "gps")); |
353 | 354 | } |
354 | 355 |
|
| 356 | + @SmallTest |
| 357 | + public void testCharSequenceCreator() { |
| 358 | + Parcel p = Parcel.obtain(); |
| 359 | + TextUtils.writeToParcel(null, p, 0); |
| 360 | + CharSequence text = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(p); |
| 361 | + assertNull("null CharSequence should generate null from parcel", text); |
| 362 | + p = Parcel.obtain(); |
| 363 | + TextUtils.writeToParcel("test", p, 0); |
| 364 | + text = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(p); |
| 365 | + assertEquals("conversion to/from parcel failed", "test", text); |
| 366 | + } |
| 367 | + |
| 368 | + @SmallTest |
| 369 | + public void testCharSequenceCreatorNull() { |
| 370 | + Parcel p; |
| 371 | + CharSequence text; |
| 372 | + p = Parcel.obtain(); |
| 373 | + TextUtils.writeToParcel(null, p, 0); |
| 374 | + p.setDataPosition(0); |
| 375 | + text = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(p); |
| 376 | + assertNull("null CharSequence should generate null from parcel", text); |
| 377 | + } |
| 378 | + |
| 379 | + @SmallTest |
| 380 | + public void testCharSequenceCreatorSpannable() { |
| 381 | + Parcel p; |
| 382 | + CharSequence text; |
| 383 | + p = Parcel.obtain(); |
| 384 | + TextUtils.writeToParcel(new SpannableString("test"), p, 0); |
| 385 | + p.setDataPosition(0); |
| 386 | + text = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(p); |
| 387 | + assertEquals("conversion to/from parcel failed", "test", text.toString()); |
| 388 | + } |
| 389 | + |
| 390 | + @SmallTest |
| 391 | + public void testCharSequenceCreatorString() { |
| 392 | + Parcel p; |
| 393 | + CharSequence text; |
| 394 | + p = Parcel.obtain(); |
| 395 | + TextUtils.writeToParcel("test", p, 0); |
| 396 | + p.setDataPosition(0); |
| 397 | + text = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(p); |
| 398 | + assertEquals("conversion to/from parcel failed", "test", text.toString()); |
| 399 | + } |
| 400 | + |
355 | 401 | /** |
356 | 402 | * CharSequence wrapper for testing the cases where text is copied into |
357 | 403 | * a char array instead of working from a String or a Spanned. |
|
0 commit comments