Render WebView content and qualify Archiver document previews in IntelliJ

This commit is contained in:
2026-11-24 17:54:36 +01:00
parent b04bd9d7ef
commit f9c3de2d2b
9 changed files with 653 additions and 175 deletions
@@ -2,13 +2,10 @@ package qualification;
import static qualification.WorkflowProbe.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.fileEditor.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity;
import com.intellij.openapi.vfs.*;
import de.neitzel.fxdesigner.kit.DesignerPane;
import java.nio.file.*;
import java.util.*;
import javafx.embed.swing.SwingFXUtils;
@@ -16,112 +13,8 @@ import javafx.scene.control.*;
import javafx.scene.image.*;
import javax.imageio.ImageIO;
/** Drives the registered editor against a disposable copy of the real Archiver form. */
public final class ConnectionWorkflowProbe implements StartupActivity.DumbAware {
private DesignerPane pane;
private VirtualFile file;
public void runActivity(Project project) {
if (!started.compareAndSet(false, true)) return;
ApplicationManager.getApplication()
.executeOnPooledThread(
() -> {
try {
verify(project);
} catch (Throwable ex) {
try {
var trace = new java.io.StringWriter();
ex.printStackTrace(new java.io.PrintWriter(trace));
if (pane != null)
trace.append(
fx(
() ->
pane.lookupAll(".label").stream()
.filter(Label.class::isInstance)
.map(n -> Objects.toString(((Label) n).getText(), ""))
.filter(s -> !s.isEmpty())
.toList()
.toString()));
Files.writeString(output.resolve("FAILURE.txt"), trace.toString());
} catch (Exception failure) {
failure.printStackTrace();
}
}
});
}
private void step(String message) throws Exception {
Files.writeString(
output.resolve("steps.txt"),
message + "\n",
StandardOpenOption.CREATE,
StandardOpenOption.APPEND);
}
private String source() throws Exception {
return edt(() -> FileDocumentManager.getInstance().getDocument(file).getText());
}
private void controls(boolean expanded) throws Exception {
fx(
() -> {
var panel =
(TitledPane)
pane.lookupAll(".titled-pane").stream()
.filter(n -> n instanceof TitledPane t && t.getText().equals("Form controls"))
.findFirst()
.orElseThrow();
panel.setAnimated(false);
panel.setExpanded(expanded);
pane.applyCss();
pane.layout();
return null;
});
}
private void choose(String selector, String text) throws Exception {
fx(
() -> {
var combo = (ComboBox<?>) pane.lookup("#" + selector);
for (int i = 0; i < combo.getItems().size(); i++) {
if (combo.getItems().get(i).toString().equals(text)) {
combo.getSelectionModel().select(i);
return null;
}
}
for (int i = 0; i < combo.getItems().size(); i++) {
String label = combo.getItems().get(i).toString();
if (label.equals(text) || label.contains(text)) {
combo.getSelectionModel().select(i);
return null;
}
}
throw new AssertionError(selector + " missing " + text + " in " + combo.getItems());
});
}
private void edited(String before, String expected) throws Exception {
await(
() -> {
String now = source();
String error =
fx(
() -> {
var label = (Label) pane.lookup("#form-message");
return label == null ? "" : label.getText();
});
if (!error.isEmpty()) throw new AssertionError(error);
return !before.equals(now)
&& now.contains(expected)
&& fx(
() ->
((TextArea) pane.lookup("#fxml-source")) == null
|| ((TextArea) pane.lookup("#fxml-source")).getText().equals(now));
});
// Both the native document and visual selection are refreshed asynchronously.
fx(pane::flush).toCompletableFuture().get(10, java.util.concurrent.TimeUnit.SECONDS);
}
/** Drives the registered editor against a disposable copy of the real Archiver connection form. */
public final class ConnectionWorkflowProbe extends FormWorkflowProbe {
private void add(String type, String destination, String id) throws Exception {
step("Inserting " + type + " as " + id);
choose("form-palette", type);
@@ -151,18 +44,6 @@ public final class ConnectionWorkflowProbe implements StartupActivity.DumbAware
step("Inserted " + type + " into " + destination);
}
private void set(String name, String value, String expected) throws Exception {
choose("form-property", name);
fx(
() -> {
((TextArea) pane.lookup("#form-value")).setText(value);
return null;
});
String before = source();
click(pane, "Set property");
edited(before, expected);
}
private void bind(String name, String path) throws Exception {
choose("form-property", name);
click(pane, "Bind property");
@@ -211,16 +92,8 @@ public final class ConnectionWorkflowProbe implements StartupActivity.DumbAware
step("In-editor " + id + " target frame " + width + " × 720");
}
private void awaitTarget(String name) throws Exception {
await(
() -> {
var error = output.resolve("target-error.txt");
if (Files.exists(error)) throw new AssertionError(Files.readString(error));
return Files.exists(output.resolve(name));
});
}
private void verify(Project project) throws Exception {
@Override
void verify(Project project) throws Exception {
var path =
Path.of(
project.getBasePath(), "src/main/resources/de/neitzel/archiver/ui/ConnectionForm.fxml");