@Test public void testKeyDownEvent_doesNotTriggerHandleAcceleratorActivation_withoutAccelerator() { when(Boolean.valueOf(menuItem.isEnabled())).thenReturn(Boolean.TRUE); display.sendEvent(SWT.KeyDown, mockKeyDownEvent(SWT.ALT, 'A')); verify(menuItem, times(0)).handleAcceleratorActivation(); }
@Test public void testKeyDownEvent_doesNotTriggerHandleAcceleratorActivation_onDisabledItem() { acceleratorSupport.setAccelerator(SWT.ALT | 'A'); display.sendEvent(SWT.KeyDown, mockKeyDownEvent(SWT.ALT, 'A')); verify(menuItem, times(0)).handleAcceleratorActivation(); }
@Test public void testKeyDownEvent_doesNotTriggerHandleAcceleratorActivation_withDifferentModifier() { acceleratorSupport.setAccelerator(SWT.ALT | 'A'); when(Boolean.valueOf(menuItem.isEnabled())).thenReturn(Boolean.TRUE); display.sendEvent(SWT.KeyDown, mockKeyDownEvent(SWT.CTRL, 'A')); verify(menuItem, times(0)).handleAcceleratorActivation(); }
@Test public void testKeyDownEvent_triggersHandleAcceleratorActivation_withSmallLetterInAccelerator() { acceleratorSupport.setAccelerator(SWT.ALT | 'a'); when(Boolean.valueOf(menuItem.isEnabled())).thenReturn(Boolean.TRUE); display.sendEvent(SWT.KeyDown, mockKeyDownEvent(SWT.ALT, 'A')); verify(menuItem).handleAcceleratorActivation(); }
@Test public void testAcceleratorFilter_filtersKeyDownEvent() { acceleratorSupport.setAccelerator(SWT.ALT | 'A'); when(Boolean.valueOf(menuItem.isEnabled())).thenReturn(Boolean.TRUE); Event keyEvent = mockKeyDownEvent(SWT.ALT, 'A'); display.sendEvent(SWT.KeyDown, keyEvent); assertEquals(SWT.None, keyEvent.type); }