Search in sources :

Example 6 with TempDirTestFixture

use of com.intellij.testFramework.fixtures.TempDirTestFixture in project intellij-community by JetBrains.

the class FindManagerTest method testFindInDirectoryOutsideProject.

public void testFindInDirectoryOutsideProject() throws Exception {
    final TempDirTestFixture tempDirFixture = new TempDirTestFixtureImpl();
    tempDirFixture.setUp();
    try {
        tempDirFixture.createFile("a.txt", "foo bar foo");
        FindModel findModel = FindManagerTestUtils.configureFindModel("foo");
        findModel.setWholeWordsOnly(true);
        findModel.setProjectScope(false);
        findModel.setDirectoryName(tempDirFixture.getFile("").getPath());
        assertSize(2, findUsages(findModel));
    } finally {
        tempDirFixture.tearDown();
    }
}
Also used : TempDirTestFixture(com.intellij.testFramework.fixtures.TempDirTestFixture) LightTempDirTestFixtureImpl(com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl) TempDirTestFixtureImpl(com.intellij.testFramework.fixtures.impl.TempDirTestFixtureImpl)

Example 7 with TempDirTestFixture

use of com.intellij.testFramework.fixtures.TempDirTestFixture in project intellij-community by JetBrains.

the class ProximityTest method testSameSourceRoot.

public void testSameSourceRoot() throws Throwable {
    final TempDirTestFixture root1 = IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture();
    final TempDirTestFixture root2 = IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture();
    root1.setUp();
    root2.setUp();
    try {
        new WriteCommandAction(getProject()) {

            @Override
            protected void run(@NotNull Result result) throws Throwable {
                PsiTestUtil.addSourceContentToRoots(myModule, root1.getFile(""));
                PsiTestUtil.addSourceContentToRoots(myModule, root2.getFile(""));
            }
        }.execute();
        final VirtualFile file1 = root1.createFile("buy.txt", "");
        final VirtualFile file2 = root2.createFile("buy.txt", "");
        final VirtualFile ctx = root2.createFile("ctx.txt", "");
        final PsiProximityComparator comparator = new PsiProximityComparator(getPsiManager().findFile(ctx));
        assertTrue(comparator.compare(getPsiManager().findFile(file1), getPsiManager().findFile(file2)) > 0);
        assertTrue(comparator.compare(getPsiManager().findFile(file2), getPsiManager().findFile(file1)) < 0);
    } finally {
        root1.tearDown();
        root2.tearDown();
    }
}
Also used : WriteCommandAction(com.intellij.openapi.command.WriteCommandAction) VirtualFile(com.intellij.openapi.vfs.VirtualFile) TempDirTestFixture(com.intellij.testFramework.fixtures.TempDirTestFixture) Result(com.intellij.openapi.application.Result)

Example 8 with TempDirTestFixture

use of com.intellij.testFramework.fixtures.TempDirTestFixture in project intellij-community by JetBrains.

the class GroovyGotoImplementationTest method testNoGotoImplementationOutsideSourceRoot.

public void testNoGotoImplementationOutsideSourceRoot() throws Throwable {
    final TempDirTestFixture dirFixture = new TempDirTestFixtureImpl();
    dirFixture.setUp();
    new WriteCommandAction(getProject()) {

        @Override
        protected void run(@NotNull Result result) throws Throwable {
            final VirtualFile outside = dirFixture.getFile("").createChildDirectory(this, "outside");
            PsiTestUtil.addContentRoot(myModule, outside);
            VirtualFile out = outside.createChildData(this, "Outside.groovy");
            VfsUtil.saveText(out, "class Bar {}\n class Goo extends Bar {}");
            PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
        }
    }.execute();
    try {
        PsiFile inProject = myFixture.addFileToProject("Foo.groovy", "class <caret>Foo {}\n class Bar extends Foo {}");
        myFixture.configureFromExistingVirtualFile(inProject.getVirtualFile());
        final PsiElement[] impls = CodeInsightTestUtil.gotoImplementation(myFixture.getEditor(), inProject).targets;
        assertEquals(1, impls.length);
    } finally {
        dirFixture.tearDown();
    }
}
Also used : WriteCommandAction(com.intellij.openapi.command.WriteCommandAction) VirtualFile(com.intellij.openapi.vfs.VirtualFile) TempDirTestFixture(com.intellij.testFramework.fixtures.TempDirTestFixture) PsiFile(com.intellij.psi.PsiFile) TempDirTestFixtureImpl(com.intellij.testFramework.fixtures.impl.TempDirTestFixtureImpl) PsiElement(com.intellij.psi.PsiElement) Result(com.intellij.openapi.application.Result)

Example 9 with TempDirTestFixture

use of com.intellij.testFramework.fixtures.TempDirTestFixture in project intellij-community by JetBrains.

the class HgTestRepository method create.

/**
   * Creates a new Mercurial repository in a new temporary test directory.
   * @param test reference to the test case instance.
   * @return created repository.
   */
public static HgTestRepository create(HgTest test) throws Exception {
    final TempDirTestFixture dirFixture = createFixtureDir();
    final File repo = new File(dirFixture.getTempDirPath());
    final ProcessOutput processOutput = test.runHg(repo, "init");
    AbstractVcsTestCase.verify(processOutput);
    return new HgTestRepository(test, dirFixture);
}
Also used : TempDirTestFixture(com.intellij.testFramework.fixtures.TempDirTestFixture) ProcessOutput(com.intellij.execution.process.ProcessOutput) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Aggregations

TempDirTestFixture (com.intellij.testFramework.fixtures.TempDirTestFixture)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 Result (com.intellij.openapi.application.Result)3 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)3 LightTempDirTestFixtureImpl (com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl)3 TempDirTestFixtureImpl (com.intellij.testFramework.fixtures.impl.TempDirTestFixtureImpl)3 ProcessOutput (com.intellij.execution.process.ProcessOutput)2 LocalSearchScope (com.intellij.psi.search.LocalSearchScope)2 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)2 JavaTestUtil (com.intellij.JavaTestUtil)1 JavaFindUsagesHandler (com.intellij.find.findUsages.JavaFindUsagesHandler)1 JavaFindUsagesHandlerFactory (com.intellij.find.findUsages.JavaFindUsagesHandlerFactory)1 StdFileTypes (com.intellij.openapi.fileTypes.StdFileTypes)1 ModifiableModuleModel (com.intellij.openapi.module.ModifiableModuleModel)1 ModuleManager (com.intellij.openapi.module.ModuleManager)1 StdModuleTypes (com.intellij.openapi.module.StdModuleTypes)1 TextRange (com.intellij.openapi.util.TextRange)1 com.intellij.psi (com.intellij.psi)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1