aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.idea/gradle.xml1
-rw-r--r--app/src/androidTest/java/org/connectbot/HostListActivityTest.java47
-rw-r--r--app/src/androidTest/java/org/connectbot/SettingsActivityTest.java47
-rw-r--r--app/src/androidTest/java/org/connectbot/TerminalBridgeTest.java105
-rw-r--r--robolectric-tests/.gitignore1
-rw-r--r--robolectric-tests/build.gradle48
-rw-r--r--robolectric-tests/robolectric-tests.iml76
-rw-r--r--robolectric-tests/src/test/java/org/connectbot/HostBeanTest.java (renamed from app/src/androidTest/java/org/connectbot/HostBeanTest.java)46
-rw-r--r--robolectric-tests/src/test/java/org/connectbot/SelectionAreaTest.java (renamed from app/src/androidTest/java/org/connectbot/SelectionAreaTest.java)23
-rw-r--r--robolectric-tests/src/test/java/org/connectbot/mock/BeanAssertions.java (renamed from app/src/androidTest/java/org/connectbot/mock/BeanTestCase.java)8
-rw-r--r--robolectric-tests/src/test/java/org/connectbot/mock/NullOutputStream.java (renamed from app/src/androidTest/java/org/connectbot/mock/NullOutputStream.java)0
-rw-r--r--robolectric-tests/src/test/java/org/connectbot/mock/NullTransport.java (renamed from app/src/androidTest/java/org/connectbot/mock/NullTransport.java)0
-rw-r--r--robolectric-tests/src/test/java/org/connectbot/util/PubkeyUtilsTest.java (renamed from app/src/androidTest/java/org/connectbot/util/PubkeyUtilsTest.java)65
-rw-r--r--settings.gradle2
14 files changed, 222 insertions, 247 deletions
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 736c7b5..0228264 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -9,6 +9,7 @@
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
+ <option value="$PROJECT_DIR$/robolectric-tests" />
</set>
</option>
</GradleProjectSettings>
diff --git a/app/src/androidTest/java/org/connectbot/HostListActivityTest.java b/app/src/androidTest/java/org/connectbot/HostListActivityTest.java
deleted file mode 100644
index 3962c9a..0000000
--- a/app/src/androidTest/java/org/connectbot/HostListActivityTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * ConnectBot: simple, powerful, open-source SSH client for Android
- * Copyright 2007 Kenny Root, Jeffrey Sharkey
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.connectbot;
-
-import android.app.Activity;
-import android.test.ActivityInstrumentationTestCase2;
-
-/**
- * This is a simple framework for a test of an Application. See
- * {@link android.test.ApplicationTestCase ApplicationTestCase} for more
- * information on how to write and extend Application tests.
- * <p/>
- * To run this test, you can type: adb shell am instrument -w \ -e class
- * org.connectbot.HostListActivityTest \
- * org.connectbot.tests/android.test.InstrumentationTestRunner
- */
-public class HostListActivityTest extends ActivityInstrumentationTestCase2<HostListActivity> {
- private Activity mActivity;
-
- public HostListActivityTest() {
- super("org.connectbot", HostListActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- setActivityInitialTouchMode(false);
-
- mActivity = getActivity();
- }
-}
diff --git a/app/src/androidTest/java/org/connectbot/SettingsActivityTest.java b/app/src/androidTest/java/org/connectbot/SettingsActivityTest.java
deleted file mode 100644
index 6b79136..0000000
--- a/app/src/androidTest/java/org/connectbot/SettingsActivityTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * ConnectBot: simple, powerful, open-source SSH client for Android
- * Copyright 2007 Kenny Root, Jeffrey Sharkey
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.connectbot;
-
-import android.test.ActivityInstrumentationTestCase2;
-
-/**
- * This is a simple framework for a test of an Application. See
- * {@link android.test.ApplicationTestCase ApplicationTestCase} for more
- * information on how to write and extend Application tests.
- * <p/>
- * To run this test, you can type:
- * adb shell am instrument -w \
- * -e class org.connectbot.HostListActivityTest \
- * org.connectbot.tests/android.test.InstrumentationTestRunner
- */
-public class SettingsActivityTest extends
- ActivityInstrumentationTestCase2<SettingsActivity> {
-
- public SettingsActivityTest() {
- super("org.connectbot", SettingsActivity.class);
- }
-
- public void testOpenMenu() {
- SettingsActivity a = getActivity();
-
- a.openOptionsMenu();
-
- a.closeOptionsMenu();
- }
-
-}
diff --git a/app/src/androidTest/java/org/connectbot/TerminalBridgeTest.java b/app/src/androidTest/java/org/connectbot/TerminalBridgeTest.java
deleted file mode 100644
index bfa5e23..0000000
--- a/app/src/androidTest/java/org/connectbot/TerminalBridgeTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * ConnectBot: simple, powerful, open-source SSH client for Android
- * Copyright 2007 Kenny Root, Jeffrey Sharkey
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.connectbot;
-
-import android.test.AndroidTestCase;
-
-/**
- * @author Kenny Root
- *
- */
-public class TerminalBridgeTest extends AndroidTestCase {
- public void testShiftLock() throws SecurityException, NoSuchFieldException,
- IllegalArgumentException, IllegalAccessException {
-// TerminalBridge bridge = new TerminalBridge();
-// AbsTransport nullTransport = new NullTransport();
-//
-// // Make sure onKey will work when we call it
-// Field disconnected = TerminalBridge.class
-// .getDeclaredField("disconnected");
-// Field keymode = TerminalBridge.class.getDeclaredField("keymode");
-// Field transport = TerminalBridge.class.getDeclaredField("transport");
-//
-// disconnected.setAccessible(true);
-// keymode.setAccessible(true);
-// transport.setAccessible(true);
-//
-// disconnected.setBoolean(bridge, false);
-// keymode.set(bridge, PreferenceConstants.KEYMODE_RIGHT);
-// transport.set(bridge, nullTransport);
-//
-// // Begin tests
-// assertTrue("Meta state is " + bridge.getMetaState()
-// + " when it should be 0", bridge.getMetaState() == 0);
-//
-// KeyEvent shiftDown = new KeyEvent(KeyEvent.ACTION_DOWN,
-// KeyEvent.KEYCODE_SHIFT_LEFT);
-// bridge.onKey(null, shiftDown.getKeyCode(), shiftDown);
-//
-// assertTrue("Shift test: after shift press, meta state is "
-// + bridge.getMetaState() + " when it should be "
-// + TerminalBridge.META_SHIFT_ON,
-// bridge.getMetaState() == TerminalBridge.META_SHIFT_ON);
-//
-// KeyEvent shiftUp = KeyEvent.changeAction(shiftDown, KeyEvent.ACTION_UP);
-// bridge.onKey(null, shiftUp.getKeyCode(), shiftUp);
-//
-// assertTrue("Shift test: after shift release, meta state is "
-// + bridge.getMetaState() + " when it should be "
-// + TerminalBridge.META_SHIFT_ON,
-// bridge.getMetaState() == TerminalBridge.META_SHIFT_ON);
-//
-// KeyEvent letterAdown = new KeyEvent(KeyEvent.ACTION_DOWN,
-// KeyEvent.KEYCODE_A);
-// KeyEvent letterAup = KeyEvent.changeAction(letterAdown,
-// KeyEvent.ACTION_UP);
-//
-// bridge.onKey(null, letterAdown.getKeyCode(), letterAdown);
-// bridge.onKey(null, letterAup.getKeyCode(), letterAup);
-//
-// assertTrue("Shift test: after letter press and release, meta state is "
-// + bridge.getMetaState() + " when it should be 0", bridge
-// .getMetaState() == 0);
-//
-// bridge.onKey(null, shiftDown.getKeyCode(), shiftDown);
-// bridge.onKey(null, shiftUp.getKeyCode(), shiftUp);
-// bridge.onKey(null, shiftDown.getKeyCode(), shiftDown);
-// bridge.onKey(null, shiftUp.getKeyCode(), shiftUp);
-//
-// assertTrue("Shift lock test: after two shift presses, meta state is "
-// + bridge.getMetaState() + " when it should be "
-// + TerminalBridge.META_SHIFT_LOCK,
-// bridge.getMetaState() == TerminalBridge.META_SHIFT_LOCK);
-//
-// bridge.onKey(null, letterAdown.getKeyCode(), letterAdown);
-//
-// assertTrue(
-// "Shift lock test: after letter press, meta state is "
-// + bridge.getMetaState() + " when it should be "
-// + TerminalBridge.META_SHIFT_LOCK,
-// bridge.getMetaState() == TerminalBridge.META_SHIFT_LOCK);
-//
-// bridge.onKey(null, letterAup.getKeyCode(), letterAup);
-//
-// assertTrue(
-// "Shift lock test: after letter press and release, meta state is "
-// + bridge.getMetaState() + " when it should be "
-// + TerminalBridge.META_SHIFT_LOCK,
-// bridge.getMetaState() == TerminalBridge.META_SHIFT_LOCK);
- }
-}
diff --git a/robolectric-tests/.gitignore b/robolectric-tests/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/robolectric-tests/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/robolectric-tests/build.gradle b/robolectric-tests/build.gradle
new file mode 100644
index 0000000..ce644af
--- /dev/null
+++ b/robolectric-tests/build.gradle
@@ -0,0 +1,48 @@
+/*
+ * ConnectBot: simple, powerful, open-source SSH client for Android
+ * Copyright 2014 Kenny Root, Jeffrey Sharkey
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+apply plugin: 'java'
+
+evaluationDependsOn(':app')
+
+dependencies {
+ def androidModule = project(':app')
+ compile androidModule
+
+ testCompile androidModule.android.applicationVariants.toList().first().javaCompile.classpath
+ testCompile androidModule.android.applicationVariants.toList().first().javaCompile.outputs.files
+ testCompile files(androidModule.plugins.findPlugin("com.android.application").getBootClasspath())
+
+ // This gets the location of the SDK's Android Support Repo
+ androidModule.repositories {
+ all { ArtifactRepository repo ->
+ if (repo.url.toString().contains("extras/android/m2repository")) {
+ project.repositories.maven { url = repo.url }
+ }
+ }
+ }
+
+ testCompile 'junit:junit:4.10'
+ testCompile 'org.robolectric:robolectric:2.3'
+}
+
+tasks.withType(Test) {
+ scanForTestClasses = false
+ include "**/*Should.class"
+ include "**/*Test.class"
+ include "**/*Tests.class"
+} \ No newline at end of file
diff --git a/robolectric-tests/robolectric-tests.iml b/robolectric-tests/robolectric-tests.iml
new file mode 100644
index 0000000..7ebd6eb
--- /dev/null
+++ b/robolectric-tests/robolectric-tests.iml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$PROJECT_PATH$" external.system.id="GRADLE" external.system.module.group="connectbot" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
+ <component name="FacetManager">
+ <facet type="android-gradle" name="Android-Gradle">
+ <configuration>
+ <option name="GRADLE_PROJECT_PATH" value=":robolectric-tests" />
+ </configuration>
+ </facet>
+ <facet type="java-gradle" name="Java-Gradle">
+ <configuration>
+ <option name="BUILD_FOLDER_PATH" />
+ </configuration>
+ </facet>
+ </component>
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/build/classes/main" />
+ <output-test url="file://$MODULE_DIR$/build/classes/test" />
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
+ <excludeFolder url="file://$MODULE_DIR$/.gradle" />
+ <excludeFolder url="file://$MODULE_DIR$/build" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="app" exported="" />
+ <orderEntry type="library" exported="" scope="TEST" name="junit-4.10" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="robolectric-2.3" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="objenesis-1.3" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="sqlite4java-0.282" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="asm-5.0.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="asm-commons-5.0.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="asm-util-5.0.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="asm-analysis-5.0.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="commons-logging-1.1.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="commons-codec-1.3" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="httpclient-4.0.3" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="vtd-xml-2.11" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="support-v4-19.0.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="fest-util-1.2.5" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="fest-reflect-1.4.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="maven-ant-tasks-2.1.3" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="asm-tree-5.0.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="httpcore-4.0.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="ant-1.8.0" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="classworlds-1.1-alpha-2" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="plexus-container-default-1.0-alpha-9-stable-1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="plexus-utils-1.5.15" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="plexus-interpolation-1.11" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="maven-artifact-2.2.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="maven-artifact-manager-2.2.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="maven-model-2.2.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="maven-project-2.2.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="maven-error-diagnostics-2.2.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="maven-settings-2.2.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="wagon-file-1.0-beta-6" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="wagon-http-lightweight-1.0-beta-6" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="wagon-provider-api-1.0-beta-6" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="ant-launcher-1.8.0" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="maven-repository-metadata-2.2.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="backport-util-concurrent-3.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="maven-profile-2.2.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="maven-plugin-registry-2.2.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="wagon-http-shared-1.0-beta-6" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="xercesMinimal-1.9.6.2" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="nekohtml-1.9.6.2" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="_Users_kroot_AndroidStudioProjects_connectbot_app_build_intermediates_classes_debug" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="_Users_kroot_AndroidStudioProjects_connectbot_app_build_intermediates_dependency_cache_debug" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="android" level="project" />
+ </component>
+</module>
+
diff --git a/app/src/androidTest/java/org/connectbot/HostBeanTest.java b/robolectric-tests/src/test/java/org/connectbot/HostBeanTest.java
index a252aca..2f8eb2f 100644
--- a/app/src/androidTest/java/org/connectbot/HostBeanTest.java
+++ b/robolectric-tests/src/test/java/org/connectbot/HostBeanTest.java
@@ -18,25 +18,31 @@
package org.connectbot;
import org.connectbot.bean.HostBean;
-import org.connectbot.mock.BeanTestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
-import android.test.AndroidTestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.connectbot.mock.BeanAssertions.assertMeetsEqualsContract;
+import static org.connectbot.mock.BeanAssertions.assertMeetsHashCodeContract;
/**
* @author Kenny Root
- *
*/
-public class HostBeanTest extends AndroidTestCase {
+@Config(manifest = "../app/src/main/AndroidManifest.xml", emulateSdk = 16)
+@RunWith(RobolectricTestRunner.class)
+public class HostBeanTest {
private static final String[] FIELDS = { "nickname", "username",
"hostname", "port" };
- HostBean host1;
- HostBean host2;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ private HostBean host1;
+ private HostBean host2;
+ @Before
+ public void setUp() {
host1 = new HostBean();
host1.setNickname("Home");
host1.setUsername("bob");
@@ -50,19 +56,16 @@ public class HostBeanTest extends AndroidTestCase {
host2.setPort(22);
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testIdEquality() {
+ @Test
+ public void id_Equality() {
host1.setId(1);
host2.setId(1);
assertTrue(host1.equals(host2));
assertTrue(host1.hashCode() == host2.hashCode());
}
- public void testIdInequality() {
+ @Test
+ public void id_Inequality() {
host1.setId(1);
host2.setId(2);
// HostBeans shouldn't be equal when their IDs are not the same
@@ -72,7 +75,8 @@ public class HostBeanTest extends AndroidTestCase {
host1.hashCode() == host2.hashCode());
}
- public void testIdEquality2() {
+ @Test
+ public void id_Equality2() {
host1.setId(1);
host2.setId(1);
host2.setNickname("Work");
@@ -86,11 +90,13 @@ public class HostBeanTest extends AndroidTestCase {
host1.hashCode() == host2.hashCode());
}
+ @Test
public void testBeanMeetsEqualsContract() {
- BeanTestCase.assertMeetsEqualsContract(HostBean.class, FIELDS);
+ assertMeetsEqualsContract(HostBean.class, FIELDS);
}
+ @Test
public void testBeanMeetsHashCodeContract() {
- BeanTestCase.assertMeetsHashCodeContract(HostBean.class, FIELDS);
+ assertMeetsHashCodeContract(HostBean.class, FIELDS);
}
}
diff --git a/app/src/androidTest/java/org/connectbot/SelectionAreaTest.java b/robolectric-tests/src/test/java/org/connectbot/SelectionAreaTest.java
index 93e0293..6e4134a 100644
--- a/app/src/androidTest/java/org/connectbot/SelectionAreaTest.java
+++ b/robolectric-tests/src/test/java/org/connectbot/SelectionAreaTest.java
@@ -18,18 +18,26 @@
package org.connectbot;
import org.connectbot.bean.SelectionArea;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
-import android.test.AndroidTestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
/**
* @author Kenny Root
*
*/
-public class SelectionAreaTest extends AndroidTestCase {
+@Config(manifest = "../app/src/main/AndroidManifest.xml", emulateSdk = 16)
+@RunWith(RobolectricTestRunner.class)
+public class SelectionAreaTest {
private static final int WIDTH = 80;
private static final int HEIGHT = 24;
- public void testCreate() {
+ @Test
+ public void createSelectionArea() {
SelectionArea sa = new SelectionArea();
assertTrue(sa.getLeft() == 0);
@@ -39,7 +47,8 @@ public class SelectionAreaTest extends AndroidTestCase {
assertTrue(sa.isSelectingOrigin());
}
- public void testCheckMovement() {
+ @Test
+ public void checkMovement() {
SelectionArea sa = new SelectionArea();
sa.setBounds(WIDTH, HEIGHT);
@@ -65,7 +74,8 @@ public class SelectionAreaTest extends AndroidTestCase {
assertTrue(sa.getBottom() == 0);
}
- public void testBounds() {
+ @Test
+ public void boundsAreCorrect() {
SelectionArea sa = new SelectionArea();
sa.setBounds(WIDTH, HEIGHT);
@@ -99,7 +109,8 @@ public class SelectionAreaTest extends AndroidTestCase {
sa.getTop() == 0);
}
- public void testSetThenMove() {
+ @Test
+ public void setThenMove() {
SelectionArea sa = new SelectionArea();
sa.setBounds(WIDTH, HEIGHT);
diff --git a/app/src/androidTest/java/org/connectbot/mock/BeanTestCase.java b/robolectric-tests/src/test/java/org/connectbot/mock/BeanAssertions.java
index 5d13d9f..cf7b7de 100644
--- a/app/src/androidTest/java/org/connectbot/mock/BeanTestCase.java
+++ b/robolectric-tests/src/test/java/org/connectbot/mock/BeanAssertions.java
@@ -7,11 +7,17 @@ import junit.framework.TestCase;
import java.lang.reflect.Field;
-public class BeanTestCase extends TestCase {
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+public class BeanAssertions {
private static final String TEST_STRING_VAL1 = "Some Value";
private static final String TEST_STRING_VAL2 = "Some Other Value";
+ private BeanAssertions() {
+ }
+
public static void assertMeetsEqualsContract(Class<?> classUnderTest,
String[] fieldNames) {
Object o1;
diff --git a/app/src/androidTest/java/org/connectbot/mock/NullOutputStream.java b/robolectric-tests/src/test/java/org/connectbot/mock/NullOutputStream.java
index 79b8e72..79b8e72 100644
--- a/app/src/androidTest/java/org/connectbot/mock/NullOutputStream.java
+++ b/robolectric-tests/src/test/java/org/connectbot/mock/NullOutputStream.java
diff --git a/app/src/androidTest/java/org/connectbot/mock/NullTransport.java b/robolectric-tests/src/test/java/org/connectbot/mock/NullTransport.java
index d841e6a..d841e6a 100644
--- a/app/src/androidTest/java/org/connectbot/mock/NullTransport.java
+++ b/robolectric-tests/src/test/java/org/connectbot/mock/NullTransport.java
diff --git a/app/src/androidTest/java/org/connectbot/util/PubkeyUtilsTest.java b/robolectric-tests/src/test/java/org/connectbot/util/PubkeyUtilsTest.java
index 1eb1ee6..0843e74 100644
--- a/app/src/androidTest/java/org/connectbot/util/PubkeyUtilsTest.java
+++ b/robolectric-tests/src/test/java/org/connectbot/util/PubkeyUtilsTest.java
@@ -17,6 +17,11 @@
package org.connectbot.util;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
import java.math.BigInteger;
import java.security.KeyPair;
import java.security.NoSuchAlgorithmException;
@@ -27,14 +32,18 @@ import java.security.interfaces.ECPublicKey;
import java.security.interfaces.RSAPublicKey;
import java.util.Arrays;
-import android.test.AndroidTestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* @author Kenny Root
- *
*/
-public class PubkeyUtilsTest extends AndroidTestCase {
- public void testEncodeHex_Null_Failure() throws Exception {
+@Config(manifest = "../app/src/main/AndroidManifest.xml", emulateSdk = 16)
+@RunWith(RobolectricTestRunner.class)
+public class PubkeyUtilsTest {
+ @Test
+ public void encodeHex_Null_Failure() throws Exception {
try {
PubkeyUtils.encodeHex(null);
fail("Should throw null pointer exception when argument is null");
@@ -42,7 +51,9 @@ public class PubkeyUtilsTest extends AndroidTestCase {
// success
}
}
- public void testEncodeHex_Success() throws Exception {
+
+ @Test
+ public void encodeHex_Success() throws Exception {
byte[] input = {(byte) 0xFF, 0x00, (byte) 0xA5, 0x5A, 0x12, 0x23};
String expected = "ff00a55a1223";
@@ -50,7 +61,8 @@ public class PubkeyUtilsTest extends AndroidTestCase {
PubkeyUtils.encodeHex(input), expected);
}
- public void testSha256_Empty_Success() throws Exception {
+ @Test
+ public void sha256_Empty_Success() throws Exception {
byte[] empty_hashed = new byte[] {
(byte) 0xe3, (byte) 0xb0, (byte) 0xc4, (byte) 0x42,
(byte) 0x98, (byte) 0xfc, (byte) 0x1c, (byte) 0x14,
@@ -234,19 +246,23 @@ public class PubkeyUtilsTest extends AndroidTestCase {
private static final BigInteger DSA_KEY_priv = new BigInteger("2950e4774fb2fffb5d33c937f0b58ffb0d45c200", 16);
private static final BigInteger DSA_KEY_pub = new BigInteger("0087b82cdf3232db3bec0d00e96c8393bc7f5629551ea1a00888961cf56e80a36f2a7b316bc10b1d367a5ea374235c9361a472a9176f6cf61f708b86a52b4fae814abd1f1bdd16eea94aea9281851032b1bad7567624c615d6899ca1c94ad614f14e767e49d2ba5223cd113a0d02b66183653cd346ae76d85843afe66520904274", 16);
- public void testGetOidFromPkcs8Encoded_Ec_NistP256() throws Exception {
+ @Test
+ public void getOidFromPkcs8Encoded_Ec_NistP256() throws Exception {
assertEquals("1.2.840.10045.2.1", PubkeyUtils.getOidFromPkcs8Encoded(EC_KEY_PKCS8));
}
- public void testGetOidFromPkcs8Encoded_Rsa() throws Exception {
+ @Test
+ public void getOidFromPkcs8Encoded_Rsa() throws Exception {
assertEquals("1.2.840.113549.1.1.1", PubkeyUtils.getOidFromPkcs8Encoded(RSA_KEY_PKCS8));
}
- public void testGetOidFromPkcs8Encoded_Dsa() throws Exception {
+ @Test
+ public void getOidFromPkcs8Encoded_Dsa() throws Exception {
assertEquals("1.2.840.10040.4.1", PubkeyUtils.getOidFromPkcs8Encoded(DSA_KEY_PKCS8));
}
- public void testGetOidFromPkcs8Encoded_Null_Failure() throws Exception {
+ @Test
+ public void getOidFromPkcs8Encoded_Null_Failure() throws Exception {
try {
PubkeyUtils.getOidFromPkcs8Encoded(null);
fail("Should throw NoSuchAlgorithmException");
@@ -254,7 +270,8 @@ public class PubkeyUtilsTest extends AndroidTestCase {
}
}
- public void testGetOidFromPkcs8Encoded_NotCorrectDer_Failure() throws Exception {
+ @Test
+ public void getOidFromPkcs8Encoded_NotCorrectDer_Failure() throws Exception {
try {
PubkeyUtils.getOidFromPkcs8Encoded(new byte[] { 0x30, 0x01, 0x00 });
fail("Should throw NoSuchAlgorithmException");
@@ -262,19 +279,22 @@ public class PubkeyUtilsTest extends AndroidTestCase {
}
}
- public void testGetAlgorithmForOid_Ecdsa() throws Exception {
+ @Test
+ public void getAlgorithmForOid_Ecdsa() throws Exception {
assertEquals("EC", PubkeyUtils.getAlgorithmForOid("1.2.840.10045.2.1"));
}
- public void testGetAlgorithmForOid_Rsa() throws Exception {
+ @Test
+ public void getAlgorithmForOid_Rsa() throws Exception {
assertEquals("RSA", PubkeyUtils.getAlgorithmForOid("1.2.840.113549.1.1.1"));
}
- public void testGetAlgorithmForOid_Dsa() throws Exception {
+ public void getAlgorithmForOid_Dsa() throws Exception {
assertEquals("DSA", PubkeyUtils.getAlgorithmForOid("1.2.840.10040.4.1"));
}
- public void testGetAlgorithmForOid_NullInput_Failure() throws Exception {
+ @Test
+ public void getAlgorithmForOid_NullInput_Failure() throws Exception {
try {
PubkeyUtils.getAlgorithmForOid(null);
fail("Should throw NoSuchAlgorithmException");
@@ -282,7 +302,8 @@ public class PubkeyUtilsTest extends AndroidTestCase {
}
}
- public void testGetAlgorithmForOid_UnknownOid_Failure() throws Exception {
+ @Test
+ public void getAlgorithmForOid_UnknownOid_Failure() throws Exception {
try {
PubkeyUtils.getAlgorithmForOid("1.3.66666.2000.4000.1");
fail("Should throw NoSuchAlgorithmException");
@@ -290,7 +311,8 @@ public class PubkeyUtilsTest extends AndroidTestCase {
}
}
- public void testRecoverKeyPair_Dsa() throws Exception {
+ @Test
+ public void recoverKeyPair_Dsa() throws Exception {
KeyPair kp = PubkeyUtils.recoverKeyPair(DSA_KEY_PKCS8);
DSAPublicKey pubKey = (DSAPublicKey) kp.getPublic();
@@ -303,7 +325,8 @@ public class PubkeyUtilsTest extends AndroidTestCase {
assertEquals(params.getQ(), DSA_KEY_Q);
}
- public void testRecoverKeyPair_Rsa() throws Exception {
+ @Test
+ public void recoverKeyPair_Rsa() throws Exception {
KeyPair kp = PubkeyUtils.recoverKeyPair(RSA_KEY_PKCS8);
RSAPublicKey pubKey = (RSAPublicKey) kp.getPublic();
@@ -312,7 +335,8 @@ public class PubkeyUtilsTest extends AndroidTestCase {
assertEquals(RSA_KEY_E, pubKey.getPublicExponent());
}
- public void testRecoverKeyPair_Ec() throws Exception {
+ @Test
+ public void recoverKeyPair_Ec() throws Exception {
KeyPair kp = PubkeyUtils.recoverKeyPair(EC_KEY_PKCS8);
ECPublicKey pubKey = (ECPublicKey) kp.getPublic();
@@ -335,7 +359,8 @@ public class PubkeyUtilsTest extends AndroidTestCase {
}
}
- public void testRecoverPublicKey_FakeKey_Failure() throws Exception {
+ @Test
+ public void recoverPublicKey_FakeKey_Failure() throws Exception {
try {
PubkeyUtils.recoverPublicKey(null, new MyPrivateKey());
fail("Should not accept unknown key types");
diff --git a/settings.gradle b/settings.gradle
index e7b4def..61ac55a 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':app'
+include ':app', ':robolectric-tests'