Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2019-03-17 10:59:41 +0000
committerPaul Pazderski2019-06-29 12:38:29 +0000
commit1962d9672d5af1a8c4d749a819be3d9784bf9ee0 (patch)
tree918aef20b14995aeb6d0a2afdc21c869a0472698 /org.eclipse.debug.tests
parent2bbc97e134a0eca8598bf25de1ccc8ebc6636b05 (diff)
downloadeclipse.platform.debug-1962d9672d5af1a8c4d749a819be3d9784bf9ee0.tar.gz
eclipse.platform.debug-1962d9672d5af1a8c4d749a819be3d9784bf9ee0.tar.xz
eclipse.platform.debug-1962d9672d5af1a8c4d749a819be3d9784bf9ee0.zip
Bug 548356 - [console] Fix input handling in IOConsoleI20190702-0930I20190702-0610I20190701-1805
Existing IOConsole and especially IOConsolePartitioner have various problems with user input handling e.g. if existing input surrounded by output is modified or a character composition is started inside an output partition. Change-Id: I3ea4f19553d6363e0d3cdc5280b577be57b45bd9 Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
Diffstat (limited to 'org.eclipse.debug.tests')
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTestUtil.java11
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTests.java87
2 files changed, 97 insertions, 1 deletions
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTestUtil.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTestUtil.java
index b2e391b15..ee08f8105 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTestUtil.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTestUtil.java
@@ -345,6 +345,17 @@ public final class IOConsoleTestUtil {
}
/**
+ * Set caret to offset relative to start of current line.
+ *
+ * @param offset relative offset to line start
+ * @return this {@link IOConsoleTestUtil} to chain methods
+ */
+ public IOConsoleTestUtil setCaretLineRelative(int offset) {
+ moveCaretToLineStart().moveCaret(offset);
+ return this;
+ }
+
+ /**
* Move caret by given amount forth or back.
*
* @param amount steps to set caret forth (positive value) or back (negative
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTests.java
index 18971d36f..031f3c473 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTests.java
@@ -183,9 +183,21 @@ public class IOConsoleTests extends AbstractDebugTest {
*/
public void testConsoleClear() throws Exception {
final IOConsoleTestUtil c = getTestUtil("Test clear");
+
+ c.writeAndVerify("Hello World!");
+ c.getDocument().replace(0, c.getContentLength(), "");
+ c.waitForScheduledJobs();
+ c.verifyContent("").verifyPartitions();
+
c.writeAndVerify("New console content.");
c.clear();
- closeConsole(c);
+ assertEquals("Unexpected partition type.", IOConsoleTestUtil.inputPartitionType(), c.getPartitioner().getContentType(0));
+
+ c.insertAndVerify("wrong").write("out").verifyContent("wrongout").verifyPartitions(2);
+ c.clear().insertTypingAndVerify("i").write("ooo").verifyContent("iooo").verifyPartitions();
+ c.enter().clear();
+
+ closeConsole(c, "i");
}
/**
@@ -265,6 +277,53 @@ public class IOConsoleTests extends AbstractDebugTest {
c.enter().clear();
expectedInput.add("+more inputinput");
+ // inserted input is shorter than existing input partition
+ c.writeAndVerify("foo");
+ c.insertTyping("><--input-partition--").setCaretOffset(4);
+ c.writeAndVerify("bar");
+ c.insertTypingAndVerify("short");
+ c.verifyContent("foo>short<--input-partition--bar").verifyPartitions(3);
+ c.enter().clear();
+ expectedInput.add(">short<--input-partition--");
+
+ // inserted input is longer than existing input partition
+ c.writeAndVerify("Hello");
+ c.insertTyping("><").moveCaret(-1);
+ c.writeAndVerify("World");
+ c.insertTypingAndVerify("user input");
+ c.verifyContent("Hello>user input<World").verifyPartitions(3);
+ c.enter().clear();
+ expectedInput.add(">user input<");
+
+ // replace and remove input
+ c.writeAndVerify("oooo");
+ c.insertTyping("input");
+ c.writeAndVerify("output");
+ c.verifyContent("ooooinputoutput").verifyPartitions(3);
+ c.select(4, 5).insertAndVerify("iiii");
+ c.verifyContent("ooooiiiioutput").verifyPartitions(3);
+ c.select(4, 4).backspace();
+ c.verifyContent("oooooutput").verifyPartitions(2);
+ c.enter().clear();
+ expectedInput.add("");
+
+ // insert alternating into distinct input partitions
+ c.insertTypingAndVerify("ac").writeAndVerify("ooo");
+ c.setCaretOffset(1).insertTypingAndVerify("b");
+ c.moveCaretToEnd().insertTypingAndVerify("123");
+ c.verifyContent("abcooo123").verifyPartitions(3);
+ c.enter().clear();
+ expectedInput.add("abc123");
+
+ // insert alternating into distinct input partitions
+ c.insertTypingAndVerify("abc").writeAndVerify("ooo");
+ c.moveCaretToEnd().insertTypingAndVerify("13").writeAndVerify("OOO");
+ c.moveCaret(-1).insertTyping("2");
+ c.moveCaretToStart().insertTyping("ABC");
+ c.verifyContent("ABCabcooo123OOO").verifyPartitions(4);
+ c.enter().clear();
+ expectedInput.add("ABCabc123");
+
closeConsole(c, expectedInput.toArray(new String[0]));
}
@@ -330,4 +389,30 @@ public class IOConsoleTests extends AbstractDebugTest {
}
closeConsole(c);
}
+
+ /**
+ * Some extra tests for IOConsolePartitioner.
+ */
+ public void testIOPartitioner() throws Exception {
+ final IOConsoleTestUtil c = getTestUtil("Test partitioner");
+
+ c.writeAndVerify("output");
+ c.getDocument().replace(2, 1, ":::");
+ c.verifyPartitions();
+
+ c.clear().insertAndVerify("input").enter();
+ c.getDocument().replace(3, 0, "()");
+ c.verifyInputPartitions(0, c.getContentLength());
+
+ c.clear().writeAndVerify("><");
+ c.getDocument().replace(1, 0, "a\nb\r\nc");
+ c.verifyContent(">a\nb\r\nc<").verifyPartitions();
+
+ c.clear().writeAndVerify(")");
+ c.getDocument().replace(0, 0, "(");
+ c.verifyContent("()").verifyPartitions();
+
+ closeConsole(c);
+ assertEquals("Test triggered errors in IOConsole.", 0, loggedErrors.get());
+ }
}

Back to the top