use of org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu.NonDisplayableMenu in project scout.rt by eclipse.
the class JsonTableTest method testMenuDisposalOnPropertyChangeWithNonDisplayableMenu.
/**
* Tests whether it is possible to dispose (or replace) menus if at least one menu is not displayable.<br>
*/
@Test
public void testMenuDisposalOnPropertyChangeWithNonDisplayableMenu() throws JSONException {
ITable table = new TableWithNonDisplayableMenu();
table.initTable();
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
jsonTable.toJson();
// ----------
DisplayableMenu displayableMenu = table.getMenuByClass(TableWithNonDisplayableMenu.DisplayableMenu.class);
NonDisplayableMenu NonDisplayableMenu = table.getMenuByClass(TableWithNonDisplayableMenu.NonDisplayableMenu.class);
assertNull(jsonTable.getAdapter(NonDisplayableMenu));
assertNotNull(jsonTable.getAdapter(displayableMenu));
assertTrue(jsonTable.getAdapter(displayableMenu).isInitialized());
table.getContextMenu().removeChildAction(NonDisplayableMenu);
table.getContextMenu().removeChildAction(displayableMenu);
assertNull(jsonTable.getAdapter(NonDisplayableMenu));
assertNull(jsonTable.getAdapter(displayableMenu));
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu.NonDisplayableMenu in project scout.rt by eclipse.
the class JsonTableTest method testDontSendNonDisplayableMenus.
/**
* Tests whether non displayable menus are sent.
* <p>
* This reduces response size and also leverages security because the menus are never visible to the user, not even
* with the dev tools of the browser
*/
@Test
public void testDontSendNonDisplayableMenus() throws Exception {
TableWithNonDisplayableMenu table = new TableWithNonDisplayableMenu();
table.initTable();
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
jsonTable.toJson();
// ----------
JsonMenu<IMenu> jsonDisplayableMenu = jsonTable.getAdapter(table.getMenuByClass(TableWithNonDisplayableMenu.DisplayableMenu.class));
JsonMenu<IMenu> jsonNonDisplayableMenu = jsonTable.getAdapter(table.getMenuByClass(TableWithNonDisplayableMenu.NonDisplayableMenu.class));
// Adapter for NonDisplayableMenu must not exist
assertNull(jsonNonDisplayableMenu);
// Json response must not contain NonDisplayableMenu
JSONObject json = jsonTable.toJson();
JSONArray jsonMenus = json.getJSONArray("menus");
assertEquals(1, jsonMenus.length());
assertEquals(jsonDisplayableMenu.getId(), jsonMenus.get(0));
}
Aggregations