use of com.android.tools.idea.uibuilder.fixtures.ModelBuilder in project android by JetBrains.
the class AbsoluteLayoutHandlerTest method createModel.
@NotNull
private NlModel createModel() {
ModelBuilder builder = model("absolute.xml", component(ABSOLUTE_LAYOUT).withBounds(0, 0, 1000, 1000).matchParentWidth().matchParentHeight().children(component(TEXT_VIEW).withBounds(100, 100, 100, 100).id("@id/myText").width("100dp").height("100dp").withAttribute("android:layout_x", "100dp").withAttribute("android:layout_y", "100dp")));
final NlModel model = builder.build();
assertEquals(1, model.getComponents().size());
assertEquals("NlComponent{tag=<AbsoluteLayout>, bounds=[0,0:1000x1000}\n" + " NlComponent{tag=<TextView>, bounds=[100,100:100x100}", NlTreeDumper.dumpTree(model.getComponents()));
format(model.getFile());
assertEquals("<AbsoluteLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + " android:layout_width=\"match_parent\"\n" + " android:layout_height=\"match_parent\">\n" + "\n" + " <TextView\n" + " android:id=\"@id/myText\"\n" + " android:layout_width=\"100dp\"\n" + " android:layout_height=\"100dp\"\n" + " android:layout_x=\"100dp\"\n" + " android:layout_y=\"100dp\" />\n" + "\n" + "</AbsoluteLayout>\n", model.getFile().getText());
return model;
}
use of com.android.tools.idea.uibuilder.fixtures.ModelBuilder in project android by JetBrains.
the class AbsoluteLayoutHandlerTest method testDragToLayout2.
public void testDragToLayout2() throws Exception {
// Drag from one layout to another
ModelBuilder builder = model("absolute3.xml", component(LINEAR_LAYOUT).withBounds(0, 0, 1000, 1000).matchParentWidth().matchParentHeight().withAttribute(ANDROID_URI, ATTR_ORIENTATION, VALUE_VERTICAL).children(component(ABSOLUTE_LAYOUT).withBounds(0, 0, 1000, 850).id("myAbsLayout").matchParentWidth().height("0dp").withAttribute(ANDROID_URI, ATTR_LAYOUT_WEIGHT, VALUE_1), component(TEXT_VIEW).withBounds(0, 850, 1000, 150).id("@id/myText").width("1000px").height("150px")));
@Language("XML") String xml = "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + " android:layout_width=\"match_parent\"\n" + " android:layout_height=\"match_parent\"\n" + " android:orientation=\"vertical\">\n" + "\n" + " <AbsoluteLayout\n" + " android:id=\"myAbsLayout\"\n" + " android:layout_width=\"match_parent\"\n" + " android:layout_height=\"0dp\"\n" + " android:layout_weight=\"1\"/>\n" + "\n" + " <TextView\n" + " android:id=\"@id/myText\"\n" + " android:layout_width=\"1000px\"\n" + " android:layout_height=\"150px\"/>\n" + "\n" + "</LinearLayout>\n";
assertEquals(xml, builder.toXml());
final NlModel model = builder.build();
assertEquals(1, model.getComponents().size());
assertEquals("NlComponent{tag=<LinearLayout>, bounds=[0,0:1000x1000}\n" + " NlComponent{tag=<AbsoluteLayout>, bounds=[0,0:1000x850}\n" + " NlComponent{tag=<TextView>, bounds=[0,850:1000x150}", NlTreeDumper.dumpTree(model.getComponents()));
surface().screen(model).get("@id/myText").drag().drag(50, // into AbsoluteLayout sibling
-300).release().primary().parent().parent().expectXml("<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + " android:layout_width=\"match_parent\"\n" + " android:layout_height=\"match_parent\"\n" + " android:orientation=\"vertical\">\n" + "\n" + " <AbsoluteLayout\n" + " android:id=\"myAbsLayout\"\n" + " android:layout_width=\"match_parent\"\n" + " android:layout_height=\"0dp\"\n" + " android:layout_weight=\"1\">\n" + "\n" + " <TextView\n" + " android:id=\"@id/myText\"\n" + " android:layout_width=\"1000px\"\n" + " android:layout_height=\"150px\"\n" + " android:layout_x=\"50dp\"\n" + " android:layout_y=\"550dp\" />\n" + " </AbsoluteLayout>\n" + "\n" + "</LinearLayout>");
}
use of com.android.tools.idea.uibuilder.fixtures.ModelBuilder in project android by JetBrains.
the class MockupTestCase method createModel1Mockup.
protected NlModel createModel1Mockup(@NotNull String mockupFile, @Nullable String mockupPosition, @Nullable String opacity) {
final ComponentDescriptor root = component(RELATIVE_LAYOUT).withBounds(0, 0, 1000, 1000).matchParentWidth().matchParentHeight().withAttribute(TOOLS_URI, ATTR_MOCKUP, mockupFile);
if (mockupPosition != null) {
root.withAttribute(TOOLS_URI, ATTR_MOCKUP_CROP, mockupPosition);
}
if (opacity != null) {
root.withAttribute(TOOLS_URI, ATTR_MOCKUP_OPACITY, opacity);
}
ModelBuilder builder = model("relative.xml", root);
final NlModel model = builder.build();
assertEquals(1, model.getComponents().size());
return model;
}
use of com.android.tools.idea.uibuilder.fixtures.ModelBuilder in project android by JetBrains.
the class NlComponentTreeTest method createModel.
@NotNull
private NlModel createModel() {
ModelBuilder builder = model("relative.xml", component(RELATIVE_LAYOUT).withBounds(0, 0, 1000, 1000).matchParentWidth().matchParentHeight().children(component(LINEAR_LAYOUT).withBounds(0, 0, 200, 200).wrapContentWidth().wrapContentHeight().children(component(BUTTON).withBounds(0, 0, 100, 100).id("@+id/myButton").width("100dp").height("100dp")), component(TEXT_VIEW).withBounds(0, 200, 100, 100).id("@+id/myText").width("100dp").height("100dp"), component(ABSOLUTE_LAYOUT).withBounds(0, 300, 400, 500).width("400dp").height("500dp")));
final NlModel model = builder.build();
assertEquals(1, model.getComponents().size());
assertEquals("NlComponent{tag=<RelativeLayout>, bounds=[0,0:1000x1000}\n" + " NlComponent{tag=<LinearLayout>, bounds=[0,0:200x200}\n" + " NlComponent{tag=<Button>, bounds=[0,0:100x100}\n" + " NlComponent{tag=<TextView>, bounds=[0,200:100x100}\n" + " NlComponent{tag=<AbsoluteLayout>, bounds=[0,300:400x500}", NlTreeDumper.dumpTree(model.getComponents()));
return model;
}
use of com.android.tools.idea.uibuilder.fixtures.ModelBuilder in project android by JetBrains.
the class MockupTestCase method createModel2Mockup.
@NotNull
protected NlModel createModel2Mockup(String mockupFile, @NotNull String mockupPosition) {
ModelBuilder builder = model("relative.xml", component(RELATIVE_LAYOUT).withBounds(0, 0, 1000, 1000).matchParentWidth().matchParentHeight().withAttribute(TOOLS_URI, ATTR_MOCKUP, mockupFile).withAttribute(TOOLS_URI, ATTR_MOCKUP_CROP, mockupPosition).children(component(LINEAR_LAYOUT).withBounds(0, 0, 200, 200).wrapContentWidth().wrapContentHeight().withAttribute(TOOLS_URI, ATTR_MOCKUP, mockupFile).withAttribute(TOOLS_URI, ATTR_MOCKUP_CROP, mockupPosition).children(component(BUTTON).withBounds(0, 0, 100, 100).id("@+id/myButton").width("100dp").height("100dp")), component(TEXT_VIEW).withBounds(0, 200, 100, 100).id("@+id/myText").width("100dp").height("100dp"), component(ABSOLUTE_LAYOUT).withBounds(0, 300, 400, 500).width("400dp").height("500dp")));
final NlModel model = builder.build();
assertEquals(1, model.getComponents().size());
assertEquals(3, model.getComponents().get(0).getChildCount());
assertEquals("NlComponent{tag=<RelativeLayout>, bounds=[0,0:1000x1000}\n" + " NlComponent{tag=<LinearLayout>, bounds=[0,0:200x200}\n" + " NlComponent{tag=<Button>, bounds=[0,0:100x100}\n" + " NlComponent{tag=<TextView>, bounds=[0,200:100x100}\n" + " NlComponent{tag=<AbsoluteLayout>, bounds=[0,300:400x500}", NlTreeDumper.dumpTree(model.getComponents()));
return model;
}
Aggregations