@Test public void testOnKeyUp_Case2() { unitUnderTest = new SearchFieldDecorator<>(textFieldMock, delayedTaskMock); KeyUpEvent mockEvent = mock(KeyUpEvent.class); when(mockEvent.getNativeKeyCode()).thenReturn(KeyCodes.KEY_DOWN); unitUnderTest.onKeyUp(mockEvent); verifyZeroInteractions(delayedTaskMock); }
@Override public void onKeyUp(KeyUpEvent event) { boolean isModifierKey = false; switch (event.getNativeKeyCode()) { case KeyCodes.KEY_ENTER: case KeyCodes.KEY_ALT: case KeyCodes.KEY_CTRL: case KeyCodes.KEY_END: case KeyCodes.KEY_ESCAPE: case KeyCodes.KEY_HOME: case KeyCodes.KEY_PAGEDOWN: case KeyCodes.KEY_PAGEUP: case KeyCodes.KEY_SHIFT: case KeyCodes.KEY_TAB: isModifierKey = true; return; default: isModifierKey = KeyCodeEvent.isArrow(event.getNativeKeyCode()); } if (!isModifierKey) { task.delay(queryDelay); } }
SearchFieldDecorator implements HasSubmitTextSearchEvents, KeyUpHandler, HasHandlers { @Override public void onKeyUp(KeyUpEvent event) { boolean isModifierKey = false; switch (event.getNativeKeyCode()) { case KeyCodes.KEY_ENTER: case KeyCodes.KEY_ALT: case KeyCodes.KEY_CTRL: case KeyCodes.KEY_END: case KeyCodes.KEY_ESCAPE: case KeyCodes.KEY_HOME: case KeyCodes.KEY_PAGEDOWN: case KeyCodes.KEY_PAGEUP: case KeyCodes.KEY_SHIFT: case KeyCodes.KEY_TAB: isModifierKey = true; return; default: isModifierKey = KeyCodeEvent.isArrow(event.getNativeKeyCode()); } if (!isModifierKey) { task.delay(queryDelay); } } }
SearchFieldDecorator implements HasSubmitTextSearchEvents, KeyUpHandler, HasHandlers { @Override public void onKeyUp(KeyUpEvent event) { boolean isModifierKey = false; switch (event.getNativeKeyCode()) { case KeyCodes.KEY_ENTER: case KeyCodes.KEY_ALT: case KeyCodes.KEY_CTRL: case KeyCodes.KEY_END: case KeyCodes.KEY_ESCAPE: case KeyCodes.KEY_HOME: case KeyCodes.KEY_PAGEDOWN: case KeyCodes.KEY_PAGEUP: case KeyCodes.KEY_SHIFT: case KeyCodes.KEY_TAB: isModifierKey = true; return; default: isModifierKey = KeyCodeEvent.isArrow(event.getNativeKeyCode()); } if (!isModifierKey) { task.delay(queryDelay); } } SearchFieldDecorator(final F searchField);   SearchFieldDecorator(final F searchField, final SearchFieldDelayedTask task); }
SearchFieldDecorator implements HasSubmitTextSearchEvents, KeyUpHandler, HasHandlers { @Override public void onKeyUp(KeyUpEvent event) { boolean isModifierKey = false; switch (event.getNativeKeyCode()) { case KeyCodes.KEY_ENTER: case KeyCodes.KEY_ALT: case KeyCodes.KEY_CTRL: case KeyCodes.KEY_END: case KeyCodes.KEY_ESCAPE: case KeyCodes.KEY_HOME: case KeyCodes.KEY_PAGEDOWN: case KeyCodes.KEY_PAGEUP: case KeyCodes.KEY_SHIFT: case KeyCodes.KEY_TAB: isModifierKey = true; return; default: isModifierKey = KeyCodeEvent.isArrow(event.getNativeKeyCode()); } if (!isModifierKey) { task.delay(queryDelay); } } SearchFieldDecorator(final F searchField);   SearchFieldDecorator(final F searchField, final SearchFieldDelayedTask task); @Override HandlerRegistration addSubmitTextSearchEventHandler(SubmitTextSearchEventHandler handler); @Override void fireEvent(GwtEvent<?> event); @Override void onKeyUp(KeyUpEvent event); }
SearchFieldDecorator implements HasSubmitTextSearchEvents, KeyUpHandler, HasHandlers { @Override public void onKeyUp(KeyUpEvent event) { boolean isModifierKey = false; switch (event.getNativeKeyCode()) { case KeyCodes.KEY_ENTER: case KeyCodes.KEY_ALT: case KeyCodes.KEY_CTRL: case KeyCodes.KEY_END: case KeyCodes.KEY_ESCAPE: case KeyCodes.KEY_HOME: case KeyCodes.KEY_PAGEDOWN: case KeyCodes.KEY_PAGEUP: case KeyCodes.KEY_SHIFT: case KeyCodes.KEY_TAB: isModifierKey = true; return; default: isModifierKey = KeyCodeEvent.isArrow(event.getNativeKeyCode()); } if (!isModifierKey) { task.delay(queryDelay); } } SearchFieldDecorator(final F searchField);   SearchFieldDecorator(final F searchField, final SearchFieldDelayedTask task); @Override HandlerRegistration addSubmitTextSearchEventHandler(SubmitTextSearchEventHandler handler); @Override void fireEvent(GwtEvent<?> event); @Override void onKeyUp(KeyUpEvent event);  }