Java 类com.google.gwt.event.dom.client.DragDropEventBase 实例源码

项目:empiria.player    文件:SourceListViewImplTest.java   
@Test
public void testOnDragEventDragStart() throws Exception {
    // given
    String itemContent = "itemContent";
    String itemId = "item";
    SourceListPresenter sourceListPresenter = mock(SourceListPresenter.class);
    String json = "{}";
    DragDataObject dataObject = mock(DragDataObject.class);
    doReturn(json).when(dataObject).toJSON();
    when(sourceListPresenter.getDragDataObject(anyString())).thenReturn(dataObject);
    DragDropEventBase event = mock(DragDropEventBase.class);

    // when
    testObj.createItem(new SourcelistItemValue(SourcelistItemType.TEXT, itemContent, itemId), inlineBodyGeneratorSocket);
    testObj.setSourceListPresenter(sourceListPresenter);
    testObj.onDragEvent(DragDropEventTypes.DRAG_START, viewItem, event);

    // then
    verify(event).setData(eq("json"), eq(json));
    verify(sourceListPresenter).onDragEvent(eq(DragDropEventTypes.DRAG_START), eq(itemId));

}
项目:empiria.player    文件:SourceListViewImplTest.java   
@Test
public void shouldNotSetData_whenNotDragStartEvent() throws Exception {
    // given
    String itemContent = "itemContent";
    String itemId = "item";
    DragDropEventBase event = mock(DragDropEventBase.class);

    // when
    testObj.createItem(new SourcelistItemValue(SourcelistItemType.TEXT, itemContent, itemId), inlineBodyGeneratorSocket);
    testObj.setSourceListPresenter(sourceListPresenter);
    testObj.onDragEvent(DragDropEventTypes.DRAG_CANCEL, viewItem, event);

    // then
    verify(event, never()).setData(eq("json"), anyString());
    verify(sourceListPresenter).onDragEvent(eq(DragDropEventTypes.DRAG_CANCEL), eq(itemId));

}
项目:empiria.player    文件:SourceListViewImpl.java   
public void onDragEvent(DragDropEventTypes dropEventType, SourceListViewItem item, DragDropEventBase<?> dragEvent) {
    String itemId = itemIdToItemCollection.inverse().get(item);
    if (dropEventType == DragDropEventTypes.DRAG_START) {
        setDataOnNativeEvent(dragEvent, itemId);
    }
    sourceListPresenter.onDragEvent(dropEventType, itemId);
}
项目:empiria.player    文件:SourceListViewImpl.java   
private void setDataOnNativeEvent(DragDropEventBase<?> dragEvent, String itemId) {
    DragDataObject dataObject = sourceListPresenter.getDragDataObject(itemId);
    dragEvent.setData("json", dataObject.toJSON());
}