use of com.android.tools.idea.XmlBuilder in project android by JetBrains.
the class XmlBuilderTest method toStringEmptyElementLayout.
@Test
public void toStringEmptyElementLayout() {
@Language("XML") String expected = "<LinearLayout>\n" + "\n" + "</LinearLayout>\n";
String actual = new XmlBuilder().startTag("LinearLayout").endTag("LinearLayout").toString();
assertEquals(expected, actual);
}
use of com.android.tools.idea.XmlBuilder in project android by JetBrains.
the class XmlBuilderTest method toStringTabHost.
@Test
public void toStringTabHost() {
@Language("XML") String expected = "<TabHost\n" + " android:layout_width=\"200dip\"\n" + " android:layout_height=\"300dip\">\n" + "\n" + " <LinearLayout\n" + " android:layout_width=\"match_parent\"\n" + " android:layout_height=\"match_parent\"\n" + " android:orientation=\"vertical\">\n" + "\n" + " <TabWidget\n" + " android:id=\"@android:id/tabs\"\n" + " android:layout_width=\"match_parent\"\n" + " android:layout_height=\"wrap_content\" />\n" + "\n" + " <FrameLayout\n" + " android:id=\"@android:id/tab_content\"\n" + " android:layout_width=\"match_parent\"\n" + " android:layout_height=\"match_parent\">\n" + "\n" + " <LinearLayout\n" + " android:id=\"@+id/tab_1\"\n" + " android:layout_width=\"match_parent\"\n" + " android:layout_height=\"match_parent\"\n" + " android:orientation=\"vertical\">\n" + "\n" + " </LinearLayout>\n" + "\n" + " <LinearLayout\n" + " android:id=\"@+id/tab_2\"\n" + " android:layout_width=\"match_parent\"\n" + " android:layout_height=\"match_parent\"\n" + " android:orientation=\"vertical\">\n" + "\n" + " </LinearLayout>\n" + "\n" + " <LinearLayout\n" + " android:id=\"@+id/tab_3\"\n" + " android:layout_width=\"match_parent\"\n" + " android:layout_height=\"match_parent\"\n" + " android:orientation=\"vertical\">\n" + "\n" + " </LinearLayout>\n" + " </FrameLayout>\n" + " </LinearLayout>\n" + "</TabHost>\n";
// @formatter:off
XmlBuilder builder = new XmlBuilder().startTag("TabHost").androidAttribute(SdkConstants.ATTR_LAYOUT_WIDTH, "200dip").androidAttribute(SdkConstants.ATTR_LAYOUT_HEIGHT, "300dip").startTag("LinearLayout").androidAttribute(SdkConstants.ATTR_LAYOUT_WIDTH, SdkConstants.VALUE_MATCH_PARENT).androidAttribute(SdkConstants.ATTR_LAYOUT_HEIGHT, SdkConstants.VALUE_MATCH_PARENT).androidAttribute("orientation", "vertical").startTag("TabWidget").androidAttribute("id", "@android:id/tabs").androidAttribute(SdkConstants.ATTR_LAYOUT_WIDTH, SdkConstants.VALUE_MATCH_PARENT).androidAttribute(SdkConstants.ATTR_LAYOUT_HEIGHT, SdkConstants.VALUE_WRAP_CONTENT).endTag("TabWidget").startTag("FrameLayout").androidAttribute("id", "@android:id/tab_content").androidAttribute(SdkConstants.ATTR_LAYOUT_WIDTH, SdkConstants.VALUE_MATCH_PARENT).androidAttribute(SdkConstants.ATTR_LAYOUT_HEIGHT, SdkConstants.VALUE_MATCH_PARENT);
for (int i = 0; i < 3; i++) {
builder.startTag("LinearLayout").androidAttribute("id", "@+id/tab_" + (i + 1)).androidAttribute(SdkConstants.ATTR_LAYOUT_WIDTH, SdkConstants.VALUE_MATCH_PARENT).androidAttribute(SdkConstants.ATTR_LAYOUT_HEIGHT, SdkConstants.VALUE_MATCH_PARENT).androidAttribute("orientation", "vertical").endTag("LinearLayout");
}
// @formatter:off
builder.endTag("FrameLayout").endTag("LinearLayout").endTag("TabHost");
// @formatter:on
assertEquals(expected, builder.toString());
}
use of com.android.tools.idea.XmlBuilder in project android by JetBrains.
the class XmlBuilderTest method toStringNoClosePreviousTagWithoutAttributes.
@Test
public void toStringNoClosePreviousTagWithoutAttributes() {
@Language("XML") String expected = "<Foo>\n\n" + " <Bar />\n" + "</Foo>\n";
// @formatter:off
String actual = new XmlBuilder().startTag("Foo").startTag("Bar").endTag("Bar").endTag("Foo").toString();
// @formatter:on
assertEquals(expected, actual);
}
use of com.android.tools.idea.XmlBuilder in project android by JetBrains.
the class XmlBuilderTest method toStringEmptyElementNotLayout.
@Test
public void toStringEmptyElementNotLayout() {
@Language("XML") String expected = "<TabWidget />\n";
String actual = new XmlBuilder().startTag("TabWidget").endTag("TabWidget").toString();
assertEquals(expected, actual);
}
use of com.android.tools.idea.XmlBuilder in project android by JetBrains.
the class PaletteTestCase method assertLimitedHeightLayout.
private void assertLimitedHeightLayout(@NotNull Palette.BaseItem item, @NotNull String tag, @NotNull String expectedGradleCoordinate) {
@Language("XML") String xml = new XmlBuilder().startTag(tag).androidAttribute(ATTR_LAYOUT_WIDTH, VALUE_MATCH_PARENT).androidAttribute(ATTR_LAYOUT_HEIGHT, VALUE_WRAP_CONTENT).endTag(tag).toString();
checkItem(item, tag, STANDARD_VIEW.getTitle(tag), STANDARD_LAYOUT.getIcon(tag), xml, NO_PREVIEW, NO_PREVIEW, expectedGradleCoordinate, NO_SCALE);
checkComponent(createMockComponent(tag), STANDARD_VIEW.getTitle(tag), STANDARD_LAYOUT.getIcon(tag));
}
Aggregations