Search in sources :

Example 1 with OutlineWithOneNode

use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineWithOneNode in project scout.rt by eclipse.

the class JsonOutlineTest method testDispose.

@Test
public void testDispose() {
    ITree tree = new OutlineWithOneNode();
    JsonTree<ITree> object = UiSessionTestUtility.newJsonAdapter(m_uiSession, tree, null);
    WeakReference<JsonTree> ref = new WeakReference<JsonTree>(object);
    object.dispose();
    m_uiSession = null;
    object = null;
    TestingUtility.assertGC(ref);
}
Also used : OutlineWithOneNode(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineWithOneNode) JsonTree(org.eclipse.scout.rt.ui.html.json.tree.JsonTree) WeakReference(java.lang.ref.WeakReference) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) JsonTreeTest(org.eclipse.scout.rt.ui.html.json.tree.JsonTreeTest) Test(org.junit.Test)

Example 2 with OutlineWithOneNode

use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineWithOneNode 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 3 with OutlineWithOneNode

use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineWithOneNode 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 4 with OutlineWithOneNode

use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineWithOneNode 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

OutlineWithOneNode (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineWithOneNode)4 Test (org.junit.Test)4 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 WeakReference (java.lang.ref.WeakReference)1 ITree (org.eclipse.scout.rt.client.ui.basic.tree.ITree)1 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)1 JsonTree (org.eclipse.scout.rt.ui.html.json.tree.JsonTree)1 JsonTreeTest (org.eclipse.scout.rt.ui.html.json.tree.JsonTreeTest)1