use of com.android.tools.idea.uibuilder.model.NlComponent 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.NlComponent 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.NlComponent 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.NlComponent in project android by JetBrains.
the class MockupTest method testGetBounds_0000_Position.
public void testGetBounds_0000_Position() {
final NlModel model = createModel1Mockup(MOCKUP_PSD, "0 0 0 0", 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 componentSwingCoordinates = new Rectangle(0, 0, Coordinates.getSwingDimension(screenView, 1000), // See createModel for the 1000 value
Coordinates.getSwingDimension(screenView, 1000));
final Rectangle destinationRectangle = mockup.getScreenBounds(screenView);
assertEquals(componentSwingCoordinates, destinationRectangle);
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class MockupTest method testCreateMockupModelFromCorrectFullString.
public void testCreateMockupModelFromCorrectFullString() {
final NlModel model = createModel1Mockup(MOCKUP_PSD, "5 6 7 8 1 2 3 4");
NlComponent component = model.getComponents().get(0);
//mockProject, "", "1 2 3 4 5 6 7 8");
final Mockup mockup = Mockup.create(component);
assertNotNull(mockup);
assertEquals(new Rectangle(1, 2, 3, 4), mockup.getBounds());
assertEquals(new Rectangle(5, 6, 7, 8), mockup.getCropping());
}
Aggregations