IDEA plugin: added the error checking to intentions tests.

This commit is contained in:
Zalim Bashorov
2014-03-31 16:37:51 +04:00
parent d5eea09146
commit 3375ed90a4
4 changed files with 13 additions and 7 deletions
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.plugin.quickfix; package org.jetbrains.jet.plugin;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@@ -36,8 +36,8 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
public class QuickFixActionsUtils { public class DirectiveBasedActionUtils {
private QuickFixActionsUtils() { private DirectiveBasedActionUtils() {
} }
public static void checkForUnexpectedErrors(JetFile file) { public static void checkForUnexpectedErrors(JetFile file) {
@@ -23,6 +23,8 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.testFramework.LightCodeInsightTestCase; import com.intellij.testFramework.LightCodeInsightTestCase;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.InTextDirectivesUtils; import org.jetbrains.jet.InTextDirectivesUtils;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.plugin.DirectiveBasedActionUtils;
import org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.*; import org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.*;
import org.jetbrains.jet.plugin.intentions.declarations.ConvertMemberToExtension; import org.jetbrains.jet.plugin.intentions.declarations.ConvertMemberToExtension;
import org.jetbrains.jet.plugin.intentions.declarations.SplitPropertyDeclarationIntention; import org.jetbrains.jet.plugin.intentions.declarations.SplitPropertyDeclarationIntention;
@@ -215,6 +217,8 @@ public abstract class AbstractCodeTransformationTest extends LightCodeInsightTes
private void doTestIntention(@NotNull String path, @NotNull IntentionAction intentionAction) throws Exception { private void doTestIntention(@NotNull String path, @NotNull IntentionAction intentionAction) throws Exception {
configureByFile(path); configureByFile(path);
DirectiveBasedActionUtils.checkForUnexpectedErrors((JetFile) getFile());
String fileText = FileUtil.loadFile(new File(path), true); String fileText = FileUtil.loadFile(new File(path), true);
String isApplicableString = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// IS_APPLICABLE: "); String isApplicableString = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// IS_APPLICABLE: ");
boolean isApplicableExpected = isApplicableString == null || isApplicableString.equals("true"); boolean isApplicableExpected = isApplicableString == null || isApplicableString.equals("true");
@@ -29,6 +29,7 @@ import com.intellij.util.ui.UIUtil;
import junit.framework.ComparisonFailure; import junit.framework.ComparisonFailure;
import org.jetbrains.jet.JetTestCaseBuilder; import org.jetbrains.jet.JetTestCaseBuilder;
import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.plugin.DirectiveBasedActionUtils;
import org.jetbrains.jet.plugin.PluginTestCaseBase; import org.jetbrains.jet.plugin.PluginTestCaseBase;
import java.io.File; import java.io.File;
@@ -76,7 +77,7 @@ public abstract class AbstractQuickFixMultiFileTest extends DaemonAnalyzerTestCa
boolean actionShouldBeAvailable = pair.getSecond(); boolean actionShouldBeAvailable = pair.getSecond();
QuickFixActionsUtils.checkForUnexpectedErrors((JetFile) getFile()); DirectiveBasedActionUtils.checkForUnexpectedErrors((JetFile) getFile());
doAction(text, actionShouldBeAvailable, beforeFileName); doAction(text, actionShouldBeAvailable, beforeFileName);
} }
@@ -107,7 +108,7 @@ public abstract class AbstractQuickFixMultiFileTest extends DaemonAnalyzerTestCa
"Infos:" + infos); "Infos:" + infos);
} }
else { else {
QuickFixActionsUtils.checkAvailableActionsAreExpected((JetFile) getFile(), availableActions); DirectiveBasedActionUtils.checkAvailableActionsAreExpected((JetFile) getFile(), availableActions);
} }
} }
else { else {
@@ -33,6 +33,7 @@ import org.apache.commons.lang.SystemUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.InTextDirectivesUtils; import org.jetbrains.jet.InTextDirectivesUtils;
import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.plugin.DirectiveBasedActionUtils;
import org.jetbrains.jet.plugin.PluginTestCaseBase; import org.jetbrains.jet.plugin.PluginTestCaseBase;
import org.jetbrains.jet.test.TestMetadata; import org.jetbrains.jet.test.TestMetadata;
import org.jetbrains.jet.testing.ConfigLibraryUtil; import org.jetbrains.jet.testing.ConfigLibraryUtil;
@@ -89,13 +90,13 @@ public abstract class AbstractQuickFixTest extends LightQuickFixTestCase {
} }
else { else {
// Action shouldn't be found. Check that other actions are expected and thus tested action isn't there under another name. // Action shouldn't be found. Check that other actions are expected and thus tested action isn't there under another name.
QuickFixActionsUtils.checkAvailableActionsAreExpected((JetFile) getFile(), actions); DirectiveBasedActionUtils.checkAvailableActionsAreExpected((JetFile) getFile(), actions);
} }
} }
} }
public static void checkForUnexpectedErrors() { public static void checkForUnexpectedErrors() {
QuickFixActionsUtils.checkForUnexpectedErrors((JetFile) getFile()); DirectiveBasedActionUtils.checkForUnexpectedErrors((JetFile) getFile());
} }
@Override @Override