use of org.gwtproject.cell.client.EditTextCell.ViewData in project gwtproject by treblereel.
the class EditTextCellTest method testViewData.
public void testViewData() {
// Start in edit mode.
ViewData viewData = new ViewData("originalValue");
assertEquals("originalValue", viewData.getOriginal());
assertEquals("originalValue", viewData.getText());
assertTrue(viewData.isEditing());
assertFalse(viewData.isEditingAgain());
// Change the text.
viewData.setText("newValue");
assertEquals("originalValue", viewData.getOriginal());
assertEquals("newValue", viewData.getText());
assertTrue(viewData.isEditing());
assertFalse(viewData.isEditingAgain());
// Stop editing.
viewData.setEditing(false);
assertEquals("originalValue", viewData.getOriginal());
assertEquals("newValue", viewData.getText());
assertFalse(viewData.isEditing());
assertFalse(viewData.isEditingAgain());
// Edit again.
viewData.setEditing(true);
assertEquals("newValue", viewData.getOriginal());
assertEquals("newValue", viewData.getText());
assertTrue(viewData.isEditing());
assertTrue(viewData.isEditingAgain());
}
use of org.gwtproject.cell.client.EditTextCell.ViewData in project gwtproject by treblereel.
the class EditTextCellTest method testOnBrowserEventCancel.
/**
* Cancel and switch to read only mode.
*/
public void testOnBrowserEventCancel() {
NativeEvent event = Document.get().createKeyUpEvent(false, false, false, false, KeyCodes.KEY_ESCAPE);
ViewData viewData = new ViewData("originalValue");
viewData.setText("newValue");
Element parent = testOnBrowserEvent("<input type='text' value='newValue'></input>", event, "originalValue", viewData, null, null);
// Verify the input element is gone.
assertEquals("originalValue", parent.getInnerHTML());
}
use of org.gwtproject.cell.client.EditTextCell.ViewData in project gwtproject by treblereel.
the class EditTextCellTest method testOnBrowserEventCommit.
/**
* Commit and switch to read only mode.
*/
public void testOnBrowserEventCommit() {
NativeEvent event = Document.get().createKeyUpEvent(false, false, false, false, KeyCodes.KEY_ENTER);
ViewData viewData = new ViewData("originalValue");
viewData.setText("newValue");
assertTrue(viewData.isEditing());
Element parent = testOnBrowserEvent("<input type='text' value='newValue'></input>", event, "originalValue", viewData, "newValue", viewData);
assertFalse(viewData.isEditing());
// Verify the input element is gone.
assertEquals("newValue", parent.getInnerHTML());
}
use of org.gwtproject.cell.client.EditTextCell.ViewData 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.EditTextCell.ViewData 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