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;
}
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());
}
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());
}
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));
}
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);
}
Aggregations