use of com.android.tools.idea.uibuilder.property.editors.NlComponentEditor in project android by JetBrains.
the class FavoritesInspectorProviderTest method testInspectorComponent.
public void testInspectorComponent() {
NlPropertyItem elevation = createFrom(myTextView, ATTR_ELEVATION);
NlPropertyItem visibility = createFrom(myTextView, ATTR_VISIBILITY);
NlPropertyItem text = createFrom(myTextView, ATTR_TEXT);
myPropertiesComponent.setValue(STARRED_PROP, TOOLS_NS_NAME_PREFIX + ATTR_ELEVATION + ";" + ATTR_VISIBILITY);
List<NlComponent> components = Collections.singletonList(myTextView);
Map<String, NlProperty> properties = ImmutableMap.of(ATTR_TEXT, text, ATTR_ELEVATION, elevation, ATTR_VISIBILITY, visibility);
assertThat(myProvider.isApplicable(components, properties, myPropertiesManager)).isTrue();
InspectorComponent inspector = myProvider.createCustomInspector(components, properties, myPropertiesManager);
List<NlComponentEditor> editors = inspector.getEditors();
assertThat(editors.size()).isEqualTo(2);
assertThat(inspector.getMaxNumberOfRows()).isEqualTo(3);
InspectorPanel panel = mock(InspectorPanel.class);
when(panel.addComponent(anyString(), anyString(), any())).thenAnswer(invocation -> new JLabel());
inspector.attachToInspector(panel);
verify(panel).addTitle(eq("Favorite Attributes"));
NlComponentEditor visibilityEditor = editors.get(1);
assertThat(visibilityEditor.getProperty()).isSameAs(visibility);
verify(panel).addComponent(eq(visibility.getName()), eq(visibility.getTooltipText()), eq(visibilityEditor.getComponent()));
JLabel visibilityLabel = visibilityEditor.getLabel();
assertThat(visibilityLabel).isNotNull();
assertThat(visibilityLabel.getIcon()).isNull();
NlComponentEditor elevationEditor = editors.get(0);
NlProperty elevationDesignProperty = elevationEditor.getProperty();
assertThat(elevationDesignProperty.getName()).isEqualTo(elevation.getName());
assertThat(elevationDesignProperty.getDefinition()).isSameAs(elevation.getDefinition());
assertThat(elevationDesignProperty.getNamespace()).isEqualTo(TOOLS_URI);
verify(panel).addComponent(eq(elevationDesignProperty.getName()), eq(elevationDesignProperty.getTooltipText()), eq(elevationEditor.getComponent()));
JLabel elevationLabel = elevationEditor.getLabel();
assertThat(elevationLabel).isNotNull();
assertThat(elevationLabel.getIcon()).isSameAs(AndroidIcons.NeleIcons.DesignProperty);
}
Aggregations