Enable completion test from custom jar-libraries
This commit is contained in:
@@ -28,6 +28,7 @@ import org.jetbrains.jet.codegen.defaultConstructor.AbstractDefaultConstructorCo
|
||||
import org.jetbrains.jet.codegen.flags.AbstractWriteFlagsTest;
|
||||
import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest;
|
||||
import org.jetbrains.jet.completion.AbstractJavaCompletionTest;
|
||||
import org.jetbrains.jet.completion.AbstractJavaWithLibCompletionTest;
|
||||
import org.jetbrains.jet.completion.AbstractJetJSCompletionTest;
|
||||
import org.jetbrains.jet.jvm.compiler.*;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.AbstractLazyResolveDescriptorRendererTest;
|
||||
@@ -241,6 +242,12 @@ public class GenerateTests {
|
||||
testModel("idea/testData/completion/basic/java", false, "doTest")
|
||||
);
|
||||
|
||||
generateTest(
|
||||
"idea/tests",
|
||||
"JetJavaLibCompletionTestGenerated",
|
||||
AbstractJavaWithLibCompletionTest.class,
|
||||
testModel("idea/testData/completion/basic/custom", false, "doTestWithJar"));
|
||||
|
||||
generateTest(
|
||||
"idea/tests/",
|
||||
"QuickFixMultiFileTestGenerated",
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.completion;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.module.StdModuleTypes;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||
import org.jetbrains.jet.testing.ConfigLibraryUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public abstract class AbstractJavaWithLibCompletionTest extends JetFixtureCompletionBaseTestCase {
|
||||
public void doTestWithJar(String testPath) {
|
||||
NewLibraryEditor editor = new NewLibraryEditor();
|
||||
editor.setName("doTestWithJarLib");
|
||||
|
||||
File fullDirectoryPath = new File(testPath).getParentFile();
|
||||
String jarLibName = getTestName(false) + ".jar";
|
||||
|
||||
File jarFile = new File(fullDirectoryPath, jarLibName);
|
||||
assert jarFile.exists() : "Library file should exist: " + jarFile.getAbsolutePath();
|
||||
|
||||
editor.addRoot(VfsUtil.getUrlForLibraryRoot(jarFile), OrderRootType.CLASSES);
|
||||
|
||||
try {
|
||||
ConfigLibraryUtil.configureLibrary(myModule, getProjectDescriptor().getSdk(), editor);
|
||||
CodeInsightTestFixtureImpl.ensureIndexesUpToDate(getProject());
|
||||
|
||||
doTest(testPath);
|
||||
}
|
||||
finally {
|
||||
ConfigLibraryUtil.unConfigureLibrary(myModule, getProjectDescriptor().getSdk(), editor.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return new LightProjectDescriptor() {
|
||||
@Override
|
||||
public ModuleType getModuleType() {
|
||||
return StdModuleTypes.JAVA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sdk getSdk() {
|
||||
return PluginTestCaseBase.jdkFromIdeaHome();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureModule(Module module, ModifiableRootModel model, ContentEntry contentEntry) {
|
||||
// Do nothing
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpectedCompletionUtils.Platform getPlatform() {
|
||||
return ExpectedCompletionUtils.Platform.JAVA;
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,7 @@ package org.jetbrains.jet.completion;
|
||||
import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.codeInsight.completion.CompletionType;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.JetStdJSProjectDescriptor;
|
||||
|
||||
public abstract class JetFixtureCompletionBaseTestCase extends LightCodeInsightFixtureTestCase {
|
||||
private boolean autocompleteSetting;
|
||||
@@ -79,10 +76,4 @@ public abstract class JetFixtureCompletionBaseTestCase extends LightCodeInsightF
|
||||
itemsNumber.intValue(), items.length);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return JetStdJSProjectDescriptor.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.completion;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
|
||||
import org.jetbrains.jet.completion.AbstractJavaWithLibCompletionTest;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/testData/completion/basic/custom")
|
||||
public class JetJavaLibCompletionTestGenerated extends AbstractJavaWithLibCompletionTest {
|
||||
public void testAllFilesPresentInCustom() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/completion/basic/custom"), Pattern.compile("^(.+)\\.kt$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("TopLevelNonImportedExtFun.kt")
|
||||
public void testTopLevelNonImportedExtFun() throws Exception {
|
||||
doTestWithJar("idea/testData/completion/basic/custom/TopLevelNonImportedExtFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("TopLevelNonImportedFun.kt")
|
||||
public void testTopLevelNonImportedFun() throws Exception {
|
||||
doTestWithJar("idea/testData/completion/basic/custom/TopLevelNonImportedFun.kt");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user