use of com.android.tools.idea.uibuilder.handlers.SwitchHandler in project android by JetBrains.
the class ViewInspectorProviderTest method testInspectorComponent.
public void testInspectorComponent() {
List<NlComponent> components = ImmutableList.of(mySwitch);
Map<String, NlProperty> properties = getPropertyMap(components);
assertThat(myProvider.isApplicable(components, properties, myPropertiesManager)).isTrue();
InspectorComponent inspector = myProvider.createCustomInspector(components, properties, myPropertiesManager);
List<NlComponentEditor> editors = inspector.getEditors();
assertThat(editors.size()).isEqualTo(14);
assertThat(inspector.getMaxNumberOfRows()).isEqualTo(editors.size() + 1);
Set<String> inspectorProperties = new HashSet<>(new SwitchHandler().getInspectorProperties());
InspectorPanel panel = mock(InspectorPanel.class);
when(panel.addComponent(anyString(), anyString(), any())).thenAnswer(invocation -> new JLabel());
inspector.attachToInspector(panel);
verify(panel).addTitle(SWITCH);
for (NlComponentEditor editor : editors) {
NlProperty property = editor.getProperty();
assertThat(property).isNotNull();
verify(panel).addComponent(eq(property.getName()), eq(property.getTooltipText()), eq(editor.getComponent()));
assertThat(editor.getLabel()).isNotNull();
if (TOOLS_URI.equals(property.getNamespace())) {
assertThat(editor.getLabel().getIcon()).isEqualTo(AndroidIcons.NeleIcons.DesignProperty);
if (!inspectorProperties.remove(TOOLS_NS_NAME_PREFIX + property.getName())) {
assertThat(inspectorProperties.remove(TOOLS_NS_NAME_PREFIX + property.getName())).named(property.getName()).isTrue();
}
} else {
assertThat(editor.getLabel().getIcon()).isNull();
assertThat(inspectorProperties.remove(property.getName())).named(property.getName()).isTrue();
}
}
assertThat(inspectorProperties).isEmpty();
}
Aggregations