aboutsummaryrefslogtreecommitdiffstats
path: root/src/org
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2009-05-14 12:37:30 +0000
committerKenny Root <kenny@the-b.org>2009-05-14 12:37:30 +0000
commitdb208c992937b9a522f0ba50a5356b53de719523 (patch)
tree3723c462f06403b143d48724cfe8f4ba0a2072d0 /src/org
parent06a3bb922b26809c979dd815f3427410c08ecccd (diff)
downloadconnectbot-db208c992937b9a522f0ba50a5356b53de719523.tar.gz
connectbot-db208c992937b9a522f0ba50a5356b53de719523.tar.bz2
connectbot-db208c992937b9a522f0ba50a5356b53de719523.zip
Added test case for TerminalBridge.onKey and fixed a bug in meta states
git-svn-id: https://connectbot.googlecode.com/svn/trunk/connectbot@234 df292f66-193f-0410-a5fc-6d59da041ff2
Diffstat (limited to 'src/org')
-rw-r--r--src/org/connectbot/service/TerminalBridge.java35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/org/connectbot/service/TerminalBridge.java b/src/org/connectbot/service/TerminalBridge.java
index 5477dd4..024c7b6 100644
--- a/src/org/connectbot/service/TerminalBridge.java
+++ b/src/org/connectbot/service/TerminalBridge.java
@@ -397,6 +397,34 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal
}
/**
+ * Create a new terminal bridge suitable for unit testing.
+ */
+ public TerminalBridge() {
+ buffer = new vt320() {
+ @Override
+ public void write(byte[] b) {}
+ @Override
+ public void sendTelnetCommand(byte cmd) {}
+ @Override
+ public void setWindowSize(int c, int r) {}
+ };
+
+ emulation = null;
+ manager = null;
+
+ defaultPaint = new Paint();
+
+ selectionArea = new SelectionArea();
+ scrollback = 1;
+
+ localOutput = new LinkedList<String>();
+
+ fontSizeChangedListeners = new LinkedList<FontSizeChangedListener>();
+
+ connection = null;
+ }
+
+ /**
* Create new terminal bridge with following parameters. We will immediately
* launch thread to start SSH connection and handle any hostkey verification
* and password authentication.
@@ -851,7 +879,7 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal
// Ignore all key-up events except for the special keys
if (event.getAction() == KeyEvent.ACTION_UP) {
// skip keys if we aren't connected yet or have been disconnected
- if (disconnected || session == null)
+ if (disconnected || !sessionOpen)
return false;
if ("Use right-side keys".equals(keymode)) {
@@ -895,7 +923,7 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal
}
// skip keys if we aren't connected yet or have been disconnected
- if (disconnected || session == null)
+ if (disconnected || !sessionOpen)
return false;
// if we're in scrollback, scroll to bottom of window on input
@@ -941,7 +969,7 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal
}
// handle pressing f-keys
- if ((metaState &= META_TAB) != 0) {
+ if ((metaState & META_TAB) != 0) {
switch(key) {
case '!': ((vt320)buffer).keyPressed(vt320.KEY_F1, ' ', 0); return true;
case '@': ((vt320)buffer).keyPressed(vt320.KEY_F2, ' ', 0); return true;
@@ -962,6 +990,7 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal
// TODO write encoding routine that doesn't allocate each time
stdin.write(new String(Character.toChars(key))
.getBytes(host.getEncoding()));
+
return true;
}