Search in sources :

Example 1 with LightTempDirTestFixtureImpl

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();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) LocalSearchScope(com.intellij.psi.search.LocalSearchScope) TempDirTestFixture(com.intellij.testFramework.fixtures.TempDirTestFixture) ThrowableRunnable(com.intellij.util.ThrowableRunnable) LightTempDirTestFixtureImpl(com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl)

Example 2 with LightTempDirTestFixtureImpl

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(","));
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) IdeaTestFixtureFactory(com.intellij.testFramework.fixtures.IdeaTestFixtureFactory) FileNotFoundException(java.io.FileNotFoundException) LightTempDirTestFixtureImpl(com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) IdeaProjectTestFixture(com.intellij.testFramework.fixtures.IdeaProjectTestFixture) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Before(org.junit.Before)

Example 3 with LightTempDirTestFixtureImpl

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();
}
Also used : IdeaProjectTestFixture(com.intellij.testFramework.fixtures.IdeaProjectTestFixture) IdeaTestFixtureFactory(com.intellij.testFramework.fixtures.IdeaTestFixtureFactory) LightTempDirTestFixtureImpl(com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl) LightProjectDescriptor(com.intellij.testFramework.LightProjectDescriptor)

Example 4 with LightTempDirTestFixtureImpl

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();
    });
}
Also used : NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) LightTempDirTestFixtureImpl(com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl) IOException(java.io.IOException) Test(org.junit.Test)

Example 5 with LightTempDirTestFixtureImpl

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());
}
Also used : SSBasedInspection(com.intellij.structuralsearch.inspection.highlightTemplate.SSBasedInspection) LightTempDirTestFixtureImpl(com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl)

Aggregations

LightTempDirTestFixtureImpl (com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl)7 IdeaProjectTestFixture (com.intellij.testFramework.fixtures.IdeaProjectTestFixture)3 IdeaTestFixtureFactory (com.intellij.testFramework.fixtures.IdeaTestFixtureFactory)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)1 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)1 BlazeImportSettings (com.google.idea.blaze.base.settings.BlazeImportSettings)1 NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)1 LocalSearchScope (com.intellij.psi.search.LocalSearchScope)1 SSBasedInspection (com.intellij.structuralsearch.inspection.highlightTemplate.SSBasedInspection)1 LightProjectDescriptor (com.intellij.testFramework.LightProjectDescriptor)1 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)1 TempDirTestFixture (com.intellij.testFramework.fixtures.TempDirTestFixture)1 ThrowableRunnable (com.intellij.util.ThrowableRunnable)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Before (org.junit.Before)1 Test (org.junit.Test)1