mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Javafx: "Wrap field with JavaFx property" intention - added test for adding/deleting FXML files (IDEA-102430)
This commit is contained in:
+41
-1
@@ -1,6 +1,12 @@
|
||||
package org.jetbrains.plugins.javaFX;
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Same as the base test, but detects the presence of JavaFX using imports and FXMLs, not artifacts
|
||||
@@ -9,11 +15,45 @@ import com.intellij.codeInsight.intention.IntentionAction;
|
||||
public class JavaFxFieldToPropertyNoArtifactTest extends JavaFxFieldToPropertyTest {
|
||||
|
||||
public void testArtifactPresenceFieldToProperty() throws Exception {
|
||||
final IntentionAction intentionAction = getIntentionAction(getTestName(false) + ".java");
|
||||
configureByFiles(null, getTestName(false) + ".java");
|
||||
final IntentionAction intentionAction = getIntentionAction();
|
||||
// no artifact, no fxml, no javafx.* imports: the intention shoudn't be available
|
||||
assertNull(intentionAction);
|
||||
}
|
||||
|
||||
public void testAddRemoveFxmlFile() throws Exception {
|
||||
final VirtualFile sourceRootDir = configureByFiles(null, getTestName(false) + ".java");
|
||||
IntentionAction intentionAction = getIntentionAction();
|
||||
assertNull(intentionAction);
|
||||
|
||||
final Ref<VirtualFile> fileRef = new Ref<>();
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
try {
|
||||
VirtualFile file = sourceRootDir.createChildData(JavaFxFieldToPropertyNoArtifactTest.this, "sample.fxml");
|
||||
VfsUtil.saveText(file, "<?import javafx.scene.layout.VBox?>\n<VBox/>");
|
||||
fileRef.set(file);
|
||||
}
|
||||
catch (IOException e) {
|
||||
fail(e.toString());
|
||||
}
|
||||
});
|
||||
|
||||
intentionAction = getIntentionAction();
|
||||
assertNotNull("when created", intentionAction);
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
try {
|
||||
fileRef.get().delete(JavaFxFieldToPropertyNoArtifactTest.this);
|
||||
}
|
||||
catch (IOException e) {
|
||||
fail(e.toString());
|
||||
}
|
||||
});
|
||||
|
||||
intentionAction = getIntentionAction();
|
||||
assertNull("when deleted", intentionAction);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isArtifactNeeded() {
|
||||
return false;
|
||||
|
||||
+3
-3
@@ -82,7 +82,8 @@ public class JavaFxFieldToPropertyTest extends DaemonAnalyzerTestCase {
|
||||
private void doTest(String... fileNames) throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(myProject).setLanguageLevel(LanguageLevel.JDK_1_7);
|
||||
|
||||
final IntentionAction intentionAction = getIntentionAction(fileNames);
|
||||
configureByFiles(null, fileNames);
|
||||
final IntentionAction intentionAction = getIntentionAction();
|
||||
assertNotNull(intentionAction);
|
||||
|
||||
Editor editor = getEditor();
|
||||
@@ -92,8 +93,7 @@ public class JavaFxFieldToPropertyTest extends DaemonAnalyzerTestCase {
|
||||
checkResultByFile(getTestName(false) + "_after.java");
|
||||
}
|
||||
|
||||
protected IntentionAction getIntentionAction(String... fileNames) throws Exception {
|
||||
configureByFiles(null, fileNames);
|
||||
protected IntentionAction getIntentionAction() throws Exception {
|
||||
final List<HighlightInfo> infos = doHighlighting();
|
||||
final Editor editor = getEditor();
|
||||
final PsiFile file = getFile();
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
class FloatDemo {
|
||||
float <caret>f;
|
||||
}
|
||||
Reference in New Issue
Block a user