use of org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWith3Cols in project scout.rt by eclipse.
the class JsonTableTest method testRequestFocusInCellRowRequired.
/**
* Tests if a RequestFocusInCell-Event get discarded when now row is set/available in the Event
*/
@Test
public void testRequestFocusInCellRowRequired() {
TableWith3Cols table = new TableWith3Cols();
table.fill(2);
table.initTable();
table.resetColumns();
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
// Response should contain no events
assertEquals(0, m_uiSession.currentJsonResponse().getEventList().size());
// Request Focus without a row
table.requestFocusInCell(table.getColumns().get(0), null);
// Events should not be in the response
assertEquals(0, m_uiSession.currentJsonResponse().getEventList().size());
// And also not in the event buffer
assertEquals(0, jsonTable.eventBuffer().size());
// So there should be no events at all in the response
JSONObject response = m_uiSession.currentJsonResponse().toJson();
assertNull(response.optJSONArray("events"));
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWith3Cols in project scout.rt by eclipse.
the class JsonTableTest method testIgnorableColumnOrderChangedEvent.
/**
* Response must not contain the column order changed event if the event was triggered by the request and the order
* hasn't changed
*/
@Test
public void testIgnorableColumnOrderChangedEvent() throws JSONException {
TableWith3Cols table = new TableWith3Cols();
table.fill(2);
table.initTable();
table.resetColumns();
IColumn<?> column = table.getColumns().get(0);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
jsonTable.toJson();
// ----------
JsonEvent event = createJsonColumnMovedEvent(jsonTable.getColumnId(column), 2);
jsonTable.handleUiEvent(event);
List<JsonEvent> responseEvents = JsonTestUtility.extractEventsFromResponse(m_uiSession.currentJsonResponse(), "columnOrderChanged");
assertTrue(responseEvents.size() == 0);
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWith3Cols in project scout.rt by eclipse.
the class JsonTableTest method testColumnStructureChangedEvent_dispose.
/**
* If column structure changes, old columns are disposed and the new ones attached
*/
@Test
public void testColumnStructureChangedEvent_dispose() throws JSONException {
TableWith3Cols table = new TableWith3Cols();
table.fill(2);
table.initTable();
table.resetColumns();
IColumn column0 = table.getColumnSet().getColumn(0);
IColumn column1 = table.getColumnSet().getColumn(1);
IColumn column2 = table.getColumnSet().getColumn(2);
column0.setVisible(false);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
jsonTable.toJson();
String column0Id = jsonTable.getColumnId(column0);
String column1Id = jsonTable.getColumnId(column1);
String column2Id = jsonTable.getColumnId(column2);
assertNull(column0Id);
assertNotNull(column1Id);
assertNotNull(column2Id);
column0.setVisible(true);
column2.setVisible(false);
JsonResponse response = m_uiSession.currentJsonResponse();
response.fireProcessBufferedEvents();
String newColumn0Id = jsonTable.getColumnId(column0);
String newColumn1Id = jsonTable.getColumnId(column1);
String newColumn2Id = jsonTable.getColumnId(column2);
assertNotNull(newColumn0Id);
assertNotNull(newColumn1Id);
Assert.assertNotEquals(column1Id, newColumn1Id);
assertNull(newColumn2Id);
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWith3Cols in project scout.rt by eclipse.
the class JsonTableTest method testTableEventCoalesceInUi_DeleteEventOnFilteredRow.
@Test
public void testTableEventCoalesceInUi_DeleteEventOnFilteredRow() throws Exception {
TableWith3Cols table = new TableWith3Cols();
table.initTable();
table.fill(1, false);
table.resetColumns();
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
m_uiSession.currentJsonResponse().addAdapter(jsonTable);
JSONObject response = m_uiSession.currentJsonResponse().toJson();
JsonTestUtility.endRequest(m_uiSession);
// -------------
table.fill(2, false);
table.addRowFilter(new ITableRowFilter() {
@Override
public boolean accept(ITableRow r) {
// filter all rows
return false;
}
});
response = m_uiSession.currentJsonResponse().toJson();
JsonTestUtility.endRequest(m_uiSession);
JSONArray events = response.optJSONArray("events");
assertEquals(1, events.length());
assertEquals("allRowsDeleted", events.getJSONObject(0).getString("type"));
// -------------
// should not trigger any events
table.deleteRow(0);
response = m_uiSession.currentJsonResponse().toJson();
JsonTestUtility.endRequest(m_uiSession);
events = response.optJSONArray("events");
// No events should be emitted
assertNull(events);
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWith3Cols in project scout.rt by eclipse.
the class JsonTableTest method testGetTableRow.
@Test(expected = UiException.class)
public void testGetTableRow() throws Exception {
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, new TableWith3Cols(), null);
jsonTable.getTableRow("foo");
}
Aggregations