use of org.eclipse.scout.rt.client.ui.desktop.outline.pages.AbstractPageWithNodes in project scout.rt by eclipse.
the class JsonOutlineTest method testNoEventsFiredOnChildPageCreation.
/**
* Tests that no events are fired during page initialization
*/
@Test
public void testNoEventsFiredOnChildPageCreation() throws JSONException {
final Holder<Integer> initPageCounter = new Holder<>(Integer.class);
initPageCounter.setValue(0);
// Build an outline with two nodes, where the second node has a child node
IPage page1 = new AbstractPageWithNodes() {
};
IPage page2 = new AbstractPageWithNodes() {
@Override
protected void execCreateChildPages(List<IPage<?>> pageList) {
pageList.add(new AbstractPageWithNodes() {
@Override
protected void execInitPage() {
// Change some properties (this would normally fire events, but we are inside execInitPage())
setLeaf(!isLeaf());
getCellForUpdate().setText("Test");
initPageCounter.setValue(initPageCounter.getValue() + 1);
}
});
super.execCreateChildPages(pageList);
}
};
List<IPage<?>> pages = new ArrayList<IPage<?>>();
pages.add(page2);
IOutline outline = new Outline(pages);
outline.selectNode(page1);
// Outline to JsonOutline
JsonOutline<IOutline> jsonOutline = UiSessionTestUtility.newJsonAdapter(m_uiSession, outline, m_uiSession.getRootJsonAdapter());
// simulate "send to client"
jsonOutline.toJson();
Assert.assertEquals(0, initPageCounter.getValue().intValue());
// Simulate "select page2" event
JsonEvent event = createNodeSelectionEvent(jsonOutline, page2);
jsonOutline.handleUiEvent(event);
assertEquals(1, initPageCounter.getValue().intValue());
// Get all events for the outline (ignore table events)
List<JsonEvent> responseEvents = JsonTestUtility.extractEventsFromResponse(m_uiSession.currentJsonResponse(), null, jsonOutline.getId());
// Check that we got only two events: page-changed (because the table was created), node insertion
assertEquals(2, responseEvents.size());
assertEquals("pageChanged", responseEvents.get(0).getType());
assertEquals(JsonTree.EVENT_NODES_INSERTED, responseEvents.get(1).getType());
}
Aggregations