#KT-5728 Fixed

Code review fixes
This commit is contained in:
Anton Sukhonosenko
2016-03-08 22:24:15 +03:00
parent 31fea1d2b7
commit 5bb8bf7381
9 changed files with 83 additions and 64 deletions
@@ -75,6 +75,7 @@ import org.jetbrains.kotlin.idea.decompiler.textBuilder.AbstractCommonDecompiled
import org.jetbrains.kotlin.idea.decompiler.textBuilder.AbstractCommonDecompiledTextTest
import org.jetbrains.kotlin.idea.decompiler.textBuilder.AbstractJsDecompiledTextFromJsMetadataTest
import org.jetbrains.kotlin.idea.decompiler.textBuilder.AbstractJvmDecompiledTextTest
import org.jetbrains.kotlin.idea.editor.backspaceHandler.AbstractBackspaceHandlerTest
import org.jetbrains.kotlin.idea.editor.quickDoc.AbstractQuickDocProviderTest
import org.jetbrains.kotlin.idea.filters.AbstractKotlinExceptionFilterTest
import org.jetbrains.kotlin.idea.folding.AbstractKotlinFoldingTest
@@ -523,6 +524,10 @@ fun main(args: Array<String>) {
model("codeInsight/unwrapAndRemove/unwrapLambda", testMethod = "doTestLambdaUnwrapper")
}
testClass<AbstractBackspaceHandlerTest>() {
model("editor/backspaceHandler")
}
testClass<AbstractQuickDocProviderTest>() {
model("editor/quickDoc", pattern = """^([^_]+)\.[^\.]*$""")
}
@@ -1,40 +0,0 @@
/*
* 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.editor;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.testFramework.EditorTestUtil;
import com.intellij.testFramework.LightCodeInsightTestCase;
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase;
import java.io.File;
public abstract class AbstractEditorTest extends LightCodeInsightTestCase {
protected abstract String getBasePath();
protected String loadFile(String name) throws Exception {
return FileUtil.loadFile(new File(getBasePath(), name), true);
}
protected void configure() throws Exception {
configureFromFileText("a.kt", loadFile(getTestName(true) + ".kt"));
}
protected void check() throws Exception {
checkResultByText(loadFile(getTestName(true) + "_after.kt"));
}
}
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.idea.test.PluginTestCaseBase;
import java.io.File;
public class KotlinCommenterTest extends AbstractEditorTest {
public class KotlinCommenterTest extends LightCodeInsightTestCase {
private static final String BASE_PATH =
new File(PluginTestCaseBase.getTestDataPathBase(), "/editor/commenter/").getAbsolutePath();
@@ -45,8 +45,15 @@ public class KotlinCommenterTest extends AbstractEditorTest {
check();
}
@Override
protected String getBasePath() {
return BASE_PATH;
private void configure() throws Exception {
configureFromFileText("a.kt", loadFile(getTestName(true) + ".kt"));
}
private void check() throws Exception {
checkResultByText(loadFile(getTestName(true) + "_after.kt"));
}
protected static String loadFile(String name) throws Exception {
return FileUtil.loadFile(new File(BASE_PATH, name), true);
}
}
@@ -14,31 +14,20 @@
* limitations under the License.
*/
package org.jetbrains.kotlin.idea.editor
package org.jetbrains.kotlin.idea.editor.backspaceHandler
import com.intellij.openapi.actionSystem.IdeActions
import com.intellij.openapi.util.io.FileUtil
import com.intellij.testFramework.EditorTestUtil
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
import com.intellij.testFramework.LightCodeInsightTestCase
import java.io.File
class StringTemplateBackspaceHandlerTest : AbstractEditorTest() {
val path = File(PluginTestCaseBase.getTestDataPathBase(), "/editor/stringTemplateBackspaceHandler/").getAbsolutePath()
override fun getBasePath(): String? {
return path
}
fun testStringTemplateBrackets() {
doTest()
}
fun testEscapedStringTemplate() {
doTest()
}
fun doTest() {
configure()
open class AbstractBackspaceHandlerTest : LightCodeInsightTestCase() {
fun doTest(path: String) {
configureFromFileText("a.kt", loadFile(path))
EditorTestUtil.executeAction(getEditor(), IdeActions.ACTION_EDITOR_BACKSPACE)
check()
checkResultByText(loadFile(path + ".after"))
}
private fun loadFile(path: String) = FileUtil.loadFile(File(path), true)
}
@@ -0,0 +1,58 @@
/*
* 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.editor.backspaceHandler;
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/editor/backspaceHandler")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class BackspaceHandlerTestGenerated extends AbstractBackspaceHandlerTest {
public void testAllFilesPresentInBackspaceHandler() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/editor/backspaceHandler"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("idea/testData/editor/backspaceHandler/stringTemplate")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class StringTemplate extends AbstractBackspaceHandlerTest {
public void testAllFilesPresentInStringTemplate() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/editor/backspaceHandler/stringTemplate"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("escapedStringTemplate.kt")
public void testEscapedStringTemplate() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/editor/backspaceHandler/stringTemplate/escapedStringTemplate.kt");
doTest(fileName);
}
@TestMetadata("stringTemplateBrackets.kt")
public void testStringTemplateBrackets() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/editor/backspaceHandler/stringTemplate/stringTemplateBrackets.kt");
doTest(fileName);
}
}
}