Usage of Toolkit firePulse

Kevin Rushforth kevin.rushforth at oracle.com
Thu Sep 24 15:15:26 UTC 2015


This is basically how we use it for our unit tests, and is so far the 
only use case I've see where the existing semantics are useful. Given 
that unit tests still need to dip into non-public API to test various 
non-public API, force layout, force a pulse, use glass Robot, etc., we 
wouldn't make it public API just for testing.

-- Kevin


Ryan Jaeb wrote:
> 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