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();
}
}
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();
}
}
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();
}
}
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);
}
Aggregations