Search in sources :

Example 1 with MockPsiFile

use of com.intellij.mock.MockPsiFile in project intellij-community by JetBrains.

the class PsiDocumentManagerImplTest method testGetDocument_FirstGet.

public void testGetDocument_FirstGet() throws Exception {
    VirtualFile vFile = createFile();
    final PsiFile file = new MockPsiFile(vFile, getPsiManager());
    final Document document = getDocument(file);
    assertNotNull(document);
    assertSame(document, FileDocumentManager.getInstance().getDocument(vFile));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) MockPsiFile(com.intellij.mock.MockPsiFile) MockPsiFile(com.intellij.mock.MockPsiFile) Document(com.intellij.openapi.editor.Document) MockDocument(com.intellij.mock.MockDocument)

Example 2 with MockPsiFile

use of com.intellij.mock.MockPsiFile in project intellij by bazelbuild.

the class BlazeRenderErrorContributorTest method testNoIssuesIfNoErrors.

@Test
public void testNoIssuesIfNoErrors() {
    PsiFile file = new MockPsiFile(new MockPsiManager(project));
    file.putUserData(ModuleUtilCore.KEY_MODULE, module);
    RenderResult result = RenderResult.createBlank(file);
    RenderErrorModel errorModel = RenderErrorModelFactory.createErrorModel(result, null);
    assertThat(errorModel.getIssues()).isEmpty();
}
Also used : MockPsiFile(com.intellij.mock.MockPsiFile) RenderResult(com.android.tools.idea.rendering.RenderResult) MockPsiFile(com.intellij.mock.MockPsiFile) PsiFile(com.intellij.psi.PsiFile) MockPsiManager(com.intellij.mock.MockPsiManager) RenderErrorModel(com.android.tools.idea.rendering.errors.ui.RenderErrorModel) Test(org.junit.Test)

Example 3 with MockPsiFile

use of com.intellij.mock.MockPsiFile in project intellij by bazelbuild.

the class BlazeRenderErrorContributorTest method createRenderErrorModelWithBrokenClasses.

private RenderErrorModel createRenderErrorModelWithBrokenClasses() {
    PsiFile file = new MockPsiFile(new MockPsiManager(project));
    file.putUserData(ModuleUtilCore.KEY_MODULE, module);
    RenderResult result = RenderResult.createBlank(file);
    result.getLogger().addBrokenClass("com.google.example.CustomView", new Exception("resource not found"));
    return RenderErrorModelFactory.createErrorModel(result, null);
}
Also used : MockPsiFile(com.intellij.mock.MockPsiFile) RenderResult(com.android.tools.idea.rendering.RenderResult) MockPsiFile(com.intellij.mock.MockPsiFile) PsiFile(com.intellij.psi.PsiFile) MockPsiManager(com.intellij.mock.MockPsiManager)

Example 4 with MockPsiFile

use of com.intellij.mock.MockPsiFile in project intellij by bazelbuild.

the class BlazeRenderErrorContributorTest method createRenderErrorModelWithMissingClasses.

private RenderErrorModel createRenderErrorModelWithMissingClasses(String... classNames) {
    PsiFile file = new MockPsiFile(new MockPsiManager(project));
    file.putUserData(ModuleUtilCore.KEY_MODULE, module);
    RenderResult result = RenderResult.createBlank(file);
    for (String className : classNames) {
        result.getLogger().addMissingClass(className);
    }
    return RenderErrorModelFactory.createErrorModel(result, null);
}
Also used : MockPsiFile(com.intellij.mock.MockPsiFile) RenderResult(com.android.tools.idea.rendering.RenderResult) MockPsiFile(com.intellij.mock.MockPsiFile) PsiFile(com.intellij.psi.PsiFile) MockPsiManager(com.intellij.mock.MockPsiManager)

Example 5 with MockPsiFile

use of com.intellij.mock.MockPsiFile in project android by JetBrains.

the class GradleRenderErrorContributorTest method createResultWithBrokenClass.

private RenderResult createResultWithBrokenClass() {
    PsiFile file = new MockPsiFile(new MockPsiManager(myProject));
    file.putUserData(ModuleUtilCore.KEY_MODULE, myModule);
    RenderResult result = RenderResult.createBlank(file);
    result.getLogger().addBrokenClass("com.google.Class", new Exception());
    return result;
}
Also used : MockPsiFile(com.intellij.mock.MockPsiFile) RenderResult(com.android.tools.idea.rendering.RenderResult) MockPsiFile(com.intellij.mock.MockPsiFile) PsiFile(com.intellij.psi.PsiFile) MockPsiManager(com.intellij.mock.MockPsiManager)

Aggregations

MockPsiFile (com.intellij.mock.MockPsiFile)5 RenderResult (com.android.tools.idea.rendering.RenderResult)4 MockPsiManager (com.intellij.mock.MockPsiManager)4 PsiFile (com.intellij.psi.PsiFile)4 RenderErrorModel (com.android.tools.idea.rendering.errors.ui.RenderErrorModel)1 MockDocument (com.intellij.mock.MockDocument)1 Document (com.intellij.openapi.editor.Document)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)1 Test (org.junit.Test)1