* Text must be editable to pass this test.
*/
public void _testModifications(MConstText insertionText,
boolean restoreOldText) {
MConstText oldText = new StyledText(fTextPanel.getText());
final int insLength = insertionText.length();
fListener.allowAll();
fListener.expectEvent(TextPanelEvent.TEXT_CHANGED);
fListener.expectEvent(TextPanelEvent.SELECTION_RANGE_CHANGED);
fTextPanel.append(insertionText);
fListener.assertNotExpectingEvents();
if (fTextPanel.getSelectionStart() != oldText.length() + insLength) {
reportError("Append didn't result in correct selection");
}
fListener.expectEvent(TextPanelEvent.TEXT_CHANGED);
fListener.expectEvent(TextPanelEvent.SELECTION_RANGE_CHANGED);
fTextPanel.insert(insertionText, 0);
fListener.assertNotExpectingEvents();
fListener.allowAll();
if (fTextPanel.getSelectionStart() != insLength) {
reportError("Insert didn't result in correct selection");
}
fTextPanel.replaceRange(insertionText, insLength, insLength+oldText.length());
if (fTextPanel.getSelectionStart() != insLength*2) {
reportError("Replace didn't result in correct selection");
}
if (fTextPanel.getSelectionEnd() != insLength*2) {
reportError("Replace didn't result in correct selection");
}
if (fTextPanel.getTextLength() != insLength*3) {
reportError("textLength is incorrect");
}
if (restoreOldText) {
fTextPanel.setText(oldText);
if (fTextPanel.getSelectionStart() != oldText.length()) {
reportError("setText didn't result in correct selection");
}
if (fTextPanel.getTextLength() != oldText.length()) {
reportError("length incorrect after setText");
}
}
fListener.allowAll();