-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
283 additions
and
3 deletions.
There are no files selected for viewing
3 changes: 0 additions & 3 deletions
3
...ss.tools.aesh.core/src/org/jboss/tools/aesh/core/internal/ansi/DefaultCommandFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...s.tools.aesh.core.test/src/org/jboss/tools/aesh/core/internal/io/DocumentHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package org.jboss.tools.aesh.core.internal.io; | ||
|
||
import org.jboss.tools.aesh.core.document.Document; | ||
import org.jboss.tools.aesh.core.document.Style; | ||
import org.jboss.tools.aesh.core.internal.ansi.Command; | ||
import org.jboss.tools.aesh.core.test.util.TestDocument; | ||
import org.jboss.tools.aesh.core.test.util.TestStyle; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class DocumentHandlerTest { | ||
|
||
private int styleLength = 0; | ||
private int documentLength = 0; | ||
private int cursorOffset = 0; | ||
|
||
private int replacedOffset = 0; | ||
private int replacedLength = 0; | ||
private String replacedText = null; | ||
private Document handledDocument = null; | ||
|
||
private Style testStyle = new TestStyle() { | ||
@Override public int getLength() { return styleLength; } | ||
@Override public void setLength(int length) { styleLength = length; } | ||
}; | ||
|
||
private Document testDocument = new TestDocument() { | ||
@Override public Style getCurrentStyle() { return testStyle; } | ||
@Override public int getCursorOffset() { return cursorOffset; } | ||
@Override public int getLength() { return documentLength; } | ||
@Override public void moveCursorTo(int offset) { cursorOffset = offset; } | ||
@Override public void replace(int offset, int length, String text) { | ||
replacedOffset = offset; | ||
replacedLength = length; | ||
replacedText = text; | ||
} | ||
}; | ||
|
||
private Command testCommand = new Command() { | ||
@Override | ||
public void handle(Document document) { | ||
handledDocument = document; | ||
} | ||
}; | ||
|
||
private DocumentHandler testHandler = new DocumentHandler(); | ||
|
||
private String testOutput = "foobar"; | ||
|
||
@Test | ||
public void testHandleOutput() { | ||
testHandler.setDocument(testDocument); | ||
testHandler.handleOutput(testOutput); | ||
Assert.assertEquals("style length", testOutput.length(), styleLength); | ||
Assert.assertEquals("replaced offset", 0, replacedOffset); | ||
Assert.assertEquals("replaced lenght", 0, replacedLength); | ||
Assert.assertEquals("replaced text", testOutput, replacedText); | ||
Assert.assertEquals("cursor offset", testOutput.length(), cursorOffset); | ||
} | ||
|
||
@Test | ||
public void testHandleCommand() { | ||
testHandler.setDocument(testDocument); | ||
testHandler.handleCommand(testCommand); | ||
Assert.assertEquals("handled document", testDocument, handledDocument); | ||
} | ||
|
||
} |
71 changes: 71 additions & 0 deletions
71
.../org.jboss.tools.aesh.core.test/src/org/jboss/tools/aesh/core/test/util/TestDocument.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package org.jboss.tools.aesh.core.test.util; | ||
|
||
import org.jboss.tools.aesh.core.document.Document; | ||
import org.jboss.tools.aesh.core.document.Style; | ||
|
||
public class TestDocument implements Document { | ||
|
||
@Override | ||
public int getCursorOffset() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int getLineOfOffset(int offset) { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int getLineOffset(int line) { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int getLineLength(int line) { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int getLength() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void moveCursorTo(int offset) { | ||
} | ||
|
||
@Override | ||
public void restoreCursor() { | ||
} | ||
|
||
@Override | ||
public void saveCursor() { | ||
} | ||
|
||
@Override | ||
public void reset() { | ||
} | ||
|
||
@Override | ||
public void replace(int cursorOffset, int length, String str) { | ||
} | ||
|
||
@Override | ||
public Style newStyleFromCurrent() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setCurrentStyle(Style style) { | ||
} | ||
|
||
@Override | ||
public Style getCurrentStyle() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setDefaultStyle() { | ||
} | ||
|
||
} |
144 changes: 144 additions & 0 deletions
144
tests/org.jboss.tools.aesh.core.test/src/org/jboss/tools/aesh/core/test/util/TestStyle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
package org.jboss.tools.aesh.core.test.util; | ||
|
||
import org.jboss.tools.aesh.core.document.Style; | ||
|
||
public class TestStyle implements Style { | ||
|
||
@Override | ||
public void resetToNormal() { | ||
} | ||
|
||
@Override | ||
public void setBoldOn() { | ||
} | ||
|
||
@Override | ||
public void setFaintOn() { | ||
} | ||
|
||
@Override | ||
public void setItalicOn() { | ||
} | ||
|
||
@Override | ||
public void setUnderlineSingle() { | ||
} | ||
|
||
@Override | ||
public void setImageNegative() { | ||
} | ||
|
||
@Override | ||
public void setCrossedOut() { | ||
} | ||
|
||
@Override | ||
public void setBoldOrFaintOff() { | ||
} | ||
|
||
@Override | ||
public void setItalicOff() { | ||
} | ||
|
||
@Override | ||
public void setUnderlineNone() { | ||
} | ||
|
||
@Override | ||
public void setImagePositive() { | ||
} | ||
|
||
@Override | ||
public void setNotCrossedOut() { | ||
} | ||
|
||
@Override | ||
public void setForegroundBlack() { | ||
} | ||
|
||
@Override | ||
public void setForegroundRed() { | ||
} | ||
|
||
@Override | ||
public void setForegroundGreen() { | ||
} | ||
|
||
@Override | ||
public void setForegroundYellow() { | ||
} | ||
|
||
@Override | ||
public void setForegroundBlue() { | ||
} | ||
|
||
@Override | ||
public void setForegroundMagenta() { | ||
} | ||
|
||
@Override | ||
public void setForegroundCyan() { | ||
} | ||
|
||
@Override | ||
public void setForegroundWhite() { | ||
} | ||
|
||
@Override | ||
public void setForegroundXTerm(int colour) { | ||
} | ||
|
||
@Override | ||
public void setForegroundDefault() { | ||
} | ||
|
||
@Override | ||
public void setBackgroundBlack() { | ||
} | ||
|
||
@Override | ||
public void setBackgroundRed() { | ||
} | ||
|
||
@Override | ||
public void setBackgroundGreen() { | ||
} | ||
|
||
@Override | ||
public void setBackgroundYellow() { | ||
} | ||
|
||
@Override | ||
public void setBackgroundBlue() { | ||
} | ||
|
||
@Override | ||
public void setBackgroundMagenta() { | ||
} | ||
|
||
@Override | ||
public void setBackgroundCyan() { | ||
} | ||
|
||
@Override | ||
public void setBackgroundWhite() { | ||
} | ||
|
||
@Override | ||
public void setBackgroundXTerm(int colour) { | ||
} | ||
|
||
@Override | ||
public void setBackgroundDefault() { | ||
} | ||
|
||
@Override | ||
public void setLength(int length) { | ||
} | ||
|
||
@Override | ||
public int getLength() { | ||
return 0; | ||
} | ||
|
||
} |