use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class AcceleratorBuilderTest method setsDefaultAcceleratorForAction.
@Test
public void setsDefaultAcceleratorForAction() {
Entry actionEntry = new Entry();
String actionKey = "actionKey";
actionEntry.setName(actionKey);
String keyStroke = KeyStroke.getKeyStroke('A', InputEvent.CTRL_MASK).toString();
actionEntry.setAttribute("accelerator", keyStroke);
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).setDefaultAccelerator(action, keyStroke);
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class AcceleratorBuilderTest method givenEntryWithoutAccelerator_doesNotSetOwnDefaultAccelerator.
@Test
public void givenEntryWithoutAccelerator_doesNotSetOwnDefaultAccelerator() {
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, never()).setDefaultAccelerator(Mockito.<AFreeplaneAction>any(), anyString());
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class ActionFinderTest method attachesExistingFreeplaneAction.
@Test
public void attachesExistingFreeplaneAction() {
FreeplaneActions freeplaneActions = mock(FreeplaneActions.class);
Entry entry = new Entry();
entry.setName("action");
final AFreeplaneAction someAction = Mockito.mock(AFreeplaneAction.class);
when(freeplaneActions.getAction("action")).thenReturn(someAction);
final ActionFinder actionFinder = new ActionFinder(freeplaneActions);
actionFinder.visit(entry);
assertThat((AFreeplaneAction) new EntryAccessor().getAction(entry), CoreMatchers.equalTo(someAction));
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class ActionSelectListenerTest method activatesSelectOnPopup_forCheckSelectionOnPopup.
@Test
public void activatesSelectOnPopup_forCheckSelectionOnPopup() {
Entry menuEntry = new Entry();
Entry actionEntry = new Entry();
menuEntry.addChild(actionEntry);
final AFreeplaneAction someAction = Mockito.mock(AFreeplaneAction.class);
when(someAction.checkSelectionOnPopup()).thenReturn(true);
when(someAction.isEnabled()).thenReturn(true);
new EntryAccessor().setAction(actionEntry, someAction);
final EntryPopupListenerCollection entryPopupListenerCollection = new EntryPopupListenerCollection();
final ActionSelectListener actionSelectListener = new ActionSelectListener();
entryPopupListenerCollection.addEntryPopupListener(actionSelectListener);
entryPopupListenerCollection.childEntriesWillBecomeVisible(menuEntry);
verify(someAction).setSelected();
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class ComponentBuilderTest method testName.
@Test
public void testName() throws Exception {
final Entry entry = new Entry();
final Component testComponent = new JPanel();
final ComponentBuilder builder = new ComponentBuilder(new ComponentProvider() {
@Override
public Component createComponent(Entry entry) {
return testComponent;
}
});
builder.visit(entry);
Assert.assertThat(new EntryAccessor().getComponent(entry), CoreMatchers.<Object>equalTo(testComponent));
}
Aggregations