use of org.gwtproject.cell.client.Cell.Context in project gwtproject by treblereel.
the class DefaultSelectionEventManagerTest method testHandleSelectionEventToggle.
public void testHandleSelectionEventToggle() {
org.gwtproject.view.client.SingleSelectionModel<String> model = new SingleSelectionModel<String>();
display.setSelectionModel(model);
model.setSelected("test 0", true);
// Toggle a different value.
NativeEvent nativeEvent = Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false);
org.gwtproject.view.client.CellPreviewEvent<String> event = new CellPreviewEvent<String>(nativeEvent, display, new Context(1, 0, null), "test 1", false, false);
manager.handleSelectionEvent(event, SelectAction.TOGGLE, model);
assertEquals("test 1", model.getSelectedObject());
// Toggle the same value.
manager.handleSelectionEvent(event, SelectAction.TOGGLE, model);
assertNull(model.getSelectedObject());
}
use of org.gwtproject.cell.client.Cell.Context in project gwtproject by treblereel.
the class DefaultSelectionEventManagerTest method testHandleSelectionEventSelect.
public void testHandleSelectionEventSelect() {
org.gwtproject.view.client.SingleSelectionModel<String> model = new org.gwtproject.view.client.SingleSelectionModel<String>();
display.setSelectionModel(model);
model.setSelected("test 0", true);
// Select the same value.
NativeEvent nativeEvent = Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false);
org.gwtproject.view.client.CellPreviewEvent<String> event = new org.gwtproject.view.client.CellPreviewEvent<String>(nativeEvent, display, new Context(0, 0, null), "test 0", false, false);
manager.handleSelectionEvent(event, SelectAction.SELECT, model);
assertEquals("test 0", model.getSelectedObject());
// Select a different value.
event = new org.gwtproject.view.client.CellPreviewEvent<String>(nativeEvent, display, new Context(1, 0, null), "test 1", false, false);
manager.handleSelectionEvent(event, SelectAction.SELECT, model);
assertEquals("test 1", model.getSelectedObject());
}
use of org.gwtproject.cell.client.Cell.Context in project gwtproject by treblereel.
the class DefaultSelectionEventManagerTest method testHandleSelectionEventIgnore.
public void testHandleSelectionEventIgnore() {
org.gwtproject.view.client.SingleSelectionModel<String> model = new org.gwtproject.view.client.SingleSelectionModel<String>();
display.setSelectionModel(model);
model.setSelected("test 0", true);
NativeEvent nativeEvent = Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false);
org.gwtproject.view.client.CellPreviewEvent<String> event = new org.gwtproject.view.client.CellPreviewEvent<String>(nativeEvent, display, new Context(3, 0, null), "test 3", false, false);
manager.handleSelectionEvent(event, SelectAction.IGNORE, model);
assertEquals("test 0", model.getSelectedObject());
}
use of org.gwtproject.cell.client.Cell.Context in project gwtproject by treblereel.
the class EditTextCellTest method testEdit.
public void testEdit() {
EditTextCell cell = createCell();
Element parent = Document.get().createDivElement();
parent.setInnerHTML("<input type='text' value='editing'></input>");
ViewData viewData = new ViewData("originalValue");
viewData.setText("newValue");
cell.setViewData(DEFAULT_KEY, viewData);
Context context = new Context(0, 0, DEFAULT_KEY);
cell.edit(context, parent, "originalValue");
// Verify the input element.
Element child = parent.getFirstChildElement();
assertTrue(InputElement.is(child));
InputElement input = child.cast();
assertEquals("newValue", input.getValue());
}
use of org.gwtproject.cell.client.Cell.Context in project gwtproject by treblereel.
the class EditTextCellTest method testRenderViewDataDoneEditing.
/**
* Test rendering the cell with a valid value and view data, but without
* editing.
*/
public void testRenderViewDataDoneEditing() {
EditTextCell cell = createCell();
ViewData viewData = new ViewData("originalValue");
viewData.setText("newValue");
viewData.setEditing(false);
cell.setViewData(DEFAULT_KEY, viewData);
SafeHtmlBuilder sb = new SafeHtmlBuilder();
Context context = new Context(0, 0, DEFAULT_KEY);
cell.render(context, "originalValue", sb);
assertEquals("newValue", sb.toSafeHtml().asString());
}
Aggregations