193 lines
6.8 KiB
Java
193 lines
6.8 KiB
Java
package qualification;
|
|
|
|
import static qualification.WorkflowProbe.*;
|
|
|
|
import com.intellij.openapi.project.Project;
|
|
import java.nio.file.*;
|
|
import java.util.*;
|
|
import javafx.embed.swing.SwingFXUtils;
|
|
import javafx.scene.control.*;
|
|
import javax.imageio.ImageIO;
|
|
|
|
/** Edits original Archiver forms in the registered IntelliJ designer. */
|
|
public final class MediaLayoutGridWorkflowProbe extends DeclarationWorkflowProbe {
|
|
|
|
void verify(Project project) throws Exception {
|
|
this.project = project;
|
|
open("HtmlDocument");
|
|
controls(true);
|
|
choose("form-control", "HtmlViewer #article");
|
|
set("mediaLoadText", "Belegbilder laden", "mediaLoadText=\"Belegbilder laden\"");
|
|
reopen("HtmlDocument", "Belegbilder laden");
|
|
build("html-invoice");
|
|
interactive("html-invoice", "offline");
|
|
details();
|
|
trash();
|
|
window();
|
|
folder();
|
|
Files.writeString(output.resolve("SUCCESS.txt"), Files.readString(output.resolve("steps.txt")));
|
|
}
|
|
|
|
private void insert(String type, String slot, int position, String id) throws Exception {
|
|
choose("form-palette", type);
|
|
choose("form-destination", slot);
|
|
if (position >= 0)
|
|
fx(
|
|
() -> {
|
|
((Spinner<Integer>) pane.lookup("#form-position")).getValueFactory().setValue(position);
|
|
return null;
|
|
});
|
|
String before = source();
|
|
click(pane, "Insert control");
|
|
edited(before, "fx:id=\"" + id + "\"");
|
|
}
|
|
|
|
private void reject(String type, String slot, String reason) throws Exception {
|
|
choose("form-palette", type);
|
|
choose("form-destination", slot);
|
|
String before = source();
|
|
click(pane, "Insert control");
|
|
if (!before.equals(source())
|
|
|| !fx(() -> ((Label) pane.lookup("#form-message")).getText()).contains(reason))
|
|
throw new AssertionError("Expected " + reason);
|
|
}
|
|
|
|
private void history(String before, String after) throws Exception {
|
|
click(pane, "Undo");
|
|
await(() -> source().equals(before));
|
|
click(pane, "Redo");
|
|
await(() -> source().equals(after));
|
|
fx(pane::flush).toCompletableFuture().get();
|
|
}
|
|
|
|
private List<String> declarations() throws Exception {
|
|
return source()
|
|
.lines()
|
|
.map(String::trim)
|
|
.filter(
|
|
l ->
|
|
l.startsWith("<DirectBinding ")
|
|
|| l.startsWith("<CommandBinding ")
|
|
|| l.startsWith("<Repeat "))
|
|
.toList();
|
|
}
|
|
|
|
private void details() throws Exception {
|
|
open("DocumentDetails");
|
|
controls(true);
|
|
var original = declarations();
|
|
reject("Label", "TabPane [", "TabPane.tabs accepts Tab");
|
|
reject("Label", "ScrollPane [", "Occupied");
|
|
insert("Tab", "TabPane [", -1, "tab");
|
|
choose("form-control", "Tab #tab");
|
|
set("text", "Belegprüfung", "text=\"Belegprüfung\"");
|
|
insert("ScrollPane", "Tab #tab / content", 0, "scrollPane");
|
|
choose("form-control", "HBox [");
|
|
choose("form-destination", "ScrollPane #scrollPane / content");
|
|
String before = source();
|
|
click(pane, "Move to destination");
|
|
edited(before, "onAction=\"#addTag\"");
|
|
history(before, source());
|
|
reopen("DocumentDetails", "Belegprüfung");
|
|
if (!original.equals(declarations())) throw new AssertionError("Moved bindings");
|
|
build("details-invoice");
|
|
interactive("details-invoice", "details");
|
|
}
|
|
|
|
private void trash() throws Exception {
|
|
open("TrashPane");
|
|
controls(true);
|
|
insert("Label", "SplitPane [", 1, "label");
|
|
choose("form-control", "Label #label");
|
|
set("text", "Dateien der Auswahl", "text=\"Dateien der Auswahl\"");
|
|
reopen("TrashPane", "Dateien der Auswahl");
|
|
build("trash-full");
|
|
interactive("trash-full", "trash");
|
|
}
|
|
|
|
private void window() throws Exception {
|
|
open("ArchiveWindow");
|
|
controls(true);
|
|
String left =
|
|
fx(
|
|
() ->
|
|
((ComboBox<?>) pane.lookup("#form-destination"))
|
|
.getItems().stream()
|
|
.map(Object::toString)
|
|
.filter(v -> v.startsWith("BorderPane [") && v.endsWith(" / left"))
|
|
.findFirst()
|
|
.orElseThrow());
|
|
String owner = left.substring(0, left.lastIndexOf(" / "));
|
|
for (String region : List.of("center", "top", "bottom", "left", "right")) {
|
|
choose("form-destination", owner + " / " + region);
|
|
}
|
|
reject("Label", owner + " / center", "Occupied");
|
|
insert("Label", left, 0, "label");
|
|
choose("form-control", "Label #label");
|
|
set("text", "Medienprüfung", "text=\"Medienprüfung\"");
|
|
reopen("ArchiveWindow", "Medienprüfung");
|
|
build("archive-window-media");
|
|
interactive("archive-window-media", "media");
|
|
}
|
|
|
|
private void folder() throws Exception {
|
|
open("FolderTab");
|
|
inspector(true);
|
|
var original = declarations();
|
|
select("DataGrid", "grid");
|
|
applySetting("setupId", "archiver-pruefung");
|
|
applySetting("setupVersion", "2");
|
|
for (var pair :
|
|
List.of(List.of("setupId", "archiver-pruefung"), List.of("setupVersion", "2"))) {
|
|
String before = source();
|
|
combo("declaration-property", pair.getFirst());
|
|
fx(
|
|
() -> {
|
|
((ComboBox<?>) pane.lookup("#declaration-value")).getEditor().clear();
|
|
return null;
|
|
});
|
|
click(pane, "Apply setting");
|
|
await(() -> !source().contains(pair.getFirst() + "=\""));
|
|
click(pane, "Undo");
|
|
await(() -> source().equals(before));
|
|
}
|
|
applySetting("groupBy", "folder");
|
|
select("DataGridColumn", "folder");
|
|
applySetting("fixedPosition", "1");
|
|
combo("declaration-property", "groupLabels");
|
|
fx(
|
|
() -> {
|
|
((ComboBox<?>) pane.lookup("#group-label-key")).getEditor().setText("Post");
|
|
((TextField) pane.lookup("#group-label-text")).setText("Posteingang");
|
|
return null;
|
|
});
|
|
String before = source();
|
|
edit("Set group label", "Post=\"Posteingang\"");
|
|
String grouped = source();
|
|
history(before, grouped);
|
|
combo("declaration-property", "groupLabels");
|
|
choose("group-label-key", "Post");
|
|
click(pane, "Remove group label");
|
|
await(() -> !source().contains("Post=\"Posteingang\""));
|
|
click(pane, "Undo");
|
|
await(() -> source().equals(grouped));
|
|
reopen("FolderTab", "Posteingang");
|
|
if (!original.equals(declarations())) throw new AssertionError("Grid bindings");
|
|
inspector(true);
|
|
select("DataGridColumn", "folder");
|
|
combo("declaration-property", "groupLabels");
|
|
if (!fx(() -> ((TextField) pane.lookup("#group-label-text")).getText().equals("Posteingang")))
|
|
throw new AssertionError("Reopened mapping");
|
|
fx(
|
|
() -> {
|
|
ImageIO.write(
|
|
SwingFXUtils.fromFXImage(pane.snapshot(null, null), null),
|
|
"png",
|
|
output.resolve("intellij.png").toFile());
|
|
return null;
|
|
});
|
|
build("archive-folder");
|
|
interactive("archive-folder", "grid");
|
|
}
|
|
}
|