diagnostics for tests

(cherry picked from commit cfc62a20a2199e53758520459344fecb2274f535)
This commit is contained in:
anna
2011-12-06 10:38:00 +01:00
parent 3519e3d598
commit e81e8dabb4
3 changed files with 29 additions and 11 deletions
@@ -113,18 +113,23 @@ public class JavaSurroundWithTest extends LightCodeInsightTestCase {
}
private void doTestWithTemplateFinish(@NotNull String fileName, final Surrounder surrounder, @Nullable String textToType)
throws Exception
{
((TemplateManagerImpl)TemplateManager.getInstance(getProject())).setTemplateTesting(true);
configureByFile(BASE_PATH + fileName + ".java");
SurroundWithHandler.invoke(getProject(), getEditor(), getFile(), surrounder);
if (textToType != null) {
type(textToType);
throws Exception {
final TemplateManagerImpl templateManager = (TemplateManagerImpl)TemplateManager.getInstance(getProject());
try {
templateManager.setTemplateTesting(true);
configureByFile(BASE_PATH + fileName + ".java");
SurroundWithHandler.invoke(getProject(), getEditor(), getFile(), surrounder);
if (textToType != null) {
type(textToType);
}
TemplateState templateState = TemplateManagerImpl.getTemplateState(getEditor());
assertNotNull(templateState);
templateState.nextTab();
checkResultByFile(BASE_PATH + fileName + "_after.java");
}
finally {
templateManager.setTemplateTesting(false);
}
TemplateState templateState = TemplateManagerImpl.getTemplateState(getEditor());
assertNotNull(templateState);
templateState.nextTab();
checkResultByFile(BASE_PATH + fileName + "_after.java");
}
}
@@ -22,6 +22,7 @@ import com.intellij.openapi.command.undo.UndoManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.TestOnly;
/**
* User: anna
@@ -61,6 +62,16 @@ public class StartMarkAction extends BasicUndoableAction {
myCommandName = commandName;
}
@TestOnly
public static void checkCleared() {
try {
assert ourCurrentMark == null;
}
finally {
ourCurrentMark = null;
}
}
public static StartMarkAction start(Editor editor, Project project, String commandName) throws AlreadyStartedException {
if (ourCurrentMark != null) {
throw new AlreadyStartedException(ourCurrentMark.myCommandName,
@@ -22,6 +22,7 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.command.impl.StartMarkAction;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
@@ -190,6 +191,7 @@ public abstract class UsefulTestCase extends TestCase {
myOldCodeStyleSettings = null;
VariableInplaceRenamer.checkCleared();
StartMarkAction.checkCleared();
}
protected void storeSettings() {