Add reviewed FXML View generation in both hosts
This commit is contained in:
@@ -56,6 +56,16 @@ public final class FileDocuments implements HostServices.Documents, AutoCloseabl
|
||||
return future;
|
||||
}
|
||||
|
||||
public CompletionStage<DocumentSession> create(URI uri, String text) {
|
||||
return submit(
|
||||
() -> {
|
||||
Files.writeString(
|
||||
Path.of(uri), text, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE);
|
||||
return uri;
|
||||
})
|
||||
.thenCompose(this::open);
|
||||
}
|
||||
|
||||
public CompletionStage<DocumentSession> open(URI uri) {
|
||||
return submit(
|
||||
() -> {
|
||||
|
||||
+18
@@ -12,6 +12,24 @@ import org.junit.jupiter.api.io.TempDir;
|
||||
class FileDocumentsTest {
|
||||
@TempDir Path folder;
|
||||
|
||||
@Test
|
||||
void creationNeverOverwritesAndTheNewDocumentHasNormalHistory() throws Exception {
|
||||
var uri = folder.resolve("New.fxml").toUri();
|
||||
try (var docs = new FileDocuments();
|
||||
var d = docs.create(uri, "before").toCompletableFuture().get()) {
|
||||
assertThrows(
|
||||
ExecutionException.class,
|
||||
() -> docs.create(uri, "overwrite").toCompletableFuture().get());
|
||||
var changed =
|
||||
d.apply(new EditBatch(0, "edit", List.of(new EditBatch.Replacement(0, 6, "after"))))
|
||||
.toCompletableFuture()
|
||||
.get();
|
||||
assertEquals("before", d.undo().toCompletableFuture().get().text());
|
||||
assertEquals("after", d.redo().toCompletableFuture().get().text());
|
||||
assertEquals("before", Files.readString(Path.of(uri)));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void sharedDraftHistorySurvivesClosingOneHandleAndUndoNeverReusesRevision() throws Exception {
|
||||
Path file = folder.resolve("View.fxml");
|
||||
|
||||
+41
-1
@@ -57,11 +57,35 @@ public final class KitWorkflowSmoke {
|
||||
started.await();
|
||||
Platform.setImplicitExit(false);
|
||||
var launch = HostLaunch.load(Path.of(args[0]));
|
||||
var application = new DesignerApplication();
|
||||
var launchField = DesignerApplication.class.getDeclaredField("launch");
|
||||
launchField.setAccessible(true);
|
||||
launchField.set(application, launch);
|
||||
var hostField = DesignerApplication.class.getDeclaredField("host");
|
||||
hostField.setAccessible(true);
|
||||
var windowsField = DesignerApplication.class.getDeclaredField("windows");
|
||||
windowsField.setAccessible(true);
|
||||
windowsField.set(application, 1);
|
||||
var navigate =
|
||||
DesignerApplication.class.getDeclaredMethod(
|
||||
"navigate", de.neitzel.fxdesigner.host.HostServices.Location.class, boolean.class);
|
||||
navigate.setAccessible(true);
|
||||
try (var host =
|
||||
new StandaloneHost(
|
||||
launch.runtimes(),
|
||||
l -> CompletableFuture.completedFuture(null),
|
||||
l -> {
|
||||
if (!l.document().toString().endsWith("ReviewedView.fxml"))
|
||||
return CompletableFuture.completedFuture(null);
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
var result = (CompletableFuture<Void>) navigate.invoke(application, l, false);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
return CompletableFuture.failedFuture(e);
|
||||
}
|
||||
},
|
||||
d -> System.out.println(d.message()))) {
|
||||
hostField.set(application, host);
|
||||
fx(
|
||||
() -> {
|
||||
pane = new DesignerPane(host.services(), launch, Path.of(args[1]));
|
||||
@@ -111,6 +135,17 @@ public final class KitWorkflowSmoke {
|
||||
.toList()));
|
||||
throw new AssertionError("Shared Kit did not render target pixels");
|
||||
}
|
||||
if (Boolean.getBoolean("designer.check.generationOnly")) {
|
||||
try (var document =
|
||||
host.services()
|
||||
.documents()
|
||||
.open(Path.of(args[1]).toUri())
|
||||
.toCompletableFuture()
|
||||
.get()) {
|
||||
ProjectionHostChecks.generation(pane, document);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (Boolean.getBoolean("designer.check.racesOnly")) {
|
||||
try (var document =
|
||||
host.services()
|
||||
@@ -288,6 +323,11 @@ public final class KitWorkflowSmoke {
|
||||
} finally {
|
||||
fx(
|
||||
() -> {
|
||||
for (var window : java.util.List.copyOf(javafx.stage.Window.getWindows()))
|
||||
if (window instanceof Stage child
|
||||
&& child != stage
|
||||
&& child.getScene() != null
|
||||
&& child.getScene().getRoot() instanceof DesignerPane) child.close();
|
||||
if (pane != null) pane.close();
|
||||
if (fallback != null) fallback.close();
|
||||
if (stage != null) stage.close();
|
||||
|
||||
Reference in New Issue
Block a user