Search in sources :

Example 1 with AbstractOutlineViewButton

use of org.eclipse.scout.rt.client.ui.desktop.outline.AbstractOutlineViewButton in project scout.rt by eclipse.

the class ActionTest method testOutlineButton.

@Test
public void testOutlineButton() {
    IDesktop desktopMock = Mockito.mock(IDesktop.class);
    IOutline outlineMock = Mockito.mock(IOutline.class);
    Mockito.when(desktopMock.getAvailableOutlines()).thenReturn(CollectionUtility.arrayList(outlineMock));
    final IntegerHolder execActionHolder = new IntegerHolder(0);
    final IntegerHolder execToggleHolder = new IntegerHolder(0);
    AbstractOutlineViewButton b = new AbstractOutlineViewButton(desktopMock, outlineMock.getClass()) {

        @Override
        protected void execAction() {
            execActionHolder.setValue(execActionHolder.getValue() + 1);
        }

        @Override
        protected void execSelectionChanged(boolean selection) {
            execToggleHolder.setValue(execToggleHolder.getValue() + 1);
        }
    };
    b.getUIFacade().setSelectedFromUI(true);
    b.getUIFacade().fireActionFromUI();
    assertEquals(1, execActionHolder.getValue().intValue());
    assertEquals(1, execToggleHolder.getValue().intValue());
    assertTrue(b.isSelected());
    b.getUIFacade().fireActionFromUI();
    assertEquals(2, execActionHolder.getValue().intValue());
    assertEquals(1, execToggleHolder.getValue().intValue());
    assertTrue(b.isSelected());
    b.getUIFacade().setSelectedFromUI(false);
    b.getUIFacade().fireActionFromUI();
    assertEquals(3, execActionHolder.getValue().intValue());
    assertEquals(2, execToggleHolder.getValue().intValue());
    assertFalse(b.isSelected());
}
Also used : IntegerHolder(org.eclipse.scout.rt.platform.holders.IntegerHolder) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) AbstractOutlineViewButton(org.eclipse.scout.rt.client.ui.desktop.outline.AbstractOutlineViewButton) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) Test(org.junit.Test)

Aggregations

IDesktop (org.eclipse.scout.rt.client.ui.desktop.IDesktop)1 AbstractOutlineViewButton (org.eclipse.scout.rt.client.ui.desktop.outline.AbstractOutlineViewButton)1 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)1 IntegerHolder (org.eclipse.scout.rt.platform.holders.IntegerHolder)1 Test (org.junit.Test)1