use of com.android.tools.idea.uibuilder.model.NlModel 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.model.NlModel in project android by JetBrains.
the class MockupTest method testGetBounds_nullPosition.
public void testGetBounds_nullPosition() {
final NlModel model = createModel1Mockup(MOCKUP_PSD, null, null);
final NlComponent component = model.getComponents().get(0);
final Mockup mockup = Mockup.create(component);
assertNotNull(mockup);
DesignSurface mockSurface = mock(DesignSurface.class);
when(mockSurface.getScale()).thenReturn(1.0);
final ScreenView screenView = new ScreenView(mockSurface, ScreenView.ScreenViewType.BLUEPRINT, model);
final Rectangle destinationRectangle = mockup.getScreenBounds(screenView);
assertEquals(new Rectangle(0, 0, component.w, component.h), destinationRectangle);
}
use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class MockupTest method testGetCropping_FullImage.
public void testGetCropping_FullImage() {
final NlModel model = createModel1Mockup(getTestDataPath() + "/" + MOCKUP_PSD, "");
NlComponent component = model.getComponents().get(0);
//mockProject, "", "1 2 3 4");
final Mockup mockup = Mockup.create(component);
assertNotNull(mockup);
final BufferedImage image = mockup.getImage();
assertNotNull(image);
assertEquals(new Rectangle(0, 0, image.getWidth(), image.getHeight()), mockup.getCropping());
}
use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class MockupTest method testFilePathRelative.
public void testFilePathRelative() {
if (SystemInfo.isWindows) {
// Do not run tests on Windows (see http://b.android.com/222904)
return;
}
final NlModel model = createModel1Mockup(MOCKUP_PSD, DEFAULT_TEST_POSITION, null);
final NlComponent component = model.getComponents().get(0);
final Mockup mockup = Mockup.create(component);
assertNotNull(mockup);
assertEquals(model.getProject().getBasePath() + "/" + MOCKUP_PSD, mockup.getFilePath());
}
use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class MockupTest method testCreateMockupModelFromCorrectPositionString.
public void testCreateMockupModelFromCorrectPositionString() {
final NlModel model = createModel1Mockup(MOCKUP_PSD, "1 2 3 4");
NlComponent component = model.getComponents().get(0);
//mockProject, "", "1 2 3 4");
final Mockup mockup = Mockup.create(component);
assertNotNull(mockup);
assertEquals(new Rectangle(1, 2, 3, 4), mockup.getCropping());
assertEquals(new Rectangle(0, 0, -1, -1), mockup.getBounds());
}
Aggregations