Search in sources :

Example 1 with Command

use of org.malai.command.Command in project Malai by arnobl.

the class TestInteractor method testInteractionStartsOkCauseOfTheNonPublicAction.

@Test
void testInteractionStartsOkCauseOfTheNonPublicAction() throws CancelFSMException {
    final boolean[] ok = { false };
    ErrorCatcher.INSTANCE.setNotifier(exception -> ok[0] = true);
    StubInstrument ins = new StubInstrument();
    WidgetBinding interactor2 = new WidgetBindingImpl<CommandImplStub2, InteractionMock, StubInstrument>(ins, false, CommandImplStub2.class, new InteractionMock()) {

        @Override
        public void first() {
        }

        @Override
        public boolean when() {
            return true;
        }

        @Override
        protected void executeCmdAsync(final Command cmd) {
        }
    };
    ins.setActivated(true);
    interactor2.fsmStarts();
    assertTrue(ok[0]);
    assertNull(interactor.getCommand());
}
Also used : WidgetBinding(org.malai.binding.WidgetBinding) InteractionMock(org.malai.interaction.InteractionMock) WidgetBindingImpl(org.malai.binding.WidgetBindingImpl) Command(org.malai.command.Command) Test(org.junit.jupiter.api.Test)

Example 2 with Command

use of org.malai.command.Command in project Malai by arnobl.

the class TestKeyNodeBinder method testCommandExecutedOnTwoCanvas.

@Test
public void testCommandExecutedOnTwoCanvas() {
    new KeyNodeBinder<>(StubCmd.class, instrument).on(widget1, widget2).with(KeyCode.C).bind();
    grabFocus(widget2);
    type(KeyCode.C);
    WaitForAsyncUtils.waitForFxEvents();
    assertEquals(1, instrument.exec.get());
    Command cmd = instrument.lastCreatedCmd;
    assertEquals(1, ((StubCmd) instrument.lastCreatedCmd).exec.get());
    grabFocus(widget1);
    type(KeyCode.C);
    WaitForAsyncUtils.waitForFxEvents();
    assertEquals(2, instrument.exec.get());
    assertEquals(1, ((StubCmd) instrument.lastCreatedCmd).exec.get());
    assertNotSame(cmd, instrument.lastCreatedCmd);
}
Also used : Command(org.malai.command.Command) Test(org.junit.jupiter.api.Test)

Example 3 with Command

use of org.malai.command.Command in project Malai by arnobl.

the class TestInteractor method testInteractionStartsOkCauseOfTheNonPublicAction2.

@Test
void testInteractionStartsOkCauseOfTheNonPublicAction2() throws CancelFSMException {
    final boolean[] ok = { false };
    ErrorCatcher.INSTANCE.setNotifier(exception -> ok[0] = true);
    StubInstrument ins = new StubInstrument();
    WidgetBinding interactor2 = new WidgetBindingImpl<CommandImplStub3, InteractionMock, StubInstrument>(ins, false, CommandImplStub3.class, new InteractionMock()) {

        @Override
        public void first() {
        }

        @Override
        public boolean when() {
            return true;
        }

        @Override
        protected void executeCmdAsync(final Command cmd) {
        }
    };
    ins.setActivated(true);
    interactor2.fsmStarts();
    assertTrue(ok[0]);
    assertNull(interactor2.getCommand());
}
Also used : WidgetBinding(org.malai.binding.WidgetBinding) InteractionMock(org.malai.interaction.InteractionMock) WidgetBindingImpl(org.malai.binding.WidgetBindingImpl) Command(org.malai.command.Command) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)3 Command (org.malai.command.Command)3 WidgetBinding (org.malai.binding.WidgetBinding)2 WidgetBindingImpl (org.malai.binding.WidgetBindingImpl)2 InteractionMock (org.malai.interaction.InteractionMock)2