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());
}
Aggregations