use of com.android.tools.idea.uibuilder.model.NlModel 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.NlModel 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());
}
use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class MockupTest method testCreateMockupModelFromIncorrectPositionString.
public void testCreateMockupModelFromIncorrectPositionString() {
final NlModel model = createModel1Mockup(MOCKUP_PSD, "1 2d");
NlComponent component = model.getComponents().get(0);
//mockProject, "", "1 2d");
final Mockup mockup = Mockup.create(component);
assertNotNull(mockup);
}
use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class MockupTest method testCreateMockup.
public void testCreateMockup() {
final NlModel model = createModel1Mockup(MOCKUP_PSD, DEFAULT_TEST_POSITION, "0.4");
NlComponent component = model.getComponents().get(0).getRoot();
final Mockup mockup = Mockup.create(component);
assertNotNull("Model creation", mockup);
assertEquals(new Rectangle(20, 20, 60, 60), mockup.getBounds());
assertEquals(new Rectangle(10, 10, 60, 60), mockup.getCropping());
assertEquals(0.4f, mockup.getAlpha());
}
use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class MockupTestCase method createModel0Mockup.
protected NlModel createModel0Mockup() {
ModelBuilder builder = model("relative.xml", component(RELATIVE_LAYOUT).withBounds(0, 0, 1000, 1000).matchParentWidth().matchParentHeight());
final NlModel model = builder.build();
assertEquals(1, model.getComponents().size());
return model;
}
Aggregations