Usage of Toolkit firePulse
Ryan Jaeb
ryan at jaeb.ca
Thu Sep 24 10:49:16 UTC 2015
I use firePulse() in GUI test code. I'm using TestFX (v3) for testing. Is
there a way to ensure model updates are reflected in the scene without
using firePulse()? Consider something like this:
...
// TestFX starts us on the main thread. Maybe I'm using it wrong?
CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(() -> {
// Add "list-item-name" to an empty list that's used as the model for
// a ListView.
Toolkit.getToolkit().firePulse();
latch.countDown();
});
try {
latch.await(1, TimeUnit.SECONDS);
}
catch (InterruptedException e) {
throw new RuntimeException(e);
}
// TestFX runs this on the application thread.
drag("list-item-name").to("trash");
assertTrue(list.isEmpty);
...
In a case like the above, firePulse() is used to ensure a node (ListCell)
for "list-item-name" is added to the scene before continuing with the
test. Otherwise the drag(...) command will throw an exception because it
can't find the node for "list-item-name" (it doesn't exist yet).
I don't actually needto call firePulse(). I just need a way to know the
scene is up to date with a re-validated model. Is there a better way of
accomplishing that right now?
Ryan
On Wed, Sep 23, 2015 at 5:49 PM, Jonathan Giles <jonathan.giles at oracle.com>
wrote:
> Hi all,
>
> Today I am keen to get your help on understanding use of the
> Toolkit.getToolkit().firePulse() private API. If you could spare a few
> minutes to grep your source directory for any usage of 'firePulse', and
> email me your findings, that would be really interesting.
>
> As a gentle motivational tool I'll conclude by saying that, surprisingly,
> this private API is barely used inside the openjfx production code. If you
> look at the openjfx unit tests, it is used massively. The question is - how
> much is this being used by other community members. If the answer is 'not
> much' or less, then this private API may not be made public in JDK 9. Your
> feedback therefore is critical!
>
> Thanks,
> -- Jonathan
>
More information about the openjfx-dev
mailing list