use of com.intellij.testFramework.fixtures.TempDirTestFixture in project intellij-community by JetBrains.
the class HgTestRepository method cloneRepository.
/**
* Clones a repository from this one. New repository is located in a new temporary test directory.
* @return New repository cloned from this one.
*/
public HgTestRepository cloneRepository() throws Exception {
final TempDirTestFixture dirFixture = createFixtureDir();
final ProcessOutput processOutput = myTest.runHg(null, "clone", getDirFixture().getTempDirPath(), dirFixture.getTempDirPath());
AbstractVcsTestCase.verify(processOutput);
return new HgTestRepository(myTest, dirFixture);
}
use of com.intellij.testFramework.fixtures.TempDirTestFixture in project intellij-community by JetBrains.
the class HgTestRepository method createFixtureDir.
private static TempDirTestFixture createFixtureDir() throws Exception {
final TempDirTestFixture fixture = IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture();
fixture.setUp();
return fixture;
}
use of com.intellij.testFramework.fixtures.TempDirTestFixture in project intellij-community by JetBrains.
the class FindUsagesTest method testNonCodeClassUsages.
public void testNonCodeClassUsages() throws Exception {
final TempDirTestFixture tdf = IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture();
tdf.setUp();
try {
new WriteCommandAction(getProject()) {
@Override
protected void run(@NotNull Result result) throws Throwable {
final ModifiableModuleModel moduleModel = ModuleManager.getInstance(getProject()).getModifiableModel();
moduleModel.newModule("independent/independent.iml", StdModuleTypes.JAVA.getId());
moduleModel.commit();
tdf.createFile("plugin.xml", "<document>\n" + " <action class=\"com.Foo\" />\n" + " <action class=\"com.Foo.Bar\" />\n" + " <action class=\"com.Foo$Bar\" />\n" + "</document>");
PsiTestUtil.addContentRoot(ModuleManager.getInstance(getProject()).findModuleByName("independent"), tdf.getFile(""));
}
}.execute();
GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());
PsiClass foo = myJavaFacade.findClass("com.Foo", scope);
PsiClass bar = myJavaFacade.findClass("com.Foo.Bar", scope);
final int[] count = { 0 };
Processor<UsageInfo> processor = usageInfo -> {
int navigationOffset = usageInfo.getNavigationOffset();
assertTrue(navigationOffset > 0);
String textAfter = usageInfo.getFile().getText().substring(navigationOffset);
assertTrue(textAfter, textAfter.startsWith("Foo") || textAfter.startsWith("Bar") || textAfter.startsWith("com.Foo.Bar"));
count[0]++;
return true;
};
JavaFindUsagesHandler handler = new JavaFindUsagesHandler(bar, JavaFindUsagesHandlerFactory.getInstance(getProject()));
count[0] = 0;
handler.processUsagesInText(foo, processor, scope);
assertEquals(3, count[0]);
count[0] = 0;
handler.processUsagesInText(bar, processor, scope);
assertEquals(2, count[0]);
} finally {
tdf.tearDown();
}
}
use of com.intellij.testFramework.fixtures.TempDirTestFixture in project intellij-community by JetBrains.
the class FindManagerTest method testFindInCurrentFileOutsideProject.
public void testFindInCurrentFileOutsideProject() throws Exception {
final TempDirTestFixture tempDirFixture = new TempDirTestFixtureImpl();
tempDirFixture.setUp();
try {
VirtualFile file = tempDirFixture.createFile("a.txt", "foo bar foo");
FindModel findModel = FindManagerTestUtils.configureFindModel("foo");
findModel.setWholeWordsOnly(true);
findModel.setCustomScope(true);
findModel.setCustomScope(new LocalSearchScope(PsiManager.getInstance(myProject).findFile(file)));
assertSize(2, findUsages(findModel));
} finally {
tempDirFixture.tearDown();
}
}
use of com.intellij.testFramework.fixtures.TempDirTestFixture in project intellij-community by JetBrains.
the class FindManagerTest method testLocalScopeSearchPerformance.
public void testLocalScopeSearchPerformance() throws Exception {
final int fileCount = 3000;
final int lineCount = 500;
TempDirTestFixture fixture = new LightTempDirTestFixtureImpl();
fixture.setUp();
try {
String sampleText = StringUtil.repeat("zoo TargetWord foo bar goo\n", lineCount);
for (int i = 0; i < fileCount; i++) {
fixture.createFile("a" + i + ".txt", sampleText);
}
PsiTestUtil.addSourceContentToRoots(myModule, fixture.getFile(""));
VirtualFile file = fixture.createFile("target.txt", sampleText);
PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
assertNotNull(psiFile);
final FindModel findModel = new FindModel();
findModel.setStringToFind("TargetWord");
findModel.setWholeWordsOnly(true);
findModel.setFromCursor(false);
findModel.setGlobal(true);
findModel.setMultipleFiles(true);
findModel.setCustomScope(true);
ThrowableRunnable test = () -> assertSize(lineCount, findUsages(findModel));
findModel.setCustomScope(GlobalSearchScope.fileScope(psiFile));
PlatformTestUtil.startPerformanceTest("slow", 400, test).attempts(2).cpuBound().usesAllCPUCores().useLegacyScaling().assertTiming();
findModel.setCustomScope(new LocalSearchScope(psiFile));
PlatformTestUtil.startPerformanceTest("slow", 400, test).attempts(2).cpuBound().usesAllCPUCores().useLegacyScaling().assertTiming();
} finally {
fixture.tearDown();
}
}
Aggregations