comparison tests/src/com/five_ten_sg/connectbot/TerminalBridgeTest.java @ 0:0ce5cc452d02

initial version
author Carl Byington <carl@five-ten-sg.com>
date Thu, 22 May 2014 10:41:19 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:0ce5cc452d02
1 /*
2 * ConnectBot: simple, powerful, open-source SSH client for Android
3 * Copyright 2007 Kenny Root, Jeffrey Sharkey
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package com.five_ten_sg.connectbot;
19
20 import android.test.AndroidTestCase;
21
22 /**
23 * @author Kenny Root
24 *
25 */
26 public class TerminalBridgeTest extends AndroidTestCase {
27 public void testShiftLock() throws SecurityException, NoSuchFieldException,
28 IllegalArgumentException, IllegalAccessException {
29 // TerminalBridge bridge = new TerminalBridge();
30 // AbsTransport nullTransport = new NullTransport();
31 //
32 // // Make sure onKey will work when we call it
33 // Field disconnected = TerminalBridge.class
34 // .getDeclaredField("disconnected");
35 // Field keymode = TerminalBridge.class.getDeclaredField("keymode");
36 // Field transport = TerminalBridge.class.getDeclaredField("transport");
37 //
38 // disconnected.setAccessible(true);
39 // keymode.setAccessible(true);
40 // transport.setAccessible(true);
41 //
42 // disconnected.setBoolean(bridge, false);
43 // keymode.set(bridge, PreferenceConstants.KEYMODE_RIGHT);
44 // transport.set(bridge, nullTransport);
45 //
46 // // Begin tests
47 // assertTrue("Meta state is " + bridge.getMetaState()
48 // + " when it should be 0", bridge.getMetaState() == 0);
49 //
50 // KeyEvent shiftDown = new KeyEvent(KeyEvent.ACTION_DOWN,
51 // KeyEvent.KEYCODE_SHIFT_LEFT);
52 // bridge.onKey(null, shiftDown.getKeyCode(), shiftDown);
53 //
54 // assertTrue("Shift test: after shift press, meta state is "
55 // + bridge.getMetaState() + " when it should be "
56 // + TerminalBridge.META_SHIFT_ON,
57 // bridge.getMetaState() == TerminalBridge.META_SHIFT_ON);
58 //
59 // KeyEvent shiftUp = KeyEvent.changeAction(shiftDown, KeyEvent.ACTION_UP);
60 // bridge.onKey(null, shiftUp.getKeyCode(), shiftUp);
61 //
62 // assertTrue("Shift test: after shift release, meta state is "
63 // + bridge.getMetaState() + " when it should be "
64 // + TerminalBridge.META_SHIFT_ON,
65 // bridge.getMetaState() == TerminalBridge.META_SHIFT_ON);
66 //
67 // KeyEvent letterAdown = new KeyEvent(KeyEvent.ACTION_DOWN,
68 // KeyEvent.KEYCODE_A);
69 // KeyEvent letterAup = KeyEvent.changeAction(letterAdown,
70 // KeyEvent.ACTION_UP);
71 //
72 // bridge.onKey(null, letterAdown.getKeyCode(), letterAdown);
73 // bridge.onKey(null, letterAup.getKeyCode(), letterAup);
74 //
75 // assertTrue("Shift test: after letter press and release, meta state is "
76 // + bridge.getMetaState() + " when it should be 0", bridge
77 // .getMetaState() == 0);
78 //
79 // bridge.onKey(null, shiftDown.getKeyCode(), shiftDown);
80 // bridge.onKey(null, shiftUp.getKeyCode(), shiftUp);
81 // bridge.onKey(null, shiftDown.getKeyCode(), shiftDown);
82 // bridge.onKey(null, shiftUp.getKeyCode(), shiftUp);
83 //
84 // assertTrue("Shift lock test: after two shift presses, meta state is "
85 // + bridge.getMetaState() + " when it should be "
86 // + TerminalBridge.META_SHIFT_LOCK,
87 // bridge.getMetaState() == TerminalBridge.META_SHIFT_LOCK);
88 //
89 // bridge.onKey(null, letterAdown.getKeyCode(), letterAdown);
90 //
91 // assertTrue(
92 // "Shift lock test: after letter press, meta state is "
93 // + bridge.getMetaState() + " when it should be "
94 // + TerminalBridge.META_SHIFT_LOCK,
95 // bridge.getMetaState() == TerminalBridge.META_SHIFT_LOCK);
96 //
97 // bridge.onKey(null, letterAup.getKeyCode(), letterAup);
98 //
99 // assertTrue(
100 // "Shift lock test: after letter press and release, meta state is "
101 // + bridge.getMetaState() + " when it should be "
102 // + TerminalBridge.META_SHIFT_LOCK,
103 // bridge.getMetaState() == TerminalBridge.META_SHIFT_LOCK);
104 }
105 }