Remove write action for paste for better idea actual behaviour emulation
This commit is contained in:
committed by
Natalia Ukhorskaya
parent
9f3b73986a
commit
86767c2349
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* Copyright 2010-2014 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.
|
||||
@@ -17,6 +17,9 @@
|
||||
package org.jetbrains.jet.plugin;
|
||||
|
||||
import com.intellij.ide.startup.impl.StartupManagerImpl;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
@@ -69,4 +72,23 @@ public abstract class JetLightCodeInsightFixtureTestCase extends LightCodeInsigh
|
||||
protected String fileName() {
|
||||
return getTestName(false) + ".kt";
|
||||
}
|
||||
|
||||
protected boolean performNotWriteEditorAction(String actionId) {
|
||||
DataContext dataContext = ((EditorEx)myFixture.getEditor()).getDataContext();
|
||||
|
||||
ActionManagerEx managerEx = ActionManagerEx.getInstanceEx();
|
||||
AnAction action = managerEx.getAction(actionId);
|
||||
AnActionEvent event = new AnActionEvent(null, dataContext, ActionPlaces.UNKNOWN, new Presentation(), managerEx, 0);
|
||||
|
||||
action.update(event);
|
||||
if (!event.getPresentation().isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
managerEx.fireBeforeActionPerformed(action, dataContext, event);
|
||||
action.actionPerformed(event);
|
||||
|
||||
managerEx.fireAfterActionPerformed(action, dataContext, event);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -69,14 +69,18 @@ public abstract class AbstractInsertImportOnPasteTest extends JetLightCodeInsigh
|
||||
myFixture.setTestDataPath(BASE_PATH);
|
||||
File testFile = new File(path);
|
||||
String testFileName = testFile.getName();
|
||||
|
||||
configureByDependencyIfExists(testFileName.replace(".kt", ".dependency.kt"));
|
||||
configureByDependencyIfExists(testFileName.replace(".kt", ".dependency.java"));
|
||||
myFixture.configureByFile(testFileName);
|
||||
myFixture.performEditorAction(cutOrCopy);
|
||||
|
||||
String toFileName = testFileName.replace(".kt", ".to.kt");
|
||||
JetFile toFile = configureToFile(toFileName);
|
||||
myFixture.performEditorAction(IdeActions.ACTION_PASTE);
|
||||
performNotWriteEditorAction(IdeActions.ACTION_PASTE);
|
||||
|
||||
myFixture.checkResultByFile(testFileName.replace(".kt", ".expected.kt"));
|
||||
|
||||
if (!InTextDirectivesUtils.isDirectiveDefined(FileUtil.loadFile(testFile), ALLOW_UNRESOLVED_DIRECTIVE)) {
|
||||
checkNoUnresolvedReferences(toFile);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user