コード例 #1
0
  @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();
  }
コード例 #2
0
  @Test
  public void testKeyDownEvent_doesNotTriggerHandleAcceleratorActivation_onDisabledItem() {
    acceleratorSupport.setAccelerator(SWT.ALT | 'A');

    display.sendEvent(SWT.KeyDown, mockKeyDownEvent(SWT.ALT, 'A'));

    verify(menuItem, times(0)).handleAcceleratorActivation();
  }
コード例 #3
0
  @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();
  }
コード例 #4
0
  @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();
  }
コード例 #5
0
  @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);
  }