Search in sources :

Example 1 with IdInspectorComponent

use of com.android.tools.idea.uibuilder.property.inspector.IdInspectorProvider.IdInspectorComponent in project android by JetBrains.

the class IdInspectorProviderTest method testInspectorComponent.

public void testInspectorComponent() {
    List<NlComponent> components = ImmutableList.of(myTextView);
    Map<String, NlProperty> properties = getPropertyMap(components);
    assertThat(myProvider.isApplicable(components, properties, myPropertiesManager)).isTrue();
    IdInspectorComponent inspector = myProvider.createCustomInspector(components, properties, myPropertiesManager);
    List<NlComponentEditor> editors = inspector.getEditors();
    assertThat(editors.size()).isEqualTo(3);
    assertThat(inspector.getMaxNumberOfRows()).isEqualTo(4);
    InspectorPanel panel = mock(InspectorPanel.class);
    when(panel.addComponent(anyString(), anyString(), any())).thenAnswer(invocation -> new JLabel());
    inspector.attachToInspector(panel);
    for (NlComponentEditor editor : editors) {
        NlProperty property = editor.getProperty();
        assertThat(property).isNotNull();
        String propertyName = property.getName();
        if (propertyName.equals(ATTR_ID)) {
            propertyName = "ID";
        }
        verify(panel).addComponent(eq(propertyName), eq(null), eq(editor.getComponent()));
    }
    verify(panel, never()).addPanel(inspector.getConstraintPanel());
}
Also used : NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) NlProperty(com.android.tools.idea.uibuilder.property.NlProperty) Matchers.anyString(org.mockito.Matchers.anyString) IdInspectorComponent(com.android.tools.idea.uibuilder.property.inspector.IdInspectorProvider.IdInspectorComponent) NlComponentEditor(com.android.tools.idea.uibuilder.property.editors.NlComponentEditor)

Example 2 with IdInspectorComponent

use of com.android.tools.idea.uibuilder.property.inspector.IdInspectorProvider.IdInspectorComponent in project android by JetBrains.

the class IdInspectorProviderTest method testUpdateProperties.

public void testUpdateProperties() {
    List<NlComponent> components = ImmutableList.of(myTextView);
    Map<String, NlProperty> properties = getPropertyMap(components);
    assertThat(myProvider.isApplicable(components, properties, myPropertiesManager)).isTrue();
    IdInspectorComponent inspector = myProvider.createCustomInspector(components, properties, myPropertiesManager);
    inspector.updateProperties(ImmutableList.of(), properties, myPropertiesManager);
    components = ImmutableList.of(myButtonInConstraintLayout);
    properties = getPropertyMap(components);
    inspector.updateProperties(components, properties, myPropertiesManager);
}
Also used : NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) NlProperty(com.android.tools.idea.uibuilder.property.NlProperty) Matchers.anyString(org.mockito.Matchers.anyString) IdInspectorComponent(com.android.tools.idea.uibuilder.property.inspector.IdInspectorProvider.IdInspectorComponent)

Aggregations

NlComponent (com.android.tools.idea.uibuilder.model.NlComponent)2 NlProperty (com.android.tools.idea.uibuilder.property.NlProperty)2 IdInspectorComponent (com.android.tools.idea.uibuilder.property.inspector.IdInspectorProvider.IdInspectorComponent)2 Matchers.anyString (org.mockito.Matchers.anyString)2 NlComponentEditor (com.android.tools.idea.uibuilder.property.editors.NlComponentEditor)1