use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class NlPropertyOrderingTest method testSorting.
public void testSorting() {
@Language("XML") String source = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\" >" + " <TextView android:text=\"Hello\" />" + "</RelativeLayout>";
NlComponent component = getFirstComponent(source);
Table<String, String, NlPropertyItem> properties = NlProperties.getInstance().getProperties(ImmutableList.of(component));
List<NlPropertyItem> propertyList = new ArrayList<>(properties.values());
List<NlPropertyItem> sortedList = new NlPropertiesSorter().sort(propertyList, ImmutableList.of(component));
List<PTableItem> items = new NlPropertiesGrouper().group(sortedList, ImmutableList.of(component));
assertEquals("id attribute is not the first item", "id", items.get(0).getName());
assertEquals("Layout_width attribute is not the second item", "layout_width", items.get(1).getName());
assertEquals("Layout_height attribute is not the third item", "layout_height", items.get(2).getName());
assertEquals("Layout attributes group is not the fourth item", "Layout_Margin", items.get(3).getName());
assertEquals("Padding attributes group is not the fifth item", "Padding", items.get(4).getName());
assertTrue("TextView group not within the top 10 items", findItemIndex(items, "TextView") < 10);
assertTrue("Modified attribute text not in the top 10 items", findItemIndex(items, "text") < 10);
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class PropertyTestCase method createFrom.
@NotNull
protected NlPropertyItem createFrom(@NotNull NlComponent component, @NotNull String attributeName) {
List<NlComponent> components = ImmutableList.of(component);
XmlAttributeDescriptor descriptor = getDescriptor(component, attributeName);
assertThat(descriptor).isNotNull();
AttributeDefinition definition = getDefinition(component, descriptor);
String namespace = getNamespace(component, descriptor);
return NlPropertyItem.create(components, descriptor, namespace, definition);
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class PaletteTestCase method assertHorizontalProgressBarItem.
public void assertHorizontalProgressBarItem(@NotNull Palette.BaseItem item) {
checkItem(item, "ProgressBar", "ProgressBar (Horizontal)", AndroidIcons.Views.ProgressBarHorizontal, HORIZONTAL_PROGRESS_XML, HORIZONTAL_PROGRESS_PREVIEW_XML, HORIZONTAL_PROGRESS_XML, IN_PLATFORM, 2.0);
NlComponent component = createMockComponent("ProgressBar");
when(component.getAttribute(null, TAG_STYLE)).thenReturn(ANDROID_STYLE_RESOURCE_PREFIX + "Widget.ProgressBar.Horizontal");
checkComponent(component, "ProgressBar (Horizontal)", AndroidIcons.Views.ProgressBar);
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class PaletteTestCase method assertDiscreteSeekBar.
public void assertDiscreteSeekBar(@NotNull Palette.BaseItem item) {
checkItem(item, "SeekBar", "SeekBar (Discrete)", AndroidIcons.Views.SeekBar, DISCRETE_SEEKBAR_XML, DISCRETE_SEEKBAR_PREVIEW_XML, DISCRETE_SEEKBAR_XML, IN_PLATFORM, 1.0);
NlComponent component = createMockComponent("SeekBar");
when(component.getAttribute(null, TAG_STYLE)).thenReturn(ANDROID_STYLE_RESOURCE_PREFIX + "Widget.Material.SeekBar.Discrete");
checkComponent(component, "SeekBar", AndroidIcons.Views.SeekBar);
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class PaletteTestCase method assertVerticalLinearLayoutItem.
public void assertVerticalLinearLayoutItem(@NotNull Palette.BaseItem item) {
checkItem(item, LINEAR_LAYOUT, "LinearLayout (vertical)", AndroidIcons.Views.VerticalLinearLayout, VERTICAL_LINEAR_LAYOUT_XML, NO_PREVIEW, NO_PREVIEW, IN_PLATFORM, NO_SCALE);
NlComponent component = createMockComponent(LINEAR_LAYOUT);
when(component.getAttribute(ANDROID_URI, ATTR_ORIENTATION)).thenReturn(VALUE_VERTICAL);
checkComponent(component, "LinearLayout (vertical)", AndroidIcons.Views.VerticalLinearLayout);
}
Aggregations