use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class LinearLayoutHandlerTest method createModel.
@NotNull
private NlModel createModel() {
ModelBuilder builder = model("linear.xml", component(LINEAR_LAYOUT).withBounds(0, 0, 1000, 1000).matchParentWidth().matchParentHeight().children(component(TEXT_VIEW).withBounds(100, 100, 100, 100).id("@id/myText1").width("100dp").height("100dp"), component(BUTTON).withBounds(100, 200, 100, 100).id("@id/myText2").width("100dp").height("100dp").withAttribute("android:layout_weight", "1.0")));
final NlModel model = builder.build();
assertEquals(1, model.getComponents().size());
assertEquals("NlComponent{tag=<LinearLayout>, bounds=[0,0:1000x1000}\n" + " NlComponent{tag=<TextView>, bounds=[100,100:100x100}\n" + " NlComponent{tag=<Button>, bounds=[100,200:100x100}", NlTreeDumper.dumpTree(model.getComponents()));
format(model.getFile());
return model;
}
use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class GridDragHandlerTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
GridLayout viewObject = new GridLayout();
viewObject.setVerticalAxis(new Axis(new int[] { 0, 1024 }));
viewObject.setHorizontalAxis(new Axis(new int[] { 0, 248, 248, 248, 248, 248, 248, 248, 248, 520, 768 }));
viewObject.setRowCount(1);
viewObject.setColumnCount(10);
// @formatter:off
ComponentDescriptor button1 = component(SdkConstants.BUTTON).withBounds(0, 160, 248, 96).withAttribute("android:layout_row", "0").withAttribute("android:layout_column", "0").layoutParamsObject(new LayoutParams(new Spec(new Interval(0, 1)), new Spec(new Interval(0, 1))));
ComponentDescriptor button2 = component(SdkConstants.BUTTON).withBounds(520, 160, 248, 96).withAttribute("android:layout_row", "0").withAttribute("android:layout_column", "9").layoutParamsObject(new LayoutParams(new Spec(new Interval(0, 1)), new Spec(new Interval(9, 10))));
ComponentDescriptor layout = component(SdkConstants.GRID_LAYOUT).withBounds(0, 160, 768, 1024).viewObject(viewObject).children(button1, button2);
NlModel model = model("grid_layout.xml", layout).build();
// @formatter:on
ViewEditor editor = Mockito.mock(ViewEditor.class);
Mockito.when(editor.getModel()).thenReturn(model);
List<NlComponent> components = Collections.emptyList();
handler = new GridDragHandler(editor, new ViewGroupHandler(), model.getComponents().get(0), components, DragType.CREATE);
}
use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class MockupTest method testSetAlphaString.
public void testSetAlphaString() {
NlModel model = createModel1Mockup(MOCKUP_PSD, DEFAULT_TEST_POSITION);
final NlComponent component = model.getComponents().get(0);
final Mockup mockup = Mockup.create(component);
assertNotNull(mockup);
assertEquals(Mockup.DEFAULT_OPACITY, mockup.getAlpha());
mockup.setAlpha("0.9");
assertEquals(0.9f, mockup.getAlpha());
mockup.setAlpha("2.9");
assertEquals(Mockup.DEFAULT_OPACITY_IF_ERROR, mockup.getAlpha());
mockup.setAlpha("-2.9");
assertEquals(Mockup.DEFAULT_OPACITY_IF_ERROR, mockup.getAlpha());
}
use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class MockupTest method testCreateMockupLayerEmptyStringPosition.
public void testCreateMockupLayerEmptyStringPosition() {
final NlModel model = createModel1Mockup(MOCKUP_PSD, "");
NlComponent component = model.getComponents().get(0).getRoot();
final Mockup mockup = Mockup.create(component);
assertNotNull("Model creation", mockup);
assertEquals(new Rectangle(0, 0, -1, -1), mockup.getBounds());
assertEquals(new Rectangle(0, 0, -1, -1), mockup.getCropping());
}
use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class MockupTest method testGetAllMockupNoMockup.
public void testGetAllMockupNoMockup() {
final NlModel model = createModel0Mockup();
final List<Mockup> all = Mockup.createAll(model);
assertNotNull(all);
assertSize(0, all);
}
Aggregations