use of com.android.tools.idea.uibuilder.property.NlProperty in project android by JetBrains.
the class IdAnalyzerTest method testButton1And2.
public void testButton1And2() {
ModelBuilder modelBuilder = createRelativeLayout();
NlModel model = modelBuilder.build();
NlComponent button1 = findById(model, "button1");
NlComponent button2 = findById(model, "button2");
NlProperty accessibility = new NlPropertyItem(ImmutableList.of(button1, button2), ANDROID_URI, new AttributeDefinition(ATTR_ACCESSIBILITY_TRAVERSAL_BEFORE));
IdAnalyzer analyzer = new IdAnalyzer(accessibility);
List<String> ids = analyzer.findIds();
assertEquals(ImmutableList.of("button3", "button4", "button5", "group1", "radio_button1", "radio_button2", "radio_button3", "text_view1"), ids);
}
use of com.android.tools.idea.uibuilder.property.NlProperty in project android by JetBrains.
the class IdAnalyzerTest method testRadioGroup.
public void testRadioGroup() {
ModelBuilder modelBuilder = createRelativeLayout();
NlModel model = modelBuilder.build();
NlComponent group = findById(model, "group1");
NlProperty property = new NlPropertyItem(ImmutableList.of(group), ANDROID_URI, new AttributeDefinition(ATTR_CHECKED_BUTTON));
IdAnalyzer analyzer = new IdAnalyzer(property);
List<String> ids = analyzer.findIds();
assertEquals(ImmutableList.of("radio_button1", "radio_button2", "radio_button3"), ids);
}
use of com.android.tools.idea.uibuilder.property.NlProperty in project android by JetBrains.
the class QuantityTest method mockProperty.
private static NlProperty mockProperty(@NotNull String attribute, @NotNull AttributeFormat format) {
NlProperty property = Mockito.mock(NlProperty.class);
Mockito.when(property.getName()).thenReturn(attribute);
Mockito.when(property.getDefinition()).thenReturn(new AttributeDefinition(attribute, null, Collections.singleton(format)));
return property;
}
use of com.android.tools.idea.uibuilder.property.NlProperty in project android by JetBrains.
the class NlEnumEditorFixture method createListener.
protected static NlEditingListener createListener() {
NlEditingListener listener = mock(NlEditingListener.class);
doAnswer(invocation -> {
Object[] args = invocation.getArguments();
NlComponentEditor editor = (NlComponentEditor) args[0];
Object value = args[1];
NlProperty property = editor.getProperty();
assertThat(property).isNotNull();
editor.getProperty().setValue(value);
return null;
}).when(listener).stopEditing(any(NlComponentEditor.class), any());
return listener;
}
use of com.android.tools.idea.uibuilder.property.NlProperty 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());
}
Aggregations