use of org.eclipse.scout.rt.ui.html.json.table.fixtures.Table in project scout.rt by eclipse.
the class JsonTableTest method testIgnorableSelectionEvent3.
/**
* Same as {@link #testIgnorableSelectionEvent2()} but with an empty selection
*/
@Test
public void testIgnorableSelectionEvent3() throws JSONException {
Table table = new Table() {
@Override
protected void execRowsSelected(List<? extends ITableRow> rows) {
if (rows.size() == 0) {
selectRow(4);
}
}
};
table.fill(5);
table.initTable();
ITableRow row2 = table.getRow(2);
ITableRow row4 = table.getRow(4);
table.selectRow(row2);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
jsonTable.toJson();
// ----------
JsonEvent event = createJsonRowsSelectedEvent(null);
assertTrue(row2.isSelected());
assertFalse(row4.isSelected());
jsonTable.handleUiEvent(event);
assertFalse(row2.isSelected());
assertTrue(row4.isSelected());
List<JsonEvent> responseEvents = JsonTestUtility.extractEventsFromResponse(m_uiSession.currentJsonResponse(), JsonTable.EVENT_ROWS_SELECTED);
assertTrue(responseEvents.size() == 1);
List<ITableRow> tableRows = jsonTable.extractTableRows(responseEvents.get(0).getData());
assertEquals(row4, tableRows.get(0));
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.Table in project scout.rt by eclipse.
the class JsonTableTest method testIgnorableSelectionEvent2.
/**
* If the selection event triggers the selection of another row, the selection event must not be ignored.
*/
@Test
public void testIgnorableSelectionEvent2() throws JSONException {
Table table = new Table() {
@Override
protected void execRowsSelected(List<? extends ITableRow> rows) {
selectRow(4);
}
};
table.fill(5);
table.initTable();
ITableRow row2 = table.getRow(2);
ITableRow row4 = table.getRow(4);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
jsonTable.toJson();
// ----------
JsonEvent event = createJsonRowsSelectedEvent(jsonTable.getOrCreateRowId(row2));
assertFalse(row2.isSelected());
assertFalse(row4.isSelected());
jsonTable.handleUiEvent(event);
assertFalse(row2.isSelected());
assertTrue(row4.isSelected());
List<JsonEvent> responseEvents = JsonTestUtility.extractEventsFromResponse(m_uiSession.currentJsonResponse(), JsonTable.EVENT_ROWS_SELECTED);
assertTrue(responseEvents.size() == 1);
List<ITableRow> tableRows = jsonTable.extractTableRows(responseEvents.get(0).getData());
assertEquals(row4, tableRows.get(0));
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.Table in project scout.rt by eclipse.
the class JsonTableTest method testIgnorableRowOrderChangedEvent.
/**
* Response must not contain the row_order_changed event if the sort was triggered by the request
*/
@Test
public void testIgnorableRowOrderChangedEvent() throws JSONException {
Table table = createTableFixture(5);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
jsonTable.toJson();
IColumn column = table.getColumnSet().getFirstVisibleColumn();
// ----------
JsonEvent event = createJsonRowsSortedEvent(jsonTable.getColumnId(column), !column.isSortAscending());
jsonTable.handleUiEvent(event);
List<JsonEvent> responseEvents = JsonTestUtility.extractEventsFromResponse(m_uiSession.currentJsonResponse(), "rowOrderChanged");
assertTrue(responseEvents.size() == 0);
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.Table in project scout.rt by eclipse.
the class JsonTableTest method testDispose.
@Test
public void testDispose() {
Table table = new Table();
JsonTable<ITable> object = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
WeakReference<JsonTable> ref = new WeakReference<JsonTable>(object);
object.dispose();
m_uiSession = null;
object = null;
TestingUtility.assertGC(ref);
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.Table in project scout.rt by eclipse.
the class JsonTableTest method createTableFixture.
public static Table createTableFixture(int numRows) {
Table table = new Table();
table.fill(numRows);
table.initTable();
return table;
}
Aggregations