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