Skip to content

Commit

Permalink
Test for scene event
Browse files Browse the repository at this point in the history
  • Loading branch information
shadskii authored and jkh416 committed Nov 6, 2017
1 parent 6e6b9f9 commit 6b971ff
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void testObservable()
{
SimpleBooleanProperty observable = new SimpleBooleanProperty(false);
AtomicBoolean actual = new AtomicBoolean();
FxFluxFrom.oberservable(observable)
FxFluxFrom.observable(observable)
.publishOn(thread)
.subscribe(actual::set);
observable.set(true);
Expand All @@ -132,6 +132,33 @@ public void testObservableList()
assertThat(actual.get()).containsExactly(1, 2, 3);
}

@Test
public void testSceneEvent() throws TimeoutException, InterruptedException
{
AtomicReference<Scene> actual = new AtomicReference<>();
AtomicReference<Node> actualNode = new AtomicReference<>();
setStage(stage ->
{
Pane pane = new Pane();
Scene scene = new Scene(pane);
actualNode.set(pane);
actual.set(scene);
stage.setScene(scene);
});

AtomicReference<Event> event = new AtomicReference<>();
Scene scene = actual.get();

FxFluxFrom.sceneEvent(scene, KeyEvent.KEY_TYPED)
.publishOn(thread)
.subscribe(event::set);


actualNode.get()
.fireEvent(new KeyEvent(KeyEvent.KEY_TYPED, "", "", KeyCode.CODE_INPUT, false, false, false, false));
assertThat(event.get()
.getSource()).isEqualTo(scene);
}

public static final class TestApp extends Application
{
Expand Down

0 comments on commit 6b971ff

Please sign in to comment.