use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineViewButton in project scout.rt by eclipse.
the class JsonOutlineViewButtonTest method testLazyLoadingOutline_onModelSelectionChanged.
@Test
public void testLazyLoadingOutline_onModelSelectionChanged() throws JSONException {
OutlineWithOneNode outline = new OutlineWithOneNode();
IDesktop desktop = Mockito.mock(IDesktop.class);
Mockito.when(desktop.getAvailableOutlines()).thenReturn(Collections.<IOutline>singletonList(outline));
IOutlineViewButton button = new OutlineViewButton(desktop, outline.getClass());
JsonOutlineViewButton<IOutlineViewButton> jsonViewButton = UiSessionTestUtility.newJsonAdapter(m_uiSession, button, null);
assertNull(jsonViewButton.getAdapter(outline));
button.setSelected(true);
IJsonAdapter<?> outlineAdapter = jsonViewButton.getAdapter(outline);
assertNotNull(outlineAdapter);
String outlineId = JsonTestUtility.extractProperty(m_uiSession.currentJsonResponse(), jsonViewButton.getId(), "outline");
assertEquals(outlineAdapter.getId(), outlineId);
}
use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineViewButton in project scout.rt by eclipse.
the class JsonOutlineViewButtonTest method testNonLazyLoadingOutlineWhenSelected.
@Test
public void testNonLazyLoadingOutlineWhenSelected() throws JSONException {
OutlineWithOneNode outline = new OutlineWithOneNode();
IDesktop desktop = Mockito.mock(IDesktop.class);
Mockito.when(desktop.getAvailableOutlines()).thenReturn(Collections.<IOutline>singletonList(outline));
IOutlineViewButton button = new OutlineViewButton(desktop, outline.getClass());
button.setSelected(true);
JsonOutlineViewButton<IOutlineViewButton> jsonViewButton = UiSessionTestUtility.newJsonAdapter(m_uiSession, button, null);
IJsonAdapter<?> outlineAdapter = jsonViewButton.getAdapter(outline);
assertNotNull(outlineAdapter);
// Expects outlineId is sent along with the button and not with a separate property change event
String outlineId = JsonTestUtility.extractProperty(m_uiSession.currentJsonResponse(), jsonViewButton.getId(), "outline");
assertNull(outlineId);
}
use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineViewButton in project scout.rt by eclipse.
the class JsonOutlineViewButtonTest method testLazyLoadingOutline_onUiSelectionChanged.
@Test
public void testLazyLoadingOutline_onUiSelectionChanged() throws Exception {
OutlineWithOneNode outline = new OutlineWithOneNode();
IDesktop desktop = Mockito.mock(IDesktop.class);
Mockito.when(desktop.getAvailableOutlines()).thenReturn(Collections.<IOutline>singletonList(outline));
IOutlineViewButton button = new OutlineViewButton(desktop, outline.getClass());
JsonOutlineViewButton<IOutlineViewButton> jsonViewButton = UiSessionTestUtility.newJsonAdapter(m_uiSession, button, null);
assertNull(jsonViewButton.getAdapter(outline));
JsonEvent event = createJsonActionEvent(jsonViewButton.getId());
assertEquals("action", event.getType());
jsonViewButton.handleUiEvent(event);
// Outline needs to be created and sent if selection changes to true
IJsonAdapter<?> outlineAdapter = jsonViewButton.getAdapter(outline);
assertNotNull(outlineAdapter);
String outlineId = JsonTestUtility.extractProperty(m_uiSession.currentJsonResponse(), jsonViewButton.getId(), "outline");
assertEquals(outlineAdapter.getId(), outlineId);
}
Aggregations