diff --git a/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoActionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoActionTest.kt new file mode 100644 index 00000000000..70b93865d70 --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoActionTest.kt @@ -0,0 +1,42 @@ +/* + * 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.navigation + +import com.intellij.codeInsight.CodeInsightActionHandler +import com.intellij.openapi.actionSystem.ActionManager +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase +import org.jetbrains.kotlin.idea.KotlinFileType +import org.jetbrains.kotlin.test.KotlinTestUtils +import org.junit.Assert + +abstract class AbstractGotoActionTest : LightCodeInsightFixtureTestCase() { + protected abstract val actionName: String + + protected fun doTest(testPath: String) { + val parts = KotlinTestUtils.loadBeforeAfterText(testPath) + + myFixture.configureByText(KotlinFileType.INSTANCE, parts[0]) + + val gotoSuperAction = ActionManager.getInstance().getAction(actionName) as CodeInsightActionHandler + gotoSuperAction.invoke(project, myFixture.editor, myFixture.file) + + val text = myFixture.getDocument(myFixture.file).text + val afterText = StringBuilder(text).insert(editor.caretModel.offset, "").toString() + + Assert.assertEquals(parts[1], afterText) + } +} diff --git a/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoSuperTest.java b/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoSuperTest.java index 8e2199bcad5..f94f30bfaa5 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoSuperTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoSuperTest.java @@ -16,25 +16,13 @@ package org.jetbrains.kotlin.idea.navigation; -import com.intellij.codeInsight.CodeInsightActionHandler; -import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.IdeActions; -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import org.jetbrains.kotlin.idea.KotlinFileType; -import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.annotations.NotNull; -import java.util.List; - -public abstract class AbstractGotoSuperTest extends LightCodeInsightFixtureTestCase { - protected void doTest(String testPath) { - List parts = KotlinTestUtils.loadBeforeAfterText(testPath); - - myFixture.configureByText(KotlinFileType.INSTANCE, parts.get(0)); - - CodeInsightActionHandler gotoSuperAction = - (CodeInsightActionHandler) ActionManager.getInstance().getAction(IdeActions.ACTION_GOTO_SUPER); - gotoSuperAction.invoke(getProject(), myFixture.getEditor(), myFixture.getFile()); - - myFixture.checkResult(parts.get(1)); +public abstract class AbstractGotoSuperTest extends AbstractGotoActionTest { + @NotNull + @Override + protected String getActionName() { + return IdeActions.ACTION_GOTO_SUPER; } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoTypeDeclarationTest.kt b/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoTypeDeclarationTest.kt index 404a46b055d..a7ff461fb12 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoTypeDeclarationTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoTypeDeclarationTest.kt @@ -16,26 +16,9 @@ package org.jetbrains.kotlin.idea.navigation -import com.intellij.codeInsight.CodeInsightActionHandler -import com.intellij.openapi.actionSystem.ActionManager import com.intellij.openapi.actionSystem.IdeActions -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase -import org.jetbrains.kotlin.idea.KotlinFileType -import org.jetbrains.kotlin.test.KotlinTestUtils -import org.junit.Assert -abstract class AbstractGotoTypeDeclarationTest : LightCodeInsightFixtureTestCase() { - protected fun doTest(testPath: String) { - val parts = KotlinTestUtils.loadBeforeAfterText(testPath) - - myFixture.configureByText(KotlinFileType.INSTANCE, parts[0]) - - val gotoSuperAction = ActionManager.getInstance().getAction(IdeActions.ACTION_GOTO_TYPE_DECLARATION) as CodeInsightActionHandler - gotoSuperAction.invoke(project, myFixture.editor, myFixture.file) - - - val afterText = StringBuilder(myFixture.getDocument(myFixture.file).text).insert(editor.caretModel.offset, "").toString() - - Assert.assertEquals(parts[1], afterText) - } +abstract class AbstractGotoTypeDeclarationTest : AbstractGotoActionTest() { + override val actionName: String + get() = IdeActions.ACTION_GOTO_TYPE_DECLARATION }