Search in sources :

Example 1 with OutlineViewButton

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);
}
Also used : OutlineWithOneNode(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineWithOneNode) IOutlineViewButton(org.eclipse.scout.rt.client.ui.desktop.outline.IOutlineViewButton) OutlineViewButton(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineViewButton) IOutlineViewButton(org.eclipse.scout.rt.client.ui.desktop.outline.IOutlineViewButton) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) Test(org.junit.Test)

Example 2 with OutlineViewButton

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);
}
Also used : OutlineWithOneNode(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineWithOneNode) IOutlineViewButton(org.eclipse.scout.rt.client.ui.desktop.outline.IOutlineViewButton) OutlineViewButton(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineViewButton) IOutlineViewButton(org.eclipse.scout.rt.client.ui.desktop.outline.IOutlineViewButton) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) Test(org.junit.Test)

Example 3 with OutlineViewButton

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);
}
Also used : OutlineWithOneNode(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineWithOneNode) IOutlineViewButton(org.eclipse.scout.rt.client.ui.desktop.outline.IOutlineViewButton) OutlineViewButton(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineViewButton) JsonEvent(org.eclipse.scout.rt.ui.html.json.JsonEvent) IOutlineViewButton(org.eclipse.scout.rt.client.ui.desktop.outline.IOutlineViewButton) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) Test(org.junit.Test)

Aggregations

IDesktop (org.eclipse.scout.rt.client.ui.desktop.IDesktop)3 IOutlineViewButton (org.eclipse.scout.rt.client.ui.desktop.outline.IOutlineViewButton)3 OutlineViewButton (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineViewButton)3 OutlineWithOneNode (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineWithOneNode)3 Test (org.junit.Test)3 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)1