use of com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl 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();
}
}
use of com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl in project intellij by bazelbuild.
the class BlazeIntegrationTestCase method setUp.
@Before
public final void setUp() throws Exception {
IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory();
TestFixtureBuilder<IdeaProjectTestFixture> fixtureBuilder = factory.createLightFixtureBuilder(LightCodeInsightFixtureTestCase.JAVA_8);
final IdeaProjectTestFixture fixture = fixtureBuilder.getFixture();
testFixture = factory.createCodeInsightFixture(fixture, new LightTempDirTestFixtureImpl(true));
testFixture.setUp();
fileSystem = new TestFileSystem(getProject(), testFixture.getTempDirFixture());
runWriteAction(() -> {
ProjectJdkTable.getInstance().addJdk(IdeaTestUtil.getMockJdk18());
VirtualFile workspaceRootVirtualFile = fileSystem.createDirectory("workspace");
workspaceRoot = new WorkspaceRoot(new File(workspaceRootVirtualFile.getPath()));
projectDataDirectory = fileSystem.createDirectory("project-data-dir");
workspace = new WorkspaceFileSystem(workspaceRoot, fileSystem);
});
BlazeImportSettingsManager.getInstance(getProject()).setImportSettings(new BlazeImportSettings(workspaceRoot.toString(), "test-project", projectDataDirectory.getPath(), workspaceRoot.fileForPath(new WorkspacePath("project-view-file")).getPath(), buildSystem()));
registerApplicationService(FileOperationProvider.class, new TestFileSystem.MockFileOperationProvider());
registerApplicationService(InputStreamProvider.class, file -> {
VirtualFile vf = fileSystem.findFile(file.getPath());
if (vf == null) {
throw new FileNotFoundException();
}
return vf.getInputStream();
});
registerApplicationService(VirtualFileSystemProvider.class, new TestFileSystem.TempVirtualFileSystemProvider());
String requiredPlugins = System.getProperty("idea.required.plugins.id");
if (requiredPlugins != null) {
VerifyRequiredPluginsEnabled.runCheck(requiredPlugins.split(","));
}
}
use of com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl in project ideavim by JetBrains.
the class VimTestCase method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
final IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory();
final LightProjectDescriptor projectDescriptor = LightProjectDescriptor.EMPTY_PROJECT_DESCRIPTOR;
final TestFixtureBuilder<IdeaProjectTestFixture> fixtureBuilder = factory.createLightFixtureBuilder(projectDescriptor);
final IdeaProjectTestFixture fixture = fixtureBuilder.getFixture();
myFixture = IdeaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(fixture, new LightTempDirTestFixtureImpl(true));
myFixture.setUp();
myFixture.setTestDataPath(getTestDataPath());
KeyHandler.getInstance().fullReset(myFixture.getEditor());
Options.getInstance().resetAllOptions();
VimPlugin.getKey().resetKeyMappings();
}
use of com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl in project intellij-community by JetBrains.
the class VfsUtilPerformanceTest method testGetPathPerformance.
@Test
public void testGetPathPerformance() throws Exception {
LightTempDirTestFixtureImpl fixture = new LightTempDirTestFixtureImpl();
fixture.setUp();
Disposer.register(getTestRootDisposable(), () -> {
try {
fixture.tearDown();
} catch (Exception e) {
ExceptionUtil.rethrowAllAsUnchecked(e);
}
});
EdtTestUtil.runInEdtAndWait(() -> {
String path = "unitTest_testGetPathPerformance_6542623412414351229/" + "junit6921058097194294088/" + StringUtil.repeat("xxx/", 50) + "fff.txt";
VirtualFile file = fixture.findOrCreateDir(path);
PlatformTestUtil.startPerformanceTest("VF.getPath() performance failed", 4000, () -> {
for (int i = 0; i < 1000000; ++i) {
file.getPath();
}
}).cpuBound().useLegacyScaling().assertTiming();
});
}
use of com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl in project intellij-community by JetBrains.
the class SSRCodeInsightTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory();
TestFixtureBuilder<IdeaProjectTestFixture> fixtureBuilder = factory.createLightFixtureBuilder(new DefaultLightProjectDescriptor());
final IdeaProjectTestFixture fixture = fixtureBuilder.getFixture();
myFixture = IdeaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(fixture, new LightTempDirTestFixtureImpl(true));
myInspection = new SSBasedInspection();
myFixture.setUp();
myFixture.enableInspections(myInspection);
myFixture.setTestDataPath(getTestDataPath());
}
Aggregations