Search in sources :

Example 71 with NlModel

use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.

the class NlPropertyItemTest method testSetValueOnDisposedProject.

public void testSetValueOnDisposedProject() {
    NlPropertyItem text = createFrom(myTextView, ATTR_TEXT);
    // Make a fake project instance that reports true to isDisposed()
    Project fakeProject = mock(Project.class);
    when(fakeProject.isDisposed()).thenReturn(true);
    NlModel fakeModel = mock(NlModel.class);
    when(fakeModel.getProject()).thenReturn(fakeProject);
    NlComponent fakeComponent = mock(NlComponent.class);
    when(fakeComponent.getModel()).thenReturn(fakeModel);
    when(fakeComponent.getTag()).thenThrow(new RuntimeException("setValue should bail out"));
    NlPropertyItem fake = new NlPropertyItem(ImmutableList.of(fakeComponent), ANDROID_URI, text.getDefinition());
    fake.setValue("stuff");
}
Also used : Project(com.intellij.openapi.project.Project) NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) NlModel(com.android.tools.idea.uibuilder.model.NlModel)

Aggregations

NlModel (com.android.tools.idea.uibuilder.model.NlModel)71 NlComponent (com.android.tools.idea.uibuilder.model.NlComponent)33 ModelBuilder (com.android.tools.idea.uibuilder.fixtures.ModelBuilder)19 NotNull (org.jetbrains.annotations.NotNull)18 XmlFile (com.intellij.psi.xml.XmlFile)14 Project (com.intellij.openapi.project.Project)12 AttributesTransaction (com.android.tools.idea.uibuilder.model.AttributesTransaction)11 Result (com.intellij.openapi.application.Result)11 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)11 ScreenView (com.android.tools.idea.uibuilder.surface.ScreenView)6 ComponentDescriptor (com.android.tools.idea.uibuilder.fixtures.ComponentDescriptor)5 NlProperty (com.android.tools.idea.uibuilder.property.NlProperty)5 NlPropertyItem (com.android.tools.idea.uibuilder.property.NlPropertyItem)5 AttributeDefinition (org.jetbrains.android.dom.attrs.AttributeDefinition)5 Configuration (com.android.tools.idea.configurations.Configuration)4 DesignSurface (com.android.tools.idea.uibuilder.surface.DesignSurface)3 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)3 SelectionModel (com.android.tools.idea.uibuilder.model.SelectionModel)2 XmlTag (com.intellij.psi.xml.XmlTag)2 BufferedImage (java.awt.image.BufferedImage)2