Search in sources :

Example 61 with NativeEvent

use of com.google.gwt.dom.client.NativeEvent in project kie-wb-common by kiegroup.

the class DataTypeConstraintEnumerationItemViewTest method testGetEventTarget.

@Test
public void testGetEventTarget() {
    final BlurEvent blurEvent = mock(BlurEvent.class);
    final NativeEvent nativeEvent = mock(NativeEvent.class);
    final EventTarget expectedTarget = mock(EventTarget.class);
    when(blurEvent.getNativeEvent()).thenReturn(nativeEvent);
    when(nativeEvent.getRelatedEventTarget()).thenReturn(expectedTarget);
    final Object actualTarget = view.getEventTarget(blurEvent);
    assertEquals(expectedTarget, actualTarget);
}
Also used : BlurEvent(com.google.gwt.event.dom.client.BlurEvent) EventTarget(com.google.gwt.dom.client.EventTarget) NativeEvent(com.google.gwt.dom.client.NativeEvent) Test(org.junit.Test)

Example 62 with NativeEvent

use of com.google.gwt.dom.client.NativeEvent in project kie-wb-common by kiegroup.

the class MonacoEditorDOMElementTest method testGetWidgetTrigger.

@Test
public void testGetWidgetTrigger() {
    final NativeEvent triggeredBlur = mock(NativeEvent.class);
    final NativeEvent monacoBlur = mock(NativeEvent.class);
    domElement.getWidgetTrigger(triggeredBlur).call(monacoBlur);
    verify(domElement).fireNativeEvent(triggeredBlur, widget);
}
Also used : NativeEvent(com.google.gwt.dom.client.NativeEvent) Test(org.junit.Test)

Example 63 with NativeEvent

use of com.google.gwt.dom.client.NativeEvent in project kie-wb-common by kiegroup.

the class MonacoEditorDOMElementTest method testGetOnKeyDownWhenSuggestWidgetIsVisibleAndKeyCodeIsNotEsc.

@Test
public void testGetOnKeyDownWhenSuggestWidgetIsVisibleAndKeyCodeIsNotEsc() {
    final MonacoStandaloneCodeEditor codeEditor = mock(MonacoStandaloneCodeEditor.class);
    final NativeEvent event = mock(NativeEvent.class);
    when(event.getKeyCode()).thenReturn(10);
    when(codeEditor.isSuggestWidgetVisible()).thenReturn(true);
    domElement.getOnKeyDown(codeEditor).call(event);
    verify(codeEditor, never()).trigger("keyboard", "cursorHome");
    verify(codeEditor, never()).trigger("keyboard", "cursorEnd");
    verify(event, never()).stopPropagation();
    verify(event, never()).preventDefault();
}
Also used : MonacoStandaloneCodeEditor(org.uberfire.client.views.pfly.monaco.jsinterop.MonacoStandaloneCodeEditor) NativeEvent(com.google.gwt.dom.client.NativeEvent) Test(org.junit.Test)

Example 64 with NativeEvent

use of com.google.gwt.dom.client.NativeEvent in project kie-wb-common by kiegroup.

the class MonacoEditorDOMElementTest method testSetupInternalComponent.

@Test
public void testSetupInternalComponent() {
    final Element element = mock(Element.class);
    final Style style = mock(Style.class);
    final elemental2.dom.Element mockedElement = mock(elemental2.dom.Element.class);
    final MonacoPropertiesFactory properties = mock(MonacoPropertiesFactory.class);
    final JavaScriptObject constructionOptions = mock(JavaScriptObject.class);
    final MonacoEditor editor = mock(MonacoEditor.class);
    final MonacoStandaloneCodeEditor standaloneCodeEditor = mock(MonacoStandaloneCodeEditor.class);
    final com.google.gwt.user.client.Element gwtElement = mock(com.google.gwt.user.client.Element.class);
    final MonacoStandaloneCodeEditor.CallbackFunction onKeyDown = mock(MonacoStandaloneCodeEditor.CallbackFunction.class);
    final MonacoStandaloneCodeEditor.CallbackFunction widgetTrigger = mock(MonacoStandaloneCodeEditor.CallbackFunction.class);
    final NativeEvent blurEvent = mock(NativeEvent.class);
    when(widget.getElement()).thenReturn(element);
    when(element.getStyle()).thenReturn(style);
    when(domElement.uncheckedCast(any())).thenReturn(mockedElement);
    when(properties.getConstructionOptions()).thenReturn(constructionOptions);
    doReturn(onKeyDown).when(domElement).getOnKeyDown(standaloneCodeEditor);
    doReturn(widgetTrigger).when(domElement).getWidgetTrigger(blurEvent);
    doReturn(blurEvent).when(domElement).getBlurEvent();
    doReturn(properties).when(domElement).makeMonacoPropertiesFactory();
    doReturn(editor).when(domElement).getMonacoEditor();
    doReturn(standaloneCodeEditor).when(editor).create(mockedElement, constructionOptions);
    domElement.setupInternalComponent();
    verify(style).setWidth(100, PCT);
    verify(style).setHeight(100, PCT);
    verify(standaloneCodeEditor).onKeyDown(onKeyDown);
    verify(standaloneCodeEditor).onDidBlurEditorWidget(widgetTrigger);
    verify(widget).setCodeEditor(standaloneCodeEditor);
    verify(widget).setFocus(true);
}
Also used : MonacoEditor(org.uberfire.client.views.pfly.monaco.jsinterop.MonacoEditor) Element(com.google.gwt.user.client.Element) Element(com.google.gwt.user.client.Element) MonacoStandaloneCodeEditor(org.uberfire.client.views.pfly.monaco.jsinterop.MonacoStandaloneCodeEditor) MonacoPropertiesFactory(org.kie.workbench.common.dmn.client.widgets.codecompletion.MonacoPropertiesFactory) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) Style(com.google.gwt.dom.client.Style) NativeEvent(com.google.gwt.dom.client.NativeEvent) Test(org.junit.Test)

Example 65 with NativeEvent

use of com.google.gwt.dom.client.NativeEvent in project kie-wb-common by kiegroup.

the class MonacoEditorDOMElementTest method testGetOnKeyDownWhenSuggestWidgetIsNotVisibleAndKeyCodeIsEsc.

@Test
public void testGetOnKeyDownWhenSuggestWidgetIsNotVisibleAndKeyCodeIsEsc() {
    final MonacoStandaloneCodeEditor codeEditor = mock(MonacoStandaloneCodeEditor.class);
    final NativeEvent event = mock(NativeEvent.class);
    when(event.getKeyCode()).thenReturn(9);
    when(codeEditor.isSuggestWidgetVisible()).thenReturn(false);
    domElement.getOnKeyDown(codeEditor).call(event);
    verify(codeEditor, never()).trigger("keyboard", "cursorHome");
    verify(codeEditor, never()).trigger("keyboard", "cursorEnd");
    verify(event, never()).stopPropagation();
    verify(event, never()).preventDefault();
}
Also used : MonacoStandaloneCodeEditor(org.uberfire.client.views.pfly.monaco.jsinterop.MonacoStandaloneCodeEditor) NativeEvent(com.google.gwt.dom.client.NativeEvent) Test(org.junit.Test)

Aggregations

NativeEvent (com.google.gwt.dom.client.NativeEvent)72 Element (com.google.gwt.dom.client.Element)20 Test (org.junit.Test)12 Column (com.google.gwt.user.cellview.client.Column)8 ValueUpdater (com.google.gwt.cell.client.ValueUpdater)6 EventTarget (com.google.gwt.dom.client.EventTarget)6 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)5 MonacoStandaloneCodeEditor (org.uberfire.client.views.pfly.monaco.jsinterop.MonacoStandaloneCodeEditor)5 AbstractCell (com.google.gwt.cell.client.AbstractCell)4 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)4 Context (com.google.gwt.cell.client.Cell.Context)3 JsArrayString (com.google.gwt.core.client.JsArrayString)3 Scheduler (com.google.gwt.core.client.Scheduler)3 Style (com.google.gwt.dom.client.Style)3 TableRowElement (com.google.gwt.dom.client.TableRowElement)3 BlurEvent (com.google.gwt.event.dom.client.BlurEvent)3 Widget (com.google.gwt.user.client.ui.Widget)3 HTMLButtonElement (elemental2.dom.HTMLButtonElement)3 Button (org.gwtbootstrap3.client.ui.Button)3 Icon (org.gwtbootstrap3.client.ui.Icon)3