Search in sources :

Example 36 with NlComponent

use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.

the class PreferenceScreenTestFactory method newPreferenceCategory.

@NotNull
static NlComponent newPreferenceCategory(int x, int y, int width, int height) {
    NlComponent category = HandlerTestFactory.newNlComponent(PREFERENCE_CATEGORY);
    category.setBounds(x, y, width, height);
    return category;
}
Also used : NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) NotNull(org.jetbrains.annotations.NotNull)

Example 37 with NlComponent

use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.

the class PreferenceScreenTestFactory method newCheckBoxPreference.

@NotNull
static NlComponent newCheckBoxPreference(int x, int y, int width, int height) {
    NlComponent preference = HandlerTestFactory.newNlComponent(CHECK_BOX_PREFERENCE);
    preference.setBounds(x, y, width, height);
    return preference;
}
Also used : NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) NotNull(org.jetbrains.annotations.NotNull)

Example 38 with NlComponent

use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.

the class GroupDragHandlerTest method updateUsingOverflowGroup.

@Test
public void updateUsingOverflowGroup() {
    NlComponent menu = newMenu(366, 162, 392, 288);
    menu.addChild(newOverflowItem(366, 162, 392, 96));
    menu.addChild(newOverflowItem(366, 258, 392, 96));
    menu.addChild(newOverflowItem(366, 354, 392, 96));
    GroupDragHandler handler = newGroupDragHandler(menu);
    int y = 90;
    y += 48;
    handler.update(0, y, 0);
    assertEquals(0, handler.getInsertIndex());
    y += 48;
    handler.update(0, y, 0);
    assertEquals(0, handler.getInsertIndex());
    y += 48;
    handler.update(0, y, 0);
    assertEquals(1, handler.getInsertIndex());
    y += 48;
    handler.update(0, y, 0);
    assertEquals(1, handler.getInsertIndex());
    y += 48;
    handler.update(0, y, 0);
    assertEquals(2, handler.getInsertIndex());
    y += 48;
    handler.update(0, y, 0);
    assertEquals(2, handler.getInsertIndex());
    y += 48;
    handler.update(0, y, 0);
    assertEquals(-1, handler.getInsertIndex());
    y += 48;
    handler.update(0, y, 0);
    assertEquals(-1, handler.getInsertIndex());
}
Also used : NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) Test(org.junit.Test)

Example 39 with NlComponent

use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.

the class ActionBarTest method addToItemsOrOverflowItemsItemViewTypeIsActionBarMenu.

@Test
public void addToItemsOrOverflowItemsItemViewTypeIsActionBarMenu() {
    NlComponent item = HandlerTestFactory.newNlComponent("item");
    item.viewInfo = MenuTestFactory.mockViewInfo(ViewType.ACTION_BAR_MENU);
    NlComponent menu = HandlerTestFactory.newNlComponent("menu");
    menu.addChild(item);
    ActionBar actionBar = new ActionBar(menu);
    assertEquals(Collections.singletonList(item), actionBar.getItems());
    assertEquals(Collections.emptyList(), actionBar.getOverflowItems());
}
Also used : NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) Test(org.junit.Test)

Example 40 with NlComponent

use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.

the class GridDragHandlerTest method testCommit.

public void testCommit() {
    handler.start(630, 210, 0);
    handler.update(470, 210, 0);
    WriteCommandAction.runWriteCommandAction(getProject(), () -> {
        handler.commit(470, 210, 0, InsertType.MOVE_INTO);
    });
    NlComponent[][] children = handler.getInfo().getChildren();
    NlComponent child = children[handler.getStartRow()][handler.getStartColumn()];
    assertEquals("0", child.getAttribute(SdkConstants.ANDROID_URI, SdkConstants.ATTR_LAYOUT_ROW));
    assertEquals("1", child.getAttribute(SdkConstants.ANDROID_URI, SdkConstants.ATTR_LAYOUT_COLUMN));
}
Also used : NlComponent(com.android.tools.idea.uibuilder.model.NlComponent)

Aggregations

NlComponent (com.android.tools.idea.uibuilder.model.NlComponent)184 NlModel (com.android.tools.idea.uibuilder.model.NlModel)34 NotNull (org.jetbrains.annotations.NotNull)34 NlProperty (com.android.tools.idea.uibuilder.property.NlProperty)18 ScreenView (com.android.tools.idea.uibuilder.surface.ScreenView)17 Nullable (org.jetbrains.annotations.Nullable)14 Test (org.junit.Test)12 Matchers.anyString (org.mockito.Matchers.anyString)11 ViewGroupHandler (com.android.tools.idea.uibuilder.api.ViewGroupHandler)9 AttributesTransaction (com.android.tools.idea.uibuilder.model.AttributesTransaction)9 AttributeDefinition (org.jetbrains.android.dom.attrs.AttributeDefinition)8 NlPropertyItem (com.android.tools.idea.uibuilder.property.NlPropertyItem)7 XmlFile (com.intellij.psi.xml.XmlFile)7 XmlTag (com.intellij.psi.xml.XmlTag)7 ArrayList (java.util.ArrayList)7 ModelBuilder (com.android.tools.idea.uibuilder.fixtures.ModelBuilder)6 NlGraphics (com.android.tools.idea.uibuilder.graphics.NlGraphics)6 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)6 Project (com.intellij.openapi.project.Project)6 List (java.util.List)6