use of com.android.tools.idea.uibuilder.model.NlComponent 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);
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class SceneBasicConnectionsTest method testConnectTop.
public void testConnectTop() {
myInteraction.select("button", true);
NlComponent button = myScene.getSceneComponent("button").getNlComponent();
assertEquals(1, myScreen.getScreen().getSelectionModel().getSelection().size());
assertEquals(button, myScreen.getScreen().getSelectionModel().getPrimary());
myInteraction.mouseDown("button", AnchorTarget.Type.TOP);
myInteraction.mouseRelease("root", AnchorTarget.Type.TOP);
myScreen.get("@id/button").expectXml("<TextView\n" + " android:id=\"@id/button\"\n" + " android:layout_width=\"100dp\"\n" + " android:layout_height=\"20dp\"\n" + " tools:layout_editor_absoluteX=\"100dp\"\n" + " app:layout_constraintTop_toTopOf=\"parent\"\n" + " android:layout_marginTop=\"8dp\" />");
assertEquals(button, myScreen.getScreen().getSelectionModel().getPrimary());
assertEquals(1, myScreen.getScreen().getSelectionModel().getSelection().size());
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class SceneCreationTest method testBasicScene.
public void testBasicScene() {
myScreen.get("@id/button").expectXml("<TextView\n" + " android:id=\"@id/button\"\n" + " android:layout_width=\"100dp\"\n" + " android:layout_height=\"20dp\"\n" + " tools:layout_editor_absoluteX=\"100dp\"\n" + " tools:layout_editor_absoluteY=\"200dp\"/>");
assertTrue(myInteraction.getDisplayList().getCommands().size() > 0);
SceneComponent component = myScene.getSceneComponent("button");
assertEquals(component.getScene(), myScene);
NlComponent nlComponent = component.getNlComponent();
assertEquals(component, myScene.getSceneComponent(nlComponent));
assertEquals(myScene.pxToDp(myScene.dpToPx(100)), 100);
myScene.setDpiFactorOverride(3.5f);
assertEquals(myScene.pxToDp(myScene.dpToPx(100)), 100);
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class SceneDeleteWidgetBaselineTest method testDelete.
public void testDelete() {
SceneComponent layout = myScene.getSceneComponent("root");
NlComponent layoutComponent = layout.getNlComponent();
ViewGroupHandler handler = (ViewGroupHandler) layoutComponent.getViewHandler();
ArrayList<NlComponent> deleted = new ArrayList<>();
deleted.add(myScene.getSceneComponent("button2").getNlComponent());
handler.deleteChildren(layoutComponent, deleted);
myScreen.get("@id/button").expectXml("<TextView\n" + " android:id=\"@id/button\"\n" + " android:layout_width=\"100dp\"\n" + " android:layout_height=\"50dp\"\n" + " app:layout_constraintLeft_toLeftOf=\"parent\"\n" + " android:layout_marginLeft=\"8dp\"\n" + " tools:layout_editor_absoluteY=\"83dp\" />");
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class NlLintHighlightingPass method getAnnotations.
@NotNull
private static LintAnnotationsModel getAnnotations(@NotNull NlModel model, @NotNull ProgressIndicator progress) {
ApplicationManager.getApplication().assertReadAccessAllowed();
LintAnnotationsModel lintModel = new LintAnnotationsModel();
XmlFile xmlFile = model.getFile();
AndroidLintExternalAnnotator annotator = new AndroidLintExternalAnnotator();
State state = annotator.collectInformation(xmlFile);
if (state != null) {
state = annotator.doAnnotate(state);
}
if (state == null) {
return lintModel;
}
for (ProblemData problemData : state.getProblems()) {
if (progress.isCanceled()) {
break;
}
TextRange range = problemData.getTextRange();
final PsiElement startElement = xmlFile.findElementAt(range.getStartOffset());
final PsiElement endElement = xmlFile.findElementAt(range.getEndOffset());
if (startElement == null || endElement == null) {
continue;
}
NlComponent component = model.findViewByPsi(startElement);
if (component == null) {
continue;
}
Issue issue = problemData.getIssue();
Pair<AndroidLintInspectionBase, HighlightDisplayLevel> pair = AndroidLintUtil.getHighlighLevelAndInspection(xmlFile.getProject(), issue, xmlFile);
if (pair == null) {
continue;
}
AndroidLintInspectionBase inspection = pair.getFirst();
if (inspection == null) {
continue;
}
HighlightDisplayLevel level = pair.getSecond();
HighlightDisplayKey key = HighlightDisplayKey.find(inspection.getShortName());
if (key == null) {
continue;
}
lintModel.addIssue(component, issue, problemData.getMessage(), inspection, level, startElement, endElement);
}
return lintModel;
}
Aggregations