use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class ProgressBarInspectorProviderTest method testChangingIndeterminateChangesVisibilityOfEditors.
public void testChangingIndeterminateChangesVisibilityOfEditors() {
List<NlComponent> components = ImmutableList.of(myProgressBar);
Map<String, NlProperty> properties = getPropertyMap(components);
assertThat(myProvider.isApplicable(components, properties, myPropertiesManager)).isTrue();
InspectorComponent inspector = myProvider.createCustomInspector(components, properties, myPropertiesManager);
inspector.refresh();
assertThat(isEditorVisible(inspector, ATTR_STYLE, "")).isTrue();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS_DRAWABLE)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE_DRAWABLE)).isFalse();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS_TINT)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE_TINT)).isFalse();
assertThat(isEditorVisible(inspector, ATTR_MAXIMUM)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_VISIBILITY)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_VISIBILITY, TOOLS_URI)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE)).isTrue();
NlBaseComponentEditor indeterminateEditor = (NlBaseComponentEditor) getEditor(inspector, ATTR_INDETERMINATE, ANDROID_URI);
indeterminateEditor.stopEditing("true");
assertThat(isEditorVisible(inspector, ATTR_STYLE, "")).isTrue();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS_DRAWABLE)).isFalse();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE_DRAWABLE)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS_TINT)).isFalse();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE_TINT)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_MAXIMUM)).isFalse();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS)).isFalse();
assertThat(isEditorVisible(inspector, ATTR_VISIBILITY)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_VISIBILITY, TOOLS_URI)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE)).isTrue();
indeterminateEditor.stopEditing("false");
assertThat(isEditorVisible(inspector, ATTR_STYLE, "")).isTrue();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS_DRAWABLE)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE_DRAWABLE)).isFalse();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS_TINT)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE_TINT)).isFalse();
assertThat(isEditorVisible(inspector, ATTR_MAXIMUM)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_VISIBILITY)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_VISIBILITY, TOOLS_URI)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE)).isTrue();
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class ProgressBarInspectorProviderTest method testInspectorComponent.
public void testInspectorComponent() {
List<NlComponent> components = ImmutableList.of(myProgressBar);
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(10);
assertThat(inspector.getMaxNumberOfRows()).isEqualTo(11);
InspectorPanel panel = mock(InspectorPanel.class);
when(panel.addComponent(anyString(), anyString(), any())).thenAnswer(invocation -> new JLabel());
inspector.attachToInspector(panel);
verify(panel).addTitle(eq(PROGRESS_BAR));
for (NlComponentEditor editor : editors) {
NlProperty property = editor.getProperty();
assertThat(property).isNotNull();
verify(panel).addComponent(eq(property.getName()), eq(property.getTooltipText()), eq(editor.getComponent()));
}
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class TextInspectorProviderTest method testInspectorComponent.
public void testInspectorComponent() {
List<NlComponent> components = ImmutableList.of(myTextView);
Map<String, NlProperty> properties = getPropertyMap(components);
assertThat(myProvider.isApplicable(components, properties, myPropertiesManager)).isTrue();
TextInspectorComponent inspector = myProvider.createCustomInspector(components, properties, myPropertiesManager);
List<NlComponentEditor> editors = inspector.getEditors();
assertThat(editors.size()).isEqualTo(9);
assertThat(inspector.getMaxNumberOfRows()).isEqualTo(12);
InspectorPanel panel = mock(InspectorPanel.class);
when(panel.addComponent(anyString(), anyString(), any())).thenAnswer(invocation -> new JLabel());
inspector.attachToInspector(panel);
verify(panel).addTitle(eq(TEXT_VIEW));
for (NlComponentEditor editor : editors) {
NlProperty property = editor.getProperty();
assertThat(property).isNotNull();
if (property.getName().equals(ATTR_TEXT_APPEARANCE)) {
assertThat(editor).isInstanceOf(NlEnumEditor.class);
NlEnumEditor enumEditor = (NlEnumEditor) editor;
verify(panel).addExpandableComponent(eq(property.getName()), eq(property.getTooltipText()), eq(editor.getComponent()), eq(enumEditor.getKeySource()));
} else {
verify(panel).addComponent(eq(property.getName()), eq(property.getTooltipText()), eq(editor.getComponent()));
}
}
propertyPanelHasAllComponents(panel, ATTR_TEXT_STYLE, properties, inspector.getTextStyleEditors());
propertyPanelHasAllComponents(panel, ATTR_TEXT_ALIGNMENT, properties, inspector.getTextAlignmentEditors());
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class TextInspectorProviderTest method testIsNotApplicableForPreferenceComponents.
public void testIsNotApplicableForPreferenceComponents() {
Map<String, NlProperty> properties = getPropertyMap(ImmutableList.of(myTextView));
for (String tagName : PreferenceUtils.VALUES) {
NlComponent component = mock(NlComponent.class);
when(component.getTagName()).thenReturn(tagName);
assertThat(myProvider.isApplicable(ImmutableList.of(component), properties, myPropertiesManager)).isFalse();
}
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class TextInspectorProviderTest method testIsApplicableRequiresAllTextAttributesPresent.
public void testIsApplicableRequiresAllTextAttributesPresent() {
List<NlComponent> components = ImmutableList.of(myTextView);
Map<String, NlProperty> properties = getPropertyMap(components);
assertThat(myProvider.isApplicable(components, properties, myPropertiesManager)).isTrue();
for (String propertyName : TextInspectorProvider.TEXT_PROPERTIES) {
Map<String, NlProperty> props = new HashMap<>(properties);
props.remove(propertyName);
assertThat(myProvider.isApplicable(components, props, myPropertiesManager)).isFalse();
}
}
Aggregations