aboutsummaryrefslogtreecommitdiffstats
path: root/app/src
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2015-09-03 17:11:07 -0700
committerKenny Root <kenny@the-b.org>2015-09-03 17:11:07 -0700
commit7896a7841bbcc215e1deb6476e3d63de91e1e207 (patch)
treefe3775ab23f116fb35849db33018f48ed383e8c2 /app/src
parent44c7bcfa9f7ae69fa481b100bcfba5e1387eee9c (diff)
parent8b2be1634e0b08579453a2dd8a5dbd04c8ee29fb (diff)
downloadconnectbot-7896a7841bbcc215e1deb6476e3d63de91e1e207.tar.gz
connectbot-7896a7841bbcc215e1deb6476e3d63de91e1e207.tar.bz2
connectbot-7896a7841bbcc215e1deb6476e3d63de91e1e207.zip
Merge pull request #182 from kruton/fix-jacoco
Fix JaCoCo usage with connected tests
Diffstat (limited to 'app/src')
-rw-r--r--app/src/androidTest/java/org/connectbot/FixJacocoTestRunner.java34
-rw-r--r--app/src/main/res/layout-large/act_console.xml7
2 files changed, 39 insertions, 2 deletions
diff --git a/app/src/androidTest/java/org/connectbot/FixJacocoTestRunner.java b/app/src/androidTest/java/org/connectbot/FixJacocoTestRunner.java
new file mode 100644
index 0000000..fbadb9b
--- /dev/null
+++ b/app/src/androidTest/java/org/connectbot/FixJacocoTestRunner.java
@@ -0,0 +1,34 @@
+/*
+ * This class comes from a StackOverflow post:
+ * http://stackoverflow.com/questions/30337375/empty-jacoco-report-for-android-espresso/31600193#31600193
+ *
+ * This should be fixed in com.android.test.support:runner:0.4 and this class can be removed.
+ */
+package org.connectbot;
+
+import android.os.Bundle;
+import android.support.test.runner.AndroidJUnitRunner;
+import android.util.Log;
+
+import java.lang.reflect.Method;
+
+public class FixJacocoTestRunner extends AndroidJUnitRunner {
+
+ static {
+ System.setProperty("jacoco-agent.destfile", "/data/data/" + BuildConfig.APPLICATION_ID + "/coverage.ec");
+ }
+
+ @Override
+ public void finish(int resultCode, Bundle results) {
+ try {
+ Class rt = Class.forName("org.jacoco.agent.rt.RT");
+ Method getAgent = rt.getMethod("getAgent");
+ Method dump = getAgent.getReturnType().getMethod("dump", boolean.class);
+ Object agent = getAgent.invoke(null);
+ dump.invoke(agent, false);
+ } catch (Throwable e) {
+ Log.d("JACOCO", e.getMessage());
+ }
+ super.finish(resultCode, results);
+ }
+}
diff --git a/app/src/main/res/layout-large/act_console.xml b/app/src/main/res/layout-large/act_console.xml
index d0ad41b..6e7ab14 100644
--- a/app/src/main/res/layout-large/act_console.xml
+++ b/app/src/main/res/layout-large/act_console.xml
@@ -21,6 +21,7 @@
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff000000">
@@ -29,7 +30,8 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:theme="@style/Theme.AppCompat.Light.DarkActionBar"/>
+ android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
+ tools:ignore="InconsistentLayout"/>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
@@ -39,7 +41,8 @@
android:textAppearance="?android:attr/textAppearanceMedium"
app:tabMode="scrollable"
app:tabContentStart="60dp"
- app:tabIndicatorColor="@android:color/white"/>
+ app:tabIndicatorColor="@android:color/white"
+ tools:ignore="InconsistentLayout"/>
<TextView
android:id="@android:id/empty"