enable registry setting before test if it is not enabled

This commit is contained in:
Bas Leijdekkers
2012-01-05 12:18:51 +01:00
parent 11c2480f30
commit 51470c6398
@@ -23,6 +23,7 @@ import com.intellij.openapi.editor.actionSystem.TypedAction;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
import org.jetbrains.annotations.NotNull;
@@ -111,19 +112,25 @@ public class SelectionQuotingTypedHandlerTest extends LightPlatformCodeInsightFi
}
private void doTest(@NotNull final String cs, @NotNull String before, @NotNull String expected) {
myFixture.configureByText(FileTypes.PLAIN_TEXT, before);
final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();
final boolean smarterSelection = Registry.is("editor.smarterSelectionQuoting");
Registry.get("editor.smarterSelectionQuoting").setValue(true);
try {
myFixture.configureByText(FileTypes.PLAIN_TEXT, before);
final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();
performAction(myFixture.getProject(), new Runnable() {
@Override
public void run() {
for (int i = 0, max = cs.length(); i < max; i++) {
final char c = cs.charAt(i);
typedAction.actionPerformed(myFixture.getEditor(), c, ((EditorEx)myFixture.getEditor()).getDataContext());
performAction(myFixture.getProject(), new Runnable() {
@Override
public void run() {
for (int i = 0, max = cs.length(); i < max; i++) {
final char c = cs.charAt(i);
typedAction.actionPerformed(myFixture.getEditor(), c, ((EditorEx)myFixture.getEditor()).getDataContext());
}
}
}
});
myFixture.checkResult(expected);
});
myFixture.checkResult(expected);
} finally {
Registry.get("editor.smarterSelectionQuoting").setValue(smarterSelection);
}
}
public void testRuby7852ErrantEditor() {