105 lines
3.5 KiB
Java
105 lines
3.5 KiB
Java
package qualification;
|
|
|
|
import static qualification.WorkflowProbe.*;
|
|
|
|
import com.intellij.openapi.project.Project;
|
|
import java.nio.file.Files;
|
|
import java.util.List;
|
|
import javafx.embed.swing.SwingFXUtils;
|
|
import javafx.scene.control.*;
|
|
import javax.imageio.ImageIO;
|
|
|
|
/** Configures the same central group in three independently loaded preview sessions. */
|
|
public final class DockRulesWorkflowProbe extends DeclarationWorkflowProbe {
|
|
private static final String FORM = "ArchiveWindow";
|
|
private static final String DOCUMENTS = "archive-window-documents";
|
|
private static final List<String> FIELDS =
|
|
List.of("minimumWidth", "minimumHeight", "persistent", "splitDirections");
|
|
|
|
@Override
|
|
void verify(Project project) throws Exception {
|
|
this.project = project;
|
|
open(FORM);
|
|
group();
|
|
reject("minimumWidth", "-0.5");
|
|
reject("minimumHeight", "Infinity");
|
|
reject("splitDirections", "RIGHT");
|
|
reject("persistent", "yes");
|
|
applySetting("minimumWidth", "300");
|
|
applySetting("minimumHeight", "225");
|
|
applySetting("persistent", "false");
|
|
applySetting("splitDirections", "HORIZONTAL");
|
|
savedGroup("HORIZONTAL");
|
|
fx(
|
|
() -> {
|
|
ImageIO.write(
|
|
SwingFXUtils.fromFXImage(pane.snapshot(null, null), null),
|
|
"png",
|
|
output.resolve("intellij.png").toFile());
|
|
return null;
|
|
});
|
|
build(DOCUMENTS);
|
|
interactive(DOCUMENTS, "horizontal");
|
|
|
|
group();
|
|
applySetting("persistent", "true");
|
|
applySetting("splitDirections", "VERTICAL");
|
|
savedGroup("VERTICAL");
|
|
build(DOCUMENTS);
|
|
interactive(DOCUMENTS, "vertical");
|
|
|
|
group();
|
|
for (var field : FIELDS) {
|
|
enter(field, "");
|
|
click(pane, "Apply setting");
|
|
await(() -> !source().contains(field + "=\""));
|
|
fx(pane::flush).toCompletableFuture().get();
|
|
}
|
|
savedGroup("destinationId=\"messages\"");
|
|
for (var field : FIELDS) {
|
|
choose("declaration-property", field);
|
|
if (!fx(
|
|
() -> ((ComboBox<?>) pane.lookup("#declaration-value")).getEditor().getText().isEmpty()))
|
|
throw new AssertionError("Reset " + field);
|
|
}
|
|
build("archive-window");
|
|
interactive("archive-window", "defaults");
|
|
Files.writeString(output.resolve("SUCCESS.txt"), Files.readString(output.resolve("steps.txt")));
|
|
}
|
|
|
|
private void group() throws Exception {
|
|
inspector(true);
|
|
select("DockGroupDefinition", "messages");
|
|
}
|
|
|
|
private void savedGroup(String value) throws Exception {
|
|
String expected = source();
|
|
reopen(FORM, expected);
|
|
if (!source().equals(expected)) throw new AssertionError("Reopened FXML differs");
|
|
group();
|
|
select("DockGroupDefinition", "details");
|
|
select("DockGroupDefinition", "messages");
|
|
choose("declaration-property", "splitDirections");
|
|
step("Save / reopen · messages, details · " + value);
|
|
}
|
|
|
|
private void enter(String field, String value) throws Exception {
|
|
choose("declaration-property", field);
|
|
fx(
|
|
() -> {
|
|
((ComboBox<?>) pane.lookup("#declaration-value")).getEditor().setText(value);
|
|
return null;
|
|
});
|
|
}
|
|
|
|
private void reject(String field, String value) throws Exception {
|
|
String before = source();
|
|
enter(field, value);
|
|
click(pane, "Apply setting");
|
|
if (!before.equals(source())
|
|
|| fx(() -> ((Label) pane.lookup("#declaration-message")).getText().isBlank()))
|
|
throw new AssertionError("Accepted " + field + "=" + value);
|
|
step("Rejected · " + field + "=" + value);
|
|
}
|
|
}
|