Search in sources :

Example 6 with IdeaProjectTestFixture

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

the class TestBase method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    final IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory();
    final IdeaProjectTestFixture fixture = factory.createLightFixtureBuilder().getFixture();
    myFixture = factory.createCodeInsightFixture(fixture);
    myFixture.setTestDataPath(getTestDataPath());
    myFixture.setUp();
}
Also used : IdeaProjectTestFixture(com.intellij.testFramework.fixtures.IdeaProjectTestFixture) IdeaTestFixtureFactory(com.intellij.testFramework.fixtures.IdeaTestFixtureFactory)

Example 7 with IdeaProjectTestFixture

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

the class CreateClassFixTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    final Ref<Exception> ex = new Ref<>();
    Runnable runnable = new Runnable() {

        public void run() {
            try {
                CreateClassFixTest.super.setUp();
                final JavaTestFixtureFactory fixtureFactory = JavaTestFixtureFactory.getFixtureFactory();
                final TestFixtureBuilder<IdeaProjectTestFixture> testFixtureBuilder = JavaTestFixtureFactory.createFixtureBuilder(getClass().getSimpleName());
                myFixture = fixtureFactory.createCodeInsightFixture(testFixtureBuilder.getFixture());
                myFixture.setTestDataPath(PluginPathManager.getPluginHomePath("devkit") + "/testData");
                testFixtureBuilder.addModule(JavaModuleFixtureBuilder.class).addContentRoot(myFixture.getTempDirPath()).addSourceRoot(getSourceRoot());
                myFixture.setUp();
                myFixture.enableInspections(new RegistrationProblemsInspection());
            } catch (Exception e) {
                ex.set(e);
            }
        }
    };
    invokeTestRunnable(runnable);
    final Exception exception = ex.get();
    if (exception != null) {
        throw exception;
    }
}
Also used : Ref(com.intellij.openapi.util.Ref) IdeaProjectTestFixture(com.intellij.testFramework.fixtures.IdeaProjectTestFixture) RegistrationProblemsInspection(org.jetbrains.idea.devkit.inspections.RegistrationProblemsInspection) JavaTestFixtureFactory(com.intellij.testFramework.fixtures.JavaTestFixtureFactory) Before(org.junit.Before)

Example 8 with IdeaProjectTestFixture

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

the class RestFixtureTestCase method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory();
    TestFixtureBuilder<IdeaProjectTestFixture> fixtureBuilder = factory.createLightFixtureBuilder(getProjectDescriptor());
    final IdeaProjectTestFixture fixture = fixtureBuilder.getFixture();
    myFixture = IdeaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(fixture, new LightTempDirTestFixtureImpl(true));
    myFixture.setUp();
    myFixture.setTestDataPath(getTestDataPath());
}
Also used : IdeaProjectTestFixture(com.intellij.testFramework.fixtures.IdeaProjectTestFixture) IdeaTestFixtureFactory(com.intellij.testFramework.fixtures.IdeaTestFixtureFactory) LightTempDirTestFixtureImpl(com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl)

Example 9 with IdeaProjectTestFixture

use of com.intellij.testFramework.fixtures.IdeaProjectTestFixture in project kotlin by JetBrains.

the class KotlinAndroidTestCase method setUp.

@Override
protected void setUp() throws Exception {
    // sdk path workaround, set real android sdk path and platform for android plugin to work
    System.setProperty(KotlinAndroidTestCaseBase.SDK_PATH_PROPERTY, PathManager.getHomePath() + "/../dependencies/androidSDK");
    System.setProperty(KotlinAndroidTestCaseBase.PLATFORM_DIR_PROPERTY, "android-23");
    VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory());
    super.setUp();
    // this will throw an exception if we don't have a full Android SDK, so we need to do this first thing before any other setup
    String sdkPath = getTestSdkPath();
    final TestFixtureBuilder<IdeaProjectTestFixture> projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName());
    myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(projectBuilder.getFixture());
    final JavaModuleFixtureBuilder moduleFixtureBuilder = projectBuilder.addModule(JavaModuleFixtureBuilder.class);
    final String dirPath = myFixture.getTempDirPath() + getContentRootPath();
    final File dir = new File(dirPath);
    if (!dir.exists()) {
        assertTrue(dir.mkdirs());
    }
    tuneModule(moduleFixtureBuilder, dirPath);
    final List<MyAdditionalModuleData> modules = new ArrayList<MyAdditionalModuleData>();
    configureAdditionalModules(projectBuilder, modules);
    myFixture.setUp();
    myFixture.setTestDataPath(getTestDataPath());
    myModule = moduleFixtureBuilder.getFixture().getModule();
    // Must be done before addAndroidFacet, and must always be done, even if !myCreateManifest.
    // We will delete it at the end of setUp; this is needed when unit tests want to rewrite
    // the manifest on their own.
    createManifest();
    androidSdk = createAndroidSdk(getTestSdkPath(), getPlatformDir());
    myFacet = addAndroidFacet(myModule, sdkPath, getPlatformDir(), isToAddSdk());
    for (File resDir : getResourceDirs(dirPath)) {
        if (resDir.exists()) {
            myFixture.copyDirectoryToProject(resDir.getName(), resDir.getName());
        } else {
            Logger.getInstance(this.getClass()).info("No res directory found in test");
        }
    }
    myAdditionalModules = new ArrayList<Module>();
    for (MyAdditionalModuleData data : modules) {
        final Module additionalModule = data.myModuleFixtureBuilder.getFixture().getModule();
        myAdditionalModules.add(additionalModule);
        final AndroidFacet facet = addAndroidFacet(additionalModule, sdkPath, getPlatformDir());
        facet.setLibraryProject(data.myLibrary);
        final String rootPath = getContentRootPath(data.myDirName);
        myFixture.copyDirectoryToProject("res", rootPath + "/res");
        myFixture.copyFileToProject(SdkConstants.FN_ANDROID_MANIFEST_XML, rootPath + '/' + SdkConstants.FN_ANDROID_MANIFEST_XML);
        ModuleRootModificationUtil.addDependency(myModule, additionalModule);
    }
    if (!myCreateManifest) {
        deleteManifest();
    }
    if (RenderSecurityManager.RESTRICT_READS) {
        // Unit test class loader includes disk directories which security manager does not allow access to
        RenderSecurityManager.sEnabled = false;
    }
    ((StartupManagerImpl) StartupManager.getInstance(getProject())).runPostStartupActivities();
    kotlinInternalModeOriginalValue = KotlinInternalMode.Instance.getEnabled();
    KotlinInternalMode.Instance.setEnabled(true);
}
Also used : IdeaProjectTestFixture(com.intellij.testFramework.fixtures.IdeaProjectTestFixture) StartupManagerImpl(com.intellij.ide.startup.impl.StartupManagerImpl) JavaModuleFixtureBuilder(com.intellij.testFramework.builders.JavaModuleFixtureBuilder) ArrayList(java.util.ArrayList) Module(com.intellij.openapi.module.Module) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 10 with IdeaProjectTestFixture

use of com.intellij.testFramework.fixtures.IdeaProjectTestFixture in project android by JetBrains.

the class AndroidGradleTestCase method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    GradleProjectImporter.ourSkipSetupFromTest = true;
    if (createDefaultProject()) {
        TestFixtureBuilder<IdeaProjectTestFixture> projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName());
        myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(projectBuilder.getFixture());
        myFixture.setUp();
        myFixture.setTestDataPath(getTestDataPath());
        ensureSdkManagerAvailable();
        setUpSdks();
        Project project = getProject();
        myModules = new Modules(project);
    } else {
        // This is necessary when we don't create a default project,
        // to ensure that the LocalFileSystemHolder is initialized.
        IdeaTestApplication.getInstance();
        ensureSdkManagerAvailable();
    }
}
Also used : Projects.isLegacyIdeaAndroidProject(com.android.tools.idea.gradle.util.Projects.isLegacyIdeaAndroidProject) Project(com.intellij.openapi.project.Project) IdeaProjectTestFixture(com.intellij.testFramework.fixtures.IdeaProjectTestFixture)

Aggregations

IdeaProjectTestFixture (com.intellij.testFramework.fixtures.IdeaProjectTestFixture)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 IdeaTestFixtureFactory (com.intellij.testFramework.fixtures.IdeaTestFixtureFactory)3 File (java.io.File)3 Module (com.intellij.openapi.module.Module)2 JavaModuleFixtureBuilder (com.intellij.testFramework.builders.JavaModuleFixtureBuilder)2 JavaTestFixtureFactory (com.intellij.testFramework.fixtures.JavaTestFixtureFactory)2 LightTempDirTestFixtureImpl (com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl)2 ArrayList (java.util.ArrayList)2 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)2 GradleSettingsFile (com.android.tools.idea.gradle.parser.GradleSettingsFile)1 Projects.isLegacyIdeaAndroidProject (com.android.tools.idea.gradle.util.Projects.isLegacyIdeaAndroidProject)1 StartupManagerImpl (com.intellij.ide.startup.impl.StartupManagerImpl)1 Project (com.intellij.openapi.project.Project)1 LanguageLevelProjectExtension (com.intellij.openapi.roots.LanguageLevelProjectExtension)1 Ref (com.intellij.openapi.util.Ref)1 VfsUtil.findFileByIoFile (com.intellij.openapi.vfs.VfsUtil.findFileByIoFile)1 LanguageLevel (com.intellij.pom.java.LanguageLevel)1 LightProjectDescriptor (com.intellij.testFramework.LightProjectDescriptor)1 EmptyModuleFixtureBuilder (com.intellij.testFramework.builders.EmptyModuleFixtureBuilder)1