Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4c4a276 authored by Conley Owens's avatar Conley Owens
Browse files

Merge commit 'f395e304' into m

Conflicts:
	core/tests/coretests/src/android/text/TextUtilsTest.java

Change-Id: I7439f7f80cf91ff654c0ddd79c3e6b3808ba4784
parents a31b3f26 f395e304
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -629,10 +629,16 @@ public class TextUtils {
        public CharSequence createFromParcel(Parcel p) {
            int kind = p.readInt();

            if (kind == 1)
                return p.readString();
            String string = p.readString();
            if (string == null) {
                return null;
            }

            if (kind == 1) {
                return string;
            }

            SpannableString sp = new SpannableString(p.readString());
            SpannableString sp = new SpannableString(string);

            while (true) {
                kind = p.readInt();
+46 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ 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.text.style.StyleSpan;
@@ -344,6 +345,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.