use of org.eclipse.che.ide.api.event.SelectionChangedHandler in project che by eclipse.
the class TestSelectionAgent method shouldFireEventWhenSelectionInActivePartChanged.
/**
* If selection chang in active part, Selection Agent should fire
* an Event
*/
@Test
public void shouldFireEventWhenSelectionInActivePartChanged() {
AbstractPartPresenter part = new AbstractPartPresenter() {
@Override
public void go(AcceptsOneWidget container) {
}
@Override
public String getTitleToolTip() {
return null;
}
@Override
public SVGResource getTitleImage() {
return null;
}
@Override
public String getTitle() {
return null;
}
@Override
public IsWidget getView() {
return null;
}
};
// fire event, for agent to get information about active part
eventBus.fireEvent(new ActivePartChangedEvent(part));
SelectionChangedHandler handler = mock(SelectionChangedHandler.class);
eventBus.addHandler(SelectionChangedEvent.TYPE, handler);
part.setSelection(mock(Selection.class));
verify(handler).onSelectionChanged((SelectionChangedEvent) any());
}
use of org.eclipse.che.ide.api.event.SelectionChangedHandler in project che by eclipse.
the class TestSelectionAgent method shouldNOTFireEventWhenSelectionInNONActivePartChanged.
/**
* If selection chang in non-active part, no events should be fired by
* Selection Agent
*/
@Test
public void shouldNOTFireEventWhenSelectionInNONActivePartChanged() {
AbstractPartPresenter firstPart = new AbstractPartPresenter() {
@Override
public void go(AcceptsOneWidget container) {
}
@Override
public String getTitleToolTip() {
return null;
}
@Override
public SVGResource getTitleImage() {
return null;
}
@Override
public String getTitle() {
return null;
}
@Override
public IsWidget getView() {
return null;
}
};
// fire event, for agent to get information about active part
eventBus.fireEvent(new ActivePartChangedEvent(firstPart));
// change part
eventBus.fireEvent(new ActivePartChangedEvent(mock(PartPresenter.class)));
SelectionChangedHandler handler = mock(SelectionChangedHandler.class);
eventBus.addHandler(SelectionChangedEvent.TYPE, handler);
// call setSelection on the first Part.
firstPart.setSelection(mock(Selection.class));
verifyZeroInteractions(handler);
}
use of org.eclipse.che.ide.api.event.SelectionChangedHandler in project che by eclipse.
the class TestSelectionAgent method shouldFireEventWhenPartChanged.
/** Event should be fired, when active part changed */
@Test
public void shouldFireEventWhenPartChanged() {
when(part.getSelection()).thenReturn(selection);
SelectionChangedHandler handler = mock(SelectionChangedHandler.class);
eventBus.addHandler(SelectionChangedEvent.TYPE, handler);
// fire event, for agent to get information about active part
eventBus.fireEvent(new ActivePartChangedEvent(part));
verify(handler).onSelectionChanged((SelectionChangedEvent) any());
}
Aggregations