aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2015-08-28 00:17:24 -0700
committerKenny Root <kenny@the-b.org>2015-08-28 00:17:24 -0700
commit1b09070fbf3f1224a5d509c5954ef9560eaf9ba1 (patch)
treec8550931954db1ce4bddc2a9fb6d80b0056cfba4
parentb3f5f9b41c89f74792f2a027ed2ab31a60c88b5e (diff)
parentf6ef2b5e6a4f33ce1d14c5a0d802b30a446ae2bf (diff)
downloadconnectbot-1b09070fbf3f1224a5d509c5954ef9560eaf9ba1.tar.gz
connectbot-1b09070fbf3f1224a5d509c5954ef9560eaf9ba1.tar.bz2
connectbot-1b09070fbf3f1224a5d509c5954ef9560eaf9ba1.zip
Merge pull request #157 from kruton/android-test
Create test for local connections
-rw-r--r--.gitignore4
-rw-r--r--.idea/codeStyleSettings.xml28
-rw-r--r--.travis.yml4
-rw-r--r--app/app.iml32
-rw-r--r--app/build.gradle71
-rw-r--r--app/src/androidTest/java/org/connectbot/StartupTest.java161
-rw-r--r--app/src/main/java/org/connectbot/ConsoleActivity.java6
-rw-r--r--app/src/main/java/org/connectbot/util/HostDatabase.java16
-rw-r--r--app/src/main/res/values/viewpager.xml23
-rw-r--r--app/src/test/java/android/net/http/AndroidHttpClient.java25
-rw-r--r--build.xml133
-rw-r--r--config/jacoco.gradle8
-rw-r--r--connectbot.iml2
-rw-r--r--gradle.properties1
14 files changed, 328 insertions, 186 deletions
diff --git a/.gitignore b/.gitignore
index bedf6b7..fee0237 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,3 @@
-# generated files
-bin/
-gen/
-
# translation artifacts
launchpad-*.tar.gz
diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml
index 659f221..1ca6443 100644
--- a/.idea/codeStyleSettings.xml
+++ b/.idea/codeStyleSettings.xml
@@ -42,6 +42,34 @@
<AndroidXmlCodeStyleSettings>
<option name="USE_CUSTOM_SETTINGS" value="true" />
</AndroidXmlCodeStyleSettings>
+ <Objective-C-extensions>
+ <option name="GENERATE_INSTANCE_VARIABLES_FOR_PROPERTIES" value="ASK" />
+ <option name="RELEASE_STYLE" value="IVAR" />
+ <option name="TYPE_QUALIFIERS_PLACEMENT" value="BEFORE" />
+ <file>
+ <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
+ <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
+ <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
+ <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
+ <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
+ <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
+ <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
+ <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
+ <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
+ </file>
+ <class>
+ <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
+ <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
+ <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
+ <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
+ <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
+ <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
+ </class>
+ <extensions>
+ <pair source="cpp" header="h" />
+ <pair source="c" header="h" />
+ </extensions>
+ </Objective-C-extensions>
<XML>
<option name="XML_ALIGN_ATTRIBUTES" value="false" />
<option name="XML_WHITE_SPACE_AROUND_CDATA" value="1" />
diff --git a/.travis.yml b/.travis.yml
index 540cff3..b27f36f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -47,14 +47,14 @@ before_script:
android:
components:
- build-tools-22.0.1
- - android-22
+ - android-23
- extra-android-support
- extra-android-m2repository
license:
- '.+'
script:
- - ./gradlew build check jacocoTestDebugReport
+ - ./gradlew build check jacocoUnitTestDebugReport
- ./scripts/check-lint-count.sh app/build/outputs/lint-results.xml $HOME/.cache/lint/issue-count.txt $HOME/.cache/lint/issue-count.txt
after_success: ./gradlew coveralls
diff --git a/app/app.iml b/app/app.iml
index 827213f..e6fba85 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -12,9 +12,13 @@
<option name="SELECTED_TEST_ARTIFACT" value="_unit_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
- <option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugUnitTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugUnitTestSources" />
+ <afterSyncTasks>
+ <task>generateDebugSources</task>
+ <task>mockableAndroidJar</task>
+ <task>prepareDebugUnitTestDependencies</task>
+ </afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
@@ -23,7 +27,7 @@
</configuration>
</facet>
</component>
- <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
@@ -33,7 +37,7 @@
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
- <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
@@ -69,7 +73,9 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
- <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.1/jars" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.0/jars" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.0.0/jars" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
@@ -82,38 +88,42 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
+ <excludeFolder url="file://$MODULE_DIR$/build/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
+ <excludeFolder url="file://$MODULE_DIR$/build/reports" />
+ <excludeFolder url="file://$MODULE_DIR$/build/test-results" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
- <orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
+ <orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
- <orderEntry type="library" exported="" scope="TEST" name="mockable-android-22" level="project" />
<orderEntry type="library" exported="" name="jzlib-1.1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="maven-ant-tasks-2.1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="ant-1.8.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="assertj-core-1.7.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="accessibility-test-framework-1.0" level="project" />
- <orderEntry type="library" exported="" name="support-annotations-22.2.1" level="project" />
- <orderEntry type="library" exported="" scope="TEST" name="ant-launcher-1.8.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="asm-commons-5.0.1" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="ant-launcher-1.8.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="asm-5.0.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="shadows-core-3.0" level="project" />
+ <orderEntry type="library" exported="" name="appcompat-v7-23.0.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="asm-util-5.0.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="bcprov-jdk16-1.46" level="project" />
+ <orderEntry type="library" exported="" name="support-v4-23.0.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="mockito-core-1.10.19" level="project" />
<orderEntry type="library" exported="" name="jsocks-1.0.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="objenesis-2.1" level="project" />
+ <orderEntry type="library" exported="" name="support-annotations-23.0.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="icu4j-53.1" level="project" />
- <orderEntry type="library" exported="" name="support-v4-22.2.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="robolectric-resources-3.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="robolectric-annotations-3.0" level="project" />
+ <orderEntry type="library" exported="" name="design-23.0.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="sqlite4java-0.282" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="asm-tree-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="robolectric-utils-3.0" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="asm-analysis-5.0.1" level="project" />
<orderEntry type="library" exported="" name="sshlib-2.2.0" level="project" />
- <orderEntry type="library" exported="" scope="TEST" name="vtd-xml-2.11" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
+ <orderEntry type="library" exported="" scope="TEST" name="vtd-xml-2.11" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="robolectric-3.0" level="project" />
</component>
diff --git a/app/build.gradle b/app/build.gradle
index e791fc9..e02e5bd 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -12,17 +12,11 @@ buildscript {
dependencies {
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.1x'
- classpath 'com.android.tools.build:gradle:1.2.3'
+ classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
}
}
-repositories {
- maven {
- url 'https://dl.bintray.com/connectbot/maven'
- }
-}
-
dependencies {
compile 'org.connectbot:sshlib:2.2.0'
@@ -36,36 +30,51 @@ dependencies {
}
android {
- compileSdkVersion 22
+ compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "org.connectbot"
minSdkVersion 8
- targetSdkVersion 22
+ targetSdkVersion 23
ndk {
moduleName "com_google_ase_Exec"
ldLibs "log"
}
- lintOptions {
- abortOnError false
- lintConfig file('lint.xml')
- }
-
testApplicationId "org.connectbot.tests"
- testInstrumentationRunner "android.test.InstrumentationTestRunner"
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
- release
+ if (project.hasProperty('keystorePassword')) {
+ release {
+ storeFile file(property('keystoreFile'))
+ storePassword property('keystorePassword')
+ keyAlias property('keystoreAlias')
+ keyPassword property('keystorePassword')
+ }
+ }
}
dependencies {
- compile "com.android.support:support-v4:22.2.1"
- compile "com.android.support:appcompat-v7:22.2.1"
- compile "com.android.support:design:22.2.1"
+ compile "com.android.support:support-v4:23.0.0"
+ compile "com.android.support:appcompat-v7:23.0.0"
+ compile "com.android.support:design:23.0.0"
+
+ androidTestCompile('com.android.support.test:runner:0.3') {
+ exclude module: "support-annotations"
+ }
+ androidTestCompile('com.android.support.test:rules:0.3') {
+ exclude module: "support-annotations"
+ }
+ androidTestCompile('com.android.support.test.espresso:espresso-core:2.2') {
+ exclude module: "support-annotations"
+ }
+ androidTestCompile('com.android.support.test.espresso:espresso-intents:2.2') {
+ exclude module: "support-annotations"
+ }
}
buildTypes {
@@ -74,8 +83,11 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
if (project.hasProperty('keystorePassword')) {
+ //noinspection GroovyAssignabilityCheck
signingConfig signingConfigs.release
}
+
+ return true // this silences Android Studio's groovy inspector
}
debug {
@@ -83,6 +95,16 @@ android {
testCoverageEnabled true
}
}
+
+ lintOptions {
+ abortOnError false
+ lintConfig file('lint.xml')
+ }
+
+ packagingOptions {
+ exclude 'META-INF/LICENSE.txt'
+ exclude 'LICENSE.txt'
+ }
}
def getGitDescription = { ->
@@ -104,17 +126,10 @@ android.applicationVariants.all { variant ->
ext.env = System.getenv()
def buildNumber = getGitDescription()
if (buildNumber != null) {
- File valuesFile = file("${buildDir}/intermediates/res/${variant.dirName}/values/values.xml")
+ File valuesFile = file("${buildDir}/intermediates/res/merged/${variant.dirName}/values/values.xml")
String content = valuesFile.getText('UTF-8')
content = content.replaceAll(/\(working copy\)/, buildNumber)
valuesFile.write(content, 'UTF-8')
}
}
-}
-
-if (project.hasProperty('keystorePassword')) {
- android.signingConfigs.release.storeFile file(keystoreFile)
- android.signingConfigs.release.storePassword keystorePassword
- android.signingConfigs.release.keyAlias keystoreAlias
- android.signingConfigs.release.keyPassword keystorePassword
-}
+} \ No newline at end of file
diff --git a/app/src/androidTest/java/org/connectbot/StartupTest.java b/app/src/androidTest/java/org/connectbot/StartupTest.java
new file mode 100644
index 0000000..ea5b584
--- /dev/null
+++ b/app/src/androidTest/java/org/connectbot/StartupTest.java
@@ -0,0 +1,161 @@
+package org.connectbot;
+
+import org.connectbot.bean.HostBean;
+import org.connectbot.util.HostDatabase;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.espresso.ViewAssertion;
+import android.support.test.espresso.intent.Intents;
+import android.support.test.espresso.matcher.BoundedMatcher;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.ImageView;
+
+import static android.support.test.espresso.Espresso.onData;
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.action.ViewActions.click;
+import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
+import static android.support.test.espresso.action.ViewActions.longClick;
+import static android.support.test.espresso.action.ViewActions.pressBack;
+import static android.support.test.espresso.action.ViewActions.pressKey;
+import static android.support.test.espresso.action.ViewActions.pressMenuKey;
+import static android.support.test.espresso.action.ViewActions.typeText;
+import static android.support.test.espresso.assertion.ViewAssertions.matches;
+import static android.support.test.espresso.intent.Intents.intended;
+import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent;
+import static android.support.test.espresso.matcher.ViewMatchers.hasDescendant;
+import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static android.support.test.espresso.matcher.ViewMatchers.withId;
+import static android.support.test.espresso.matcher.ViewMatchers.withText;
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+
+@RunWith(AndroidJUnit4.class)
+public class StartupTest {
+ @Rule
+ public final ActivityTestRule<HostListActivity> mActivityRule = new ActivityTestRule<>(
+ HostListActivity.class, false, false);
+
+ @Before
+ public void makeDatabasePristine() {
+ HostDatabase db = new HostDatabase(InstrumentationRegistry.getTargetContext());
+ db.resetDatabase();
+
+ mActivityRule.launchActivity(new Intent());
+ }
+
+ @Test
+ public void localConnectionDisconnectFromHostList() {
+ startNewLocalConnection();
+
+ onView(withId(R.id.console_flip)).perform(closeSoftKeyboard(), pressBack());
+
+ // Make sure we're still connected.
+ onData(withHostNickname("Local")).inAdapterView(withId(android.R.id.list))
+ .check(hostConnected())
+ .perform(longClick());
+
+ // Click on the disconnect context menu item.
+ onView(withText(R.string.list_host_disconnect)).check(matches(isDisplayed())).perform(click());
+
+ // Now make sure we're disconnected.
+ onData(withHostNickname("Local")).inAdapterView(withId(android.R.id.list))
+ .check(hostDisconnected());
+ }
+
+ @Test
+ public void localConnectionDisconnectConsoleActivity() {
+ startNewLocalConnection();
+
+ onView(withId(R.id.console_flip)).perform(pressMenuKey());
+
+ // Click on the disconnect context menu item.
+ onView(withText(R.string.list_host_disconnect)).check(matches(isDisplayed())).perform(click());
+
+ // Now make sure we're disconnected.
+ onData(withHostNickname("Local")).inAdapterView(withId(android.R.id.list))
+ .check(hostDisconnected());
+ }
+
+ private void startNewLocalConnection() {
+ onView(withId(R.id.transport_selection)).perform(click());
+ onData(allOf(is(instanceOf(String.class)), is("local"))).perform(click());
+ onView(withId(R.id.front_quickconnect)).perform(typeText("Local"));
+
+ Intents.init();
+ onView(withId(R.id.front_quickconnect)).perform(pressKey(KeyEvent.KEYCODE_ENTER));
+ intended(hasComponent(ConsoleActivity.class.getName()));
+ Intents.release();
+
+ onView(withId(R.id.console_flip)).check(matches(
+ hasDescendant(allOf(isDisplayed(), withId(R.id.terminal_view)))));
+ }
+
+ /**
+ * Matches the nickname of a {@link HostBean}.
+ */
+ public static Matcher<Object> withHostNickname(final String content) {
+ return new BoundedMatcher<Object, HostBean>(HostBean.class) {
+ @Override
+ public boolean matchesSafely(HostBean host) {
+ return host.getNickname().matches(content);
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("with host nickname '" + content + "'");
+ }
+ };
+ }
+
+ /**
+ * Matches the drawable state on an ImageView that is set with setImageState.
+ */
+ public static Matcher<View> withDrawableState(final int expectedState) {
+ return new TypeSafeMatcher<View>() {
+ @Override
+ public boolean matchesSafely(View view) {
+ if (!(view instanceof ImageView)) {
+ return false;
+ }
+
+ int[] states = view.getDrawableState();
+ for (int state : states) {
+ if (state == expectedState) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("with drawable state '" + expectedState + "'");
+ }
+ };
+ }
+
+ @NonNull
+ private ViewAssertion hostDisconnected() {
+ return matches(hasDescendant(allOf(withId(android.R.id.icon),
+ withDrawableState(android.R.attr.state_expanded))));
+ }
+
+ @NonNull
+ private ViewAssertion hostConnected() {
+ return matches(hasDescendant(allOf(withId(android.R.id.icon),
+ withDrawableState(android.R.attr.state_checked))));
+ }
+}
diff --git a/app/src/main/java/org/connectbot/ConsoleActivity.java b/app/src/main/java/org/connectbot/ConsoleActivity.java
index 0e23979..4d6b114 100644
--- a/app/src/main/java/org/connectbot/ConsoleActivity.java
+++ b/app/src/main/java/org/connectbot/ConsoleActivity.java
@@ -1357,7 +1357,7 @@ public class ConsoleActivity extends AppCompatActivity implements BridgeDisconne
// and add our terminal view control, using index to place behind overlay
final TerminalView terminal = new TerminalView(container.getContext(), bridge);
- terminal.setId(R.id.console_flip);
+ terminal.setId(R.id.terminal_view);
view.addView(terminal, 0);
// Tag the view with its bridge so it can be retrieved later.
@@ -1382,7 +1382,7 @@ public class ConsoleActivity extends AppCompatActivity implements BridgeDisconne
}
View view = (View) object;
- TerminalView terminal = (TerminalView) view.findViewById(R.id.console_flip);
+ TerminalView terminal = (TerminalView) view.findViewById(R.id.terminal_view);
HostBean host = terminal.bridge.host;
int itemIndex = POSITION_NONE;
@@ -1435,7 +1435,7 @@ public class ConsoleActivity extends AppCompatActivity implements BridgeDisconne
public TerminalView getCurrentTerminalView() {
View currentView = pager.findViewWithTag(getBridgeAtPosition(pager.getCurrentItem()));
if (currentView == null) return null;
- return (TerminalView) currentView.findViewById(R.id.console_flip);
+ return (TerminalView) currentView.findViewById(R.id.terminal_view);
}
}
}
diff --git a/app/src/main/java/org/connectbot/util/HostDatabase.java b/app/src/main/java/org/connectbot/util/HostDatabase.java
index d8cdf09..f721aeb 100644
--- a/app/src/main/java/org/connectbot/util/HostDatabase.java
+++ b/app/src/main/java/org/connectbot/util/HostDatabase.java
@@ -32,6 +32,7 @@ import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
+import android.support.annotation.VisibleForTesting;
import android.util.Log;
import com.trilead.ssh2.KnownHosts;
@@ -155,6 +156,10 @@ public class HostDatabase extends RobustSQLiteOpenHelper {
public void onCreate(SQLiteDatabase db) {
super.onCreate(db);
+ createTables(db);
+ }
+
+ private void createTables(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE_HOSTS
+ " (_id INTEGER PRIMARY KEY, "
+ FIELD_HOST_NICKNAME + " TEXT, "
@@ -203,6 +208,17 @@ public class HostDatabase extends RobustSQLiteOpenHelper {
db.execSQL(CREATE_TABLE_COLOR_DEFAULTS_INDEX);
}
+ @VisibleForTesting
+ public void resetDatabase() {
+ SQLiteDatabase db = getWritableDatabase();
+ db.execSQL("DROP TABLE IF EXISTS " + TABLE_HOSTS);
+ db.execSQL("DROP TABLE IF EXISTS " + TABLE_PORTFORWARDS);
+ db.execSQL("DROP TABLE IF EXISTS " + TABLE_COLORS);
+ db.execSQL("DROP TABLE IF EXISTS " + TABLE_COLOR_DEFAULTS);
+ createTables(db);
+ db.close();
+ }
+
@Override
public void onRobustUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) throws SQLiteException {
// Versions of the database before the Android Market release will be
diff --git a/app/src/main/res/values/viewpager.xml b/app/src/main/res/values/viewpager.xml
new file mode 100644
index 0000000..cc73c50
--- /dev/null
+++ b/app/src/main/res/values/viewpager.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ ConnectBot: simple, powerful, open-source SSH client for Android
+ ~ Copyright 2015 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.
+ -->
+
+<resources>
+ <!-- This is so that ConsoleActivity has something to refer to when
+ setting the ID of the TerminalView instances in the ViewPager. -->
+ <item name="terminal_view" type="id"/>
+</resources>
diff --git a/app/src/test/java/android/net/http/AndroidHttpClient.java b/app/src/test/java/android/net/http/AndroidHttpClient.java
new file mode 100644
index 0000000..701510b
--- /dev/null
+++ b/app/src/test/java/android/net/http/AndroidHttpClient.java
@@ -0,0 +1,25 @@
+/*
+ * ConnectBot: simple, powerful, open-source SSH client for Android
+ * Copyright 2015 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 android.net.http;
+
+/**
+ * This is a work-around until Robolectric 3.1 comes out with the fix for this.
+ * https://github.com/robolectric/robolectric/issues/1862
+ */
+public class AndroidHttpClient {
+}
diff --git a/build.xml b/build.xml
deleted file mode 100644
index 376125b..0000000
--- a/build.xml
+++ /dev/null
@@ -1,133 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vim: set ts=4 sw=4 et: -->
-<project name="ConnectBot" default="help">
-
-<!-- Begin custom ConnectBot stuff -->
-
- <!-- Output directory for .po files. -->
- <property name="locale.dir" value="locale" />
-
- <!-- Default args to pass to a2po for .po generation. -->
- <property name="a2po.args" value="--groups strings --template fortune/fortune.pot --layout 'fortune/fortune-%(locale)s.po'"/>
-
- <!-- File names for launchpad translations. -->
- <property name="launchpad.export.file" value="launchpad-export.tar.gz"/>
- <property name="launchpad.import.file" value="launchpad-import.tar.gz"/>
-
- <target name="-pre-build" depends="update-version"/>
-
- <target name="help">
- <!-- displays starts at col 13
- |13 80| -->
- <echo>Android Ant Build. Available targets:</echo>
- <echo> help: Displays this help.</echo>
- <echo> clean: Removes output files created by other targets.</echo>
- <echo> compile: Compiles project's .java files into .class files.</echo>
- <echo> debug: Builds the application and signs it with a debug key.</echo>
- <echo> release: Builds the application. The generated apk file must be</echo>
- <echo> signed before it is published.</echo>
- <echo> install: Installs/reinstalls the debug package onto a running</echo>
- <echo> emulator or device.</echo>
- <echo> If the application was previously installed, the</echo>
- <echo> signatures must match.</echo>
- <echo> uninstall: Uninstalls the application from a running emulator or</echo>
- <echo> device.</echo>
- <echo> translations-import: Import translations from a Launchpad-style</echo>
- <echo> Rosetta translation.</echo>
- <echo> translations-export: Export translations to a Launchpad-style</echo>
- <echo> Rosetta translation.</echo>
-
- </target>
-
- <target name="update-version" description="Updates the Version.java file with current Git revision">
- <echo>Updating resources with Git revision and build date...</echo>
-
- <tstamp>
- <format property="build.date" pattern="yyyy.MM.dd" />
- </tstamp>
-
- <!-- Get the version name from the android manifest, will en up in property ${manifest.android:versionName} -->
- <xpath input="AndroidManifest.xml" expression="/manifest/@android:versionName"
- output="manifest.version.name" />
-
- <!-- tell git to ignore changes to the version xml -->
- <exec executable="git">
- <arg line="update-index --assume-unchanged res/values/version.xml"/>
- </exec>
-
- <!-- find out the description of the current Git commit -->
- <exec executable="git" outputproperty="git.revision">
- <arg line="describe --match 'v[0-9]*' --dirty"/>
- </exec>
-
- <!-- write out to res/values/version.xml -->
- <echo file="${resource.absolute.dir}/values/version.xml" encoding="utf8"><![CDATA[<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="msg_version" translatable="false">${ant.project.name} ${manifest.version.name} (${git.revision} ${build.date})</string>
-</resources>
-]]></echo>
-
- <echo>Updated "msg_version" to: ${ant.project.name} ${manifest.version.name} (${git.revision} ${build.date})</echo>
- </target>
-
- <!-- Translations come from launchpad.net and are placed in the
- locale/ subdirectory. -->
- <target name="translations-import">
- <untar src="${launchpad.export.file}" dest="${locale.dir}" compression="gzip"/>
- <exec executable="a2po" failonerror="true">
- <arg value="import"/>
- <arg line="${a2po.args}"/>
- </exec>
- </target>
-
- <!-- Translations are to be uploaded to launchpad.net as a tar ball
- created from the locale/ subdirectory. -->
- <target name="translations-export">
- <exec executable="a2po" failonerror="true">
- <arg value="export"/>
- <arg line="${a2po.args}"/>
- </exec>
- <tar destfile="${launchpad.import.file}"
- compression="gzip"
- basedir="${locale.dir}"
- includes="**/*.pot **/*.po" />
- </target>
-
- <target name="-check-ndk">
- <fail
- message="ndk.dir is missing. Make sure to put it in local.properties"
- unless="ndk.dir"
- />
- </target>
-
- <target name="native-build" depends="-check-ndk">
- <exec executable="${ndk.dir}/ndk-build" failonerror="true" />
- </target>
-
- <target name="native-clean" depends="-check-ndk">
- <exec executable="${ndk.dir}/ndk-build" failonerror="true">
- <arg value="clean" />
- </exec>
- </target>
-
- <property name="lint" location="${android.tools.dir}/lint${bat}" />
-
- <target name="lint-xml">
- <exec executable="${lint}">
- <arg value="--xml" />
- <arg value="lint-results.xml" />
- <arg path="${basedir}" />
- </exec>
- </target>
-
- <target name="lint-html">
- <exec executable="${lint}">
- <arg value="--html" />
- <arg value="lint-results.html" />
- <arg path="${basedir}" />
- </exec>
- </target>
-
-<!-- End custom ConnectBot stuff -->
-
-</project>
diff --git a/config/jacoco.gradle b/config/jacoco.gradle
index c603349..25ac311 100644
--- a/config/jacoco.gradle
+++ b/config/jacoco.gradle
@@ -16,9 +16,9 @@ tasks.withType(Test).whenTaskAdded {
}
// These tasks are for generating the coverage report after JUnit+robolectric tests have executed
-tasks.create(name: "jacocoTestDebugReport", type: JacocoReport, dependsOn: "testDebug") {
+tasks.create(name: "jacocoUnitTestDebugReport", type: JacocoReport, dependsOn: "testDebugUnitTest") {
group = "Reporting"
- description = "Generate Jacoco coverage reports"
+ description = "Generate Jacoco coverage reports for unit tests"
classDirectories = fileTree(
dir: "${project.buildDir}/intermediates/classes/debug/",
@@ -30,7 +30,7 @@ tasks.create(name: "jacocoTestDebugReport", type: JacocoReport, dependsOn: "test
)
sourceDirectories = files("src/main/java", "src/debug/java")
- executionData = files("${project.buildDir}/jacoco/testDebug.exec")
+ executionData = files("${project.buildDir}/jacoco/testDebugUnitTest.exec")
reports {
xml.enabled = true
@@ -38,4 +38,4 @@ tasks.create(name: "jacocoTestDebugReport", type: JacocoReport, dependsOn: "test
}
}
-coveralls.jacocoReportPath = "${project.buildDir}/reports/jacoco/jacocoTestDebugReport/jacocoTestDebugReport.xml" \ No newline at end of file
+coveralls.jacocoReportPath = "${project.buildDir}/reports/jacoco/jacocoUnitTestDebugReport/jacocoUnitTestDebugReport.xml" \ No newline at end of file
diff --git a/connectbot.iml b/connectbot.iml
index bb79c8b..4b158c6 100644
--- a/connectbot.iml
+++ b/connectbot.iml
@@ -8,7 +8,7 @@
</configuration>
</facet>
</component>
- <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..dfbe478
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1 @@
+android.useDeprecatedNdk=true