Add test for KT-13057 with infrastructure
This commit is contained in:
@@ -79,6 +79,7 @@ import org.jetbrains.kotlin.idea.editor.quickDoc.AbstractQuickDocProviderTest
|
|||||||
import org.jetbrains.kotlin.idea.filters.AbstractKotlinExceptionFilterTest
|
import org.jetbrains.kotlin.idea.filters.AbstractKotlinExceptionFilterTest
|
||||||
import org.jetbrains.kotlin.idea.folding.AbstractKotlinFoldingTest
|
import org.jetbrains.kotlin.idea.folding.AbstractKotlinFoldingTest
|
||||||
import org.jetbrains.kotlin.idea.hierarchy.AbstractHierarchyTest
|
import org.jetbrains.kotlin.idea.hierarchy.AbstractHierarchyTest
|
||||||
|
import org.jetbrains.kotlin.idea.hierarchy.AbstractHierarchyWithLibTest
|
||||||
import org.jetbrains.kotlin.idea.highlighter.*
|
import org.jetbrains.kotlin.idea.highlighter.*
|
||||||
import org.jetbrains.kotlin.idea.imports.AbstractOptimizeImportsTest
|
import org.jetbrains.kotlin.idea.imports.AbstractOptimizeImportsTest
|
||||||
import org.jetbrains.kotlin.idea.intentions.AbstractIntentionTest
|
import org.jetbrains.kotlin.idea.intentions.AbstractIntentionTest
|
||||||
@@ -517,6 +518,10 @@ fun main(args: Array<String>) {
|
|||||||
model("hierarchy/overrides", extension = null, recursive = false, testMethod = "doOverrideHierarchyTest")
|
model("hierarchy/overrides", extension = null, recursive = false, testMethod = "doOverrideHierarchyTest")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testClass<AbstractHierarchyWithLibTest>() {
|
||||||
|
model("hierarchy/withLib", extension = null, recursive = false)
|
||||||
|
}
|
||||||
|
|
||||||
testClass<AbstractMoveStatementTest>() {
|
testClass<AbstractMoveStatementTest>() {
|
||||||
model("codeInsight/moveUpDown/classBodyDeclarations", testMethod = "doTestClassBodyDeclaration")
|
model("codeInsight/moveUpDown/classBodyDeclarations", testMethod = "doTestClassBodyDeclaration")
|
||||||
model("codeInsight/moveUpDown/closingBraces", testMethod = "doTestExpression")
|
model("codeInsight/moveUpDown/closingBraces", testMethod = "doTestExpression")
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<node text="Object (java.lang)">
|
||||||
|
<node text="Enum (java.lang)" base="true">
|
||||||
|
<node text="One ()"/>
|
||||||
|
<node text="G ()"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// BASE_CLASS: java.lang.Enum
|
||||||
|
|
||||||
|
enum class One {
|
||||||
|
One, Two
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class G {
|
||||||
|
A, B
|
||||||
|
}
|
||||||
@@ -53,7 +53,7 @@ Test accept more than one file, file extension should be .java or .kt
|
|||||||
*/
|
*/
|
||||||
public abstract class AbstractHierarchyTest extends KotlinHierarchyViewTestBase {
|
public abstract class AbstractHierarchyTest extends KotlinHierarchyViewTestBase {
|
||||||
|
|
||||||
private String folderName;
|
protected String folderName;
|
||||||
|
|
||||||
protected void doTypeClassHierarchyTest(@NotNull String folderName) throws Exception {
|
protected void doTypeClassHierarchyTest(@NotNull String folderName) throws Exception {
|
||||||
this.folderName = folderName;
|
this.folderName = folderName;
|
||||||
@@ -180,7 +180,7 @@ public abstract class AbstractHierarchyTest extends KotlinHierarchyViewTestBase
|
|||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] getFilesToConfigure() {
|
protected String[] getFilesToConfigure() {
|
||||||
final List<String> files = new ArrayList<String>(2);
|
final List<String> files = new ArrayList<String>(2);
|
||||||
FileUtil.processFilesRecursively(new File(folderName), new Processor<File>() {
|
FileUtil.processFilesRecursively(new File(folderName), new Processor<File>() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2016 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.kotlin.idea.hierarchy
|
||||||
|
|
||||||
|
import com.intellij.ide.hierarchy.HierarchyBrowserBaseEx
|
||||||
|
import com.intellij.ide.hierarchy.type.TypeHierarchyTreeStructure
|
||||||
|
import com.intellij.openapi.util.Computable
|
||||||
|
import com.intellij.psi.PsiClass
|
||||||
|
import com.intellij.psi.impl.java.stubs.index.JavaFullClassNameIndex
|
||||||
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
|
import org.jetbrains.kotlin.idea.test.ModuleKind
|
||||||
|
import org.jetbrains.kotlin.idea.test.configureAs
|
||||||
|
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||||
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
abstract class AbstractHierarchyWithLibTest : AbstractHierarchyTest() {
|
||||||
|
override fun setUp() {
|
||||||
|
super.setUp()
|
||||||
|
myModule.configureAs(ModuleKind.KOTLIN_JVM_WITH_STDLIB_SOURCES)
|
||||||
|
}
|
||||||
|
|
||||||
|
protected fun doTest(folderName: String) {
|
||||||
|
this.folderName = folderName
|
||||||
|
|
||||||
|
val filesToConfigure = filesToConfigure
|
||||||
|
val file = filesToConfigure.first()
|
||||||
|
val directive = InTextDirectivesUtils.findLinesWithPrefixesRemoved(
|
||||||
|
File("${KotlinTestUtils.getHomeDirectory()}/$folderName/$file").readText(),
|
||||||
|
"// BASE_CLASS: "
|
||||||
|
).singleOrNull() ?: error("File should contain BASE_CLASS directive")
|
||||||
|
|
||||||
|
val targetClass = findTargetJavaClass(directive.trim())
|
||||||
|
doHierarchyTest(
|
||||||
|
Computable {
|
||||||
|
TypeHierarchyTreeStructure(
|
||||||
|
project,
|
||||||
|
targetClass,
|
||||||
|
HierarchyBrowserBaseEx.SCOPE_PROJECT)
|
||||||
|
}, *filesToConfigure)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun findTargetJavaClass(targetClass: String): PsiClass {
|
||||||
|
return JavaFullClassNameIndex.getInstance().get(targetClass.hashCode(), project, GlobalSearchScope.allScope(project)).find {
|
||||||
|
it.qualifiedName == targetClass
|
||||||
|
} ?: error("Could not find java class: $targetClass")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2016 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.kotlin.idea.hierarchy;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||||
|
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||||
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@TestMetadata("idea/testData/hierarchy/withLib")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public class HierarchyWithLibTestGenerated extends AbstractHierarchyWithLibTest {
|
||||||
|
public void testAllFilesPresentInWithLib() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/hierarchy/withLib"), Pattern.compile("^([^\\.]+)$"), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("enum")
|
||||||
|
public void testEnum() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/withLib/enum/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user