Search in sources :

Example 16 with ComponentDescriptor

use of com.android.tools.idea.uibuilder.fixtures.ComponentDescriptor in project android by JetBrains.

the class SceneCreationTest method testSceneReparenting.

public void testSceneReparenting() {
    ModelBuilder builder = createModel();
    NlModel model = builder.build();
    Scene scene = Scene.createScene(model, myScreen.getScreen());
    scene.setDpiFactorOverride(1);
    scene.setAnimate(false);
    assertEquals(scene.getRoot().getChildren().size(), 1);
    ComponentDescriptor parent = builder.findByPath(CONSTRAINT_LAYOUT);
    parent.addChild(component(CONSTRAINT_LAYOUT).id("@id/layout").withBounds(200, 300, 200, 200).width("200dp").height("200dp"), null);
    builder.updateModel(model, false);
    scene.updateFrom(model);
    assertEquals(2, scene.getRoot().getChildren().size());
    NlComponent textView = scene.getRoot().getChild(0).getNlComponent();
    NlComponent container = scene.getRoot().getChild(1).getNlComponent();
    scene.getRoot().getNlComponent().removeChild(textView);
    container.addChild(textView);
    scene.updateFrom(model);
    assertEquals(1, scene.getRoot().getChildCount());
    SceneComponent layout = scene.getSceneComponent("layout");
    assertEquals(1, layout.getChildCount());
}
Also used : ModelBuilder(com.android.tools.idea.uibuilder.fixtures.ModelBuilder) NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) ComponentDescriptor(com.android.tools.idea.uibuilder.fixtures.ComponentDescriptor) NlModel(com.android.tools.idea.uibuilder.model.NlModel)

Aggregations

ComponentDescriptor (com.android.tools.idea.uibuilder.fixtures.ComponentDescriptor)16 ModelBuilder (com.android.tools.idea.uibuilder.fixtures.ModelBuilder)12 NlComponent (com.android.tools.idea.uibuilder.model.NlComponent)5 NlModel (com.android.tools.idea.uibuilder.model.NlModel)5 Configuration (com.android.tools.idea.configurations.Configuration)1 ViewEditor (com.android.tools.idea.uibuilder.api.ViewEditor)1 ViewGroupHandler (com.android.tools.idea.uibuilder.api.ViewGroupHandler)1