use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class DesignSurfaceTest method testEmptyRenderSuccess.
public void testEmptyRenderSuccess() {
NlModel model = model("absolute.xml", component(ABSOLUTE_LAYOUT).withBounds(0, 0, 1000, 1000).matchParentWidth().matchParentHeight()).build();
// Avoid rendering any other components (nav bar and similar) so we do not have dependencies on the Material theme
model.getConfiguration().setTheme("android:Theme.NoTitleBar.Fullscreen");
mySurface.setModel(model);
assertNull(model.getRenderResult());
mySurface.requestRender();
assertTrue(model.getRenderResult().getRenderResult().isSuccess());
assertTrue(mySurface.getErrorModel().getIssues().isEmpty());
}
use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class DesignSurfaceTest method ScreenPositioning.
// https://code.google.com/p/android/issues/detail?id=227931
public void ScreenPositioning() {
mySurface.addNotify();
mySurface.setBounds(0, 0, 400, 4000);
mySurface.validate();
// Process the resize events
IdeEventQueue.getInstance().flushQueue();
NlModel model = model("absolute.xml", component(ABSOLUTE_LAYOUT).withBounds(0, 0, 1000, 1000).matchParentWidth().matchParentHeight()).build();
// Avoid rendering any other components (nav bar and similar) so we do not have dependencies on the Material theme
model.getConfiguration().setTheme("android:Theme.NoTitleBar.Fullscreen");
mySurface.setModel(model);
assertNull(model.getRenderResult());
mySurface.setScreenMode(DesignSurface.ScreenMode.SCREEN_ONLY, false);
mySurface.requestRender();
assertTrue(model.getRenderResult().getRenderResult().isSuccess());
assertNotNull(mySurface.getCurrentScreenView());
assertNull(mySurface.getBlueprintView());
mySurface.setScreenMode(DesignSurface.ScreenMode.BOTH, false);
mySurface.requestRender();
assertTrue(model.getRenderResult().getRenderResult().isSuccess());
ScreenView screenView = mySurface.getCurrentScreenView();
ScreenView blueprintView = mySurface.getBlueprintView();
assertNotNull(screenView);
assertNotNull(blueprintView);
assertTrue(screenView.getY() < blueprintView.getY());
mySurface.setBounds(0, 0, 4000, 400);
mySurface.validate();
IdeEventQueue.getInstance().flushQueue();
// Horizontal stack
assertTrue(screenView.getY() == blueprintView.getY());
mySurface.removeNotify();
}
use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class DeleteAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
ScreenView screenView = mySurface.getCurrentScreenView();
if (screenView == null) {
return;
}
SelectionModel selectionModel = screenView.getSelectionModel();
NlModel model = screenView.getModel();
model.delete(selectionModel.getSelection());
}
use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class GenerateLayoutTestSkeletonAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
NlModel model = getModel(event.getProject());
if (model == null) {
return;
}
int option = Messages.showDialog(model.getProject(), "Generate LayoutTest skeleton with the current layout components.", "Generate LayoutTest Skeleton", new String[] { "Copy to Clipboard", "Cancel" }, 0, AndroidIcons.AndroidTestRoot);
if (option == 0) {
CopyPasteManager.getInstance().setContents(new StringSelection(generateModelFixture(model)));
}
}
use of com.android.tools.idea.uibuilder.model.NlModel 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