Revert "Bug 76936 - [console] Eclipse Console window does not handle \b, \f, and \r"
This reverts commit 0fb2d7b735ddfacbeb71b0e3eb276df73c2996f9.
diff --git a/org.eclipse.jdt.debug.tests/console tests/org/eclipse/jdt/debug/tests/console/IOConsoleTests.java b/org.eclipse.jdt.debug.tests/console tests/org/eclipse/jdt/debug/tests/console/IOConsoleTests.java
index ba09852..6cce6f9 100644
--- a/org.eclipse.jdt.debug.tests/console tests/org/eclipse/jdt/debug/tests/console/IOConsoleTests.java
+++ b/org.eclipse.jdt.debug.tests/console tests/org/eclipse/jdt/debug/tests/console/IOConsoleTests.java
@@ -7,7 +7,6 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Philippe Marschall <philippe.marschall@netcetera.ch> - Bug 76936
*******************************************************************************/
package org.eclipse.jdt.debug.tests.console;
@@ -28,8 +27,6 @@
private int fMatchCount;
private boolean fDisconnected = false;
- private IConsoleManager fConsoleManager;
- private MessageConsole fConsole;
/**
* Constructor
@@ -39,136 +36,35 @@
super(name);
}
- /*
- * (non-Javadoc)
- *
- * @see junit.framework.TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- fMatchCount = 0;
- fConsole = new MessageConsole("Test console", null);
- fConsole.addPatternMatchListener(this);
- fConsoleManager = ConsolePlugin.getDefault().getConsoleManager();
- fConsoleManager.addConsoles(new IConsole[] { fConsole });
- }
-
- /*
- * (non-Javadoc)
- *
- * @see junit.framework.TestCase#setUp()
- */
- @Override
- protected void tearDown() throws Exception {
- fConsoleManager.removeConsoles(new IConsole[] { fConsole });
- super.tearDown();
- }
-
- /**
- * Tests the escape characters backspace, carriage return and line feed
- *
- * @throws Exception
- */
- public void testControlCharacters() throws Exception {
- MessageConsoleStream stream = fConsole.newMessageStream();
- stream.println("line 1");
- stream.println("fail the test\rwinn"); // winn the test
- stream.println("fail not\b\b\b"); // fail not
- stream.println("win not\b\b\byes"); // win yes
- stream.println("win not\b\b\b\b\b\b\b\b\b\b\b\byes"); // win yes
- stream.println("line\findented"); // line
- // indented
- stream.println("line\f\b\bindented"); // line
- // indented
-
- stream.flush();
- waitUpTo1500Millis();
-
- // no newlines at start or end
- stream.print("x\b1\nx\b2\nx\b3");
-
- waitUpTo1500Millis();
- stream.flush();
-
- // newlines at start and end
- stream.print("\nx\b1\n\nx\b2\nx\b3\n");
-
- waitUpTo1500Millis();
-
- // @formatter:off
- assertEquals("line 1\n"
- + "winn the test\n"
- + "fail not\n"
- + "win yes\n"
- + "yes not\n"
- + "line\n"
- + " indented\n"
- + "line\n"
- + " indented\n"
- + "1\n2\n3"
- + "\n1\n\n2\n3\n",
- fConsole.getDocument().get());
- // @formatter:on
- }
-
- /**
- * Tests overwriting the last displayed character with backspace
- *
- * @throws Exception
- */
- public void testOverwriteLastCharacter() throws Exception {
- MessageConsoleStream stream = fConsole.newMessageStream();
- stream.print("abc");
- stream.flush();
- waitUpTo1500Millis();
- assertEquals("abc", fConsole.getDocument().get());
- stream.print("\b1");
- waitUpTo1500Millis();
-
- assertEquals("ab1", fConsole.getDocument().get());
- }
-
- /**
- * Tests overwriting the last displayed line with carriage return
- *
- * @throws Exception
- */
- public void testOverwriteLastLine() throws Exception {
- MessageConsoleStream stream = fConsole.newMessageStream();
- stream.print("abc");
- stream.flush();
- waitUpTo1500Millis();
- stream.print("\rxxx");
- waitUpTo1500Millis();
-
- assertEquals("xxx", fConsole.getDocument().get());
- }
-
/**
* Tests that the pattern matcher will find a specific pattern
* @throws Exception
*/
public void testPatternMatchListener() throws Exception {
- MessageConsoleStream stream = fConsole.newMessageStream();
- stream.print("one foo bar");
- stream.println();
- stream.print("two foo bar");
-
- waitUpTo1500Millis();
-
- assertEquals("Should be two foo's", 2, fMatchCount);
+ MessageConsole console = new MessageConsole("Test console", null);
+ fMatchCount = 0;
+ console.addPatternMatchListener(this);
+ IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
+ consoleManager.addConsoles(new IConsole[]{console});
+ try {
+ MessageConsoleStream stream = console.newMessageStream();
+ stream.print("one foo bar");
+ stream.println();
+ stream.print("two foo bar");
+
+ long endTime = System.currentTimeMillis() + 1500;
+ while (!fDisconnected && System.currentTimeMillis() < endTime) {
+ synchronized(this) {
+ wait(500);
+ }
+ }
+
+ assertEquals("Should be two foo's", 2, fMatchCount);
+ } finally {
+ consoleManager.removeConsoles(new IConsole[]{console});
+ }
}
- private void waitUpTo1500Millis() throws InterruptedException {
- long endTime = System.currentTimeMillis() + 1500;
- while (!fDisconnected && System.currentTimeMillis() < endTime) {
- synchronized (this) {
- wait(500);
- }
- }
- }
-
/**
* @see org.eclipse.ui.console.IPatternMatchListener#getPattern()
*/