use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class MenuBuilderIntegrationTest method createsToolbarButtonWithAction.
@Test
public void createsToolbarButtonWithAction() {
String content = "<FreeplaneUIEntries>" + "<Entry name='home' builder='toolbar'>" + "<Entry name='action'/>" + "</Entry>" + "</FreeplaneUIEntries>";
final AFreeplaneAction someAction = Mockito.mock(AFreeplaneAction.class);
when(freeplaneActions.getAction("action")).thenReturn(someAction);
Entry builtMenuStructure = buildJMenu(content);
assertThat(((JButton) new EntryAccessor().getComponent(builtMenuStructure.getChild(0).getChild(0))).getAction(), CoreMatchers.<Action>equalTo(someAction));
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class MenuBuilderIntegrationTest method givengroupWithAction_addsActionButtonToToolbar.
@Test
public void givengroupWithAction_addsActionButtonToToolbar() {
String content = "<FreeplaneUIEntries>" + "<Entry name='home' builder='toolbar'>" + "<Entry name='action'/>" + "</Entry>" + "</FreeplaneUIEntries>";
final AFreeplaneAction someAction = Mockito.mock(AFreeplaneAction.class);
when(freeplaneActions.getAction("action")).thenReturn(someAction);
Entry builtMenuStructure = buildJMenu(content);
final JToolBar toolbar = (JToolBar) new EntryAccessor().getComponent(builtMenuStructure.getChild(0));
final JButton button = (JButton) new EntryAccessor().getComponent(builtMenuStructure.getChild(0).getChild(0));
assertThat(button.getParent(), CoreMatchers.equalTo((Container) toolbar));
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class AcceleratorBuilderTest method registersEntryWithAction.
@Test
public void registersEntryWithAction() {
Entry actionEntry = new Entry();
final AFreeplaneAction action = mock(AFreeplaneAction.class);
new EntryAccessor().setAction(actionEntry, action);
IAcceleratorMap map = mock(IAcceleratorMap.class);
IEntriesForAction entries = mock(IEntriesForAction.class);
final AcceleratorBuilder acceleratorBuilder = new AcceleratorBuilder(map, entries);
acceleratorBuilder.visit(actionEntry);
Mockito.verify(entries).registerEntry(action, actionEntry);
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class AcceleratorBuilderTest method givenEntryWithoutAccelerator_setsUserDefinedAccelerator.
@Test
public void givenEntryWithoutAccelerator_setsUserDefinedAccelerator() {
Entry actionEntry = new Entry();
final AFreeplaneAction action = mock(AFreeplaneAction.class);
new EntryAccessor().setAction(actionEntry, action);
IAcceleratorMap map = mock(IAcceleratorMap.class);
final AcceleratorBuilder acceleratorBuilder = new AcceleratorBuilder(map, mock(IEntriesForAction.class));
acceleratorBuilder.visit(actionEntry);
Mockito.verify(map).setUserDefinedAccelerator(action);
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class AcceleratorDestroyerTest method unregistersEntryWithAction.
@Test
public void unregistersEntryWithAction() {
Entry actionEntry = new Entry();
final AFreeplaneAction action = mock(AFreeplaneAction.class);
new EntryAccessor().setAction(actionEntry, action);
IEntriesForAction entries = mock(IEntriesForAction.class);
final AcceleratorDestroyer acceleratorDestroyer = new AcceleratorDestroyer(entries);
acceleratorDestroyer.visit(actionEntry);
Mockito.verify(entries).unregisterEntry(action, actionEntry);
}
Aggregations