Search in sources :

Example 1 with StyledString

use of com.android.aapt.Resources.StyledString in project bundletool by google.

the class XmlProtoPrintUtilsTest method processStyledString_startAtSamePositionEndAtDifferentPosition.

@Test
public void processStyledString_startAtSamePositionEndAtDifferentPosition() {
    StyledString styledString = StyledString.newBuilder().setValue("hello").addSpan(Span.newBuilder().setTag("a").setFirstChar(0).setLastChar(2)).addSpan(Span.newBuilder().setTag("b").setFirstChar(0).setLastChar(4)).build();
    String processedString = XmlProtoPrintUtils.processStyledString(styledString);
    assertThat(processedString).isEqualTo("<b><a>hel</a>lo</b>");
}
Also used : StyledString(com.android.aapt.Resources.StyledString) StyledString(com.android.aapt.Resources.StyledString) Test(org.junit.Test)

Example 2 with StyledString

use of com.android.aapt.Resources.StyledString in project bundletool by google.

the class XmlProtoPrintUtilsTest method processStyledString_nestedTags.

@Test
public void processStyledString_nestedTags() {
    StyledString styledString = StyledString.newBuilder().setValue("hello").addSpan(Span.newBuilder().setTag("a").setFirstChar(0).setLastChar(4)).addSpan(Span.newBuilder().setTag("b").setFirstChar(1).setLastChar(3)).addSpan(Span.newBuilder().setTag("c").setFirstChar(2).setLastChar(2)).build();
    String processedString = XmlProtoPrintUtils.processStyledString(styledString);
    assertThat(processedString).isEqualTo("<a>h<b>e<c>l</c>l</b>o</a>");
}
Also used : StyledString(com.android.aapt.Resources.StyledString) StyledString(com.android.aapt.Resources.StyledString) Test(org.junit.Test)

Example 3 with StyledString

use of com.android.aapt.Resources.StyledString in project bundletool by google.

the class XmlProtoPrintUtilsTest method processStyledString_differentTagsStartAndEndAtSamePosition.

@Test
public void processStyledString_differentTagsStartAndEndAtSamePosition() {
    StyledString styledString = StyledString.newBuilder().setValue("hello").addSpan(Span.newBuilder().setTag("a").setFirstChar(0).setLastChar(2)).addSpan(Span.newBuilder().setTag("b").setFirstChar(3).setLastChar(4)).build();
    String processedString = XmlProtoPrintUtils.processStyledString(styledString);
    assertThat(processedString).isEqualTo("<a>hel</a><b>lo</b>");
}
Also used : StyledString(com.android.aapt.Resources.StyledString) StyledString(com.android.aapt.Resources.StyledString) Test(org.junit.Test)

Example 4 with StyledString

use of com.android.aapt.Resources.StyledString in project bundletool by google.

the class XmlProtoPrintUtilsTest method processStyledString_withAttributes.

@Test
public void processStyledString_withAttributes() {
    StyledString styledString = StyledString.newBuilder().setValue("hello").addSpan(Span.newBuilder().setTag("a;attr1=value1;attr2=value2").setFirstChar(0).setLastChar(4)).build();
    String processedString = XmlProtoPrintUtils.processStyledString(styledString);
    assertThat(processedString).isEqualTo("<a attr1=\"value1\" attr2=\"value2\">hello</a>");
}
Also used : StyledString(com.android.aapt.Resources.StyledString) StyledString(com.android.aapt.Resources.StyledString) Test(org.junit.Test)

Example 5 with StyledString

use of com.android.aapt.Resources.StyledString in project bundletool by google.

the class XmlProtoPrintUtilsTest method processStyledString_startAtDifferentPositionEndAtSamePosition.

@Test
public void processStyledString_startAtDifferentPositionEndAtSamePosition() {
    StyledString styledString = StyledString.newBuilder().setValue("hello").addSpan(Span.newBuilder().setTag("a").setFirstChar(0).setLastChar(4)).addSpan(Span.newBuilder().setTag("b").setFirstChar(3).setLastChar(4)).build();
    String processedString = XmlProtoPrintUtils.processStyledString(styledString);
    assertThat(processedString).isEqualTo("<a>hel<b>lo</b></a>");
}
Also used : StyledString(com.android.aapt.Resources.StyledString) StyledString(com.android.aapt.Resources.StyledString) Test(org.junit.Test)

Aggregations

StyledString (com.android.aapt.Resources.StyledString)9 Test (org.junit.Test)9