From 34d697c968ea136371a480883b99c43b8ec1fe91 Mon Sep 17 00:00:00 2001 From: Timothy Date: Mon, 13 Jul 2015 13:27:23 +0800 Subject: [PATCH 1/6] Upgrade Android Tools Build Gradle From 0.12.2 To 1.2.3 Remove Robolectric Gradle Plugin --- build.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index edee4ba..c4cd5fe 100644 --- a/build.gradle +++ b/build.gradle @@ -6,8 +6,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:0.12.2' - classpath 'org.robolectric:robolectric-gradle-plugin:0.11.+' + classpath 'com.android.tools.build:gradle:1.2.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files From 6bce9f7449bc393d0736b130baffa8bbf8547bc9 Mon Sep 17 00:00:00 2001 From: Timothy Date: Mon, 13 Jul 2015 13:30:19 +0800 Subject: [PATCH 2/6] Reduce Apply Robolectric Plugin Modify testInstrumentationRunner To AndroidJUnitRunner Modify Espresso To Use com.android.support.test Upgrade Robolectric From 2.3 To 3.0 --- app/build.gradle | 62 +++++++++--------------------------------------- 1 file changed, 11 insertions(+), 51 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 16faf81..8d6b2db 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,4 @@ apply plugin: 'com.android.application' -apply plugin: 'robolectric' android { packagingOptions { @@ -16,61 +15,22 @@ android { targetSdkVersion 18 versionCode 2 versionName "1.0.0-SNAPSHOT" - testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } - - buildTypes { - release { - runProguard false - } - } - - sourceSets { - androidTest { - setRoot('src/androidTest') - } - } -} - -robolectric { - include '**/*Test.class' - exclude '**/espresso/**/*.class' } dependencies { - repositories { - mavenCentral() - } compile 'com.sothree.slidinguppanel:library:2.0.1' - androidTestCompile('junit:junit:4.11') { - exclude module: 'hamcrest-core' - } // Espresso - androidTestCompile files('libs/espresso-1.1.jar') - androidTestCompile files('libs/testrunner-1.1.jar') - androidTestCompile files('libs/testrunner-runtime-1.1.jar') - androidTestCompile 'com.google.guava:guava:14.0.1' - androidTestCompile 'com.squareup.dagger:dagger:1.1.0' - androidTestCompile 'org.hamcrest:hamcrest-integration:1.1' - androidTestCompile 'org.hamcrest:hamcrest-core:1.1' - androidTestCompile 'org.hamcrest:hamcrest-library:1.1' - androidTestCompile('org.robolectric:robolectric:2.3') { - exclude module: 'classworlds' - exclude module: 'commons-logging' - exclude module: 'httpclient' - exclude module: 'maven-artifact' - exclude module: 'maven-artifact-manager' - exclude module: 'maven-error-diagnostics' - exclude module: 'maven-model' - exclude module: 'maven-project' - exclude module: 'maven-settings' - exclude module: 'plexus-container-default' - exclude module: 'plexus-interpolation' - exclude module: 'plexus-utils' - exclude module: 'wagon-file' - exclude module: 'wagon-http-lightweight' - exclude module: 'wagon-provider-api' - } - androidTestCompile 'com.squareup:fest-android:1.0.+' + androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2' + androidTestCompile 'com.android.support.test:runner:0.3' + androidTestCompile 'com.android.support.test:rules:0.3' + + // Robolectric + testCompile 'junit:junit:4.12' + testCompile 'org.hamcrest:hamcrest-core:1.1' + testCompile 'org.hamcrest:hamcrest-library:1.1' + testCompile 'org.hamcrest:hamcrest-integration:1.1' + testCompile 'org.robolectric:robolectric:3.0' } \ No newline at end of file From 601e52c8e5d7533cbfd3adaa7993fc50b04b3e16 Mon Sep 17 00:00:00 2001 From: Timothy Date: Mon, 13 Jul 2015 13:31:09 +0800 Subject: [PATCH 3/6] Upgrade Gradle From 1.12 To 2.4 --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1e61d1f..d2146bb 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip +distributionUrl=http\://services.gradle.org/distributions/gradle-2.4-bin.zip From 486a0fde3bcd9a6d233b12e2aec11d8b9a6286aa Mon Sep 17 00:00:00 2001 From: Timothy Date: Mon, 13 Jul 2015 13:37:49 +0800 Subject: [PATCH 4/6] Add Git Ignore For Intellij Files --- .gitignore | 4 ++ TestRobolectric.iml | 19 ------- app/app.iml | 119 -------------------------------------------- 3 files changed, 4 insertions(+), 138 deletions(-) delete mode 100644 TestRobolectric.iml delete mode 100644 app/app.iml diff --git a/.gitignore b/.gitignore index 9068cd0..4ce9130 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,7 @@ proguard/ # Log Files *.log + +#Intellij Files +*.iml +.idea \ No newline at end of file diff --git a/TestRobolectric.iml b/TestRobolectric.iml deleted file mode 100644 index 0bb6048..0000000 --- a/TestRobolectric.iml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/app/app.iml b/app/app.iml deleted file mode 100644 index 1711cd8..0000000 --- a/app/app.iml +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 90b6df2918dbda24825ac1670cac36434c1ee9db Mon Sep 17 00:00:00 2001 From: Timothy Date: Mon, 13 Jul 2015 13:45:59 +0800 Subject: [PATCH 5/6] Move Robolectric Test From AndroidTest To Test Directory Add Annotation For Robolectric Modify Test For Using Robolectric Build Activity Run Unit Test With This Commit will Get InflateException --- .../com/marcthomas/testrobolectric/ApplicationTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename app/src/{androidTest => Test}/java/com/marcthomas/testrobolectric/ApplicationTest.java (65%) diff --git a/app/src/androidTest/java/com/marcthomas/testrobolectric/ApplicationTest.java b/app/src/Test/java/com/marcthomas/testrobolectric/ApplicationTest.java similarity index 65% rename from app/src/androidTest/java/com/marcthomas/testrobolectric/ApplicationTest.java rename to app/src/Test/java/com/marcthomas/testrobolectric/ApplicationTest.java index 81d776d..23cedf4 100644 --- a/app/src/androidTest/java/com/marcthomas/testrobolectric/ApplicationTest.java +++ b/app/src/Test/java/com/marcthomas/testrobolectric/ApplicationTest.java @@ -1,7 +1,5 @@ package com.marcthomas.testrobolectric; -import android.app.Activity; - import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.Robolectric; @@ -10,10 +8,12 @@ import static org.junit.Assert.assertTrue; +@RunWith(RobolectricTestRunner.class) +@Config(manifest = "app/src/main/AndroidManifest.xml", sdk = 18) public class ApplicationTest { @Test public void testSomething() throws Exception { - assertTrue(true); + assertTrue(Robolectric.buildActivity(MyActivity.class).create().get() != null); } } From 92ff9d563f6981b5cc54bdfe956d66287c388c7b Mon Sep 17 00:00:00 2001 From: Timothy Date: Mon, 13 Jul 2015 13:54:20 +0800 Subject: [PATCH 6/6] Add SlidingUpPanel Res from https://github.com/umano/AndroidSlidingUpPanel/tree/master/library/res/drawable Run Unit Test With This Commit Will Pass --- app/src/main/res/drawable-hdpi/above_shadow.xml | 8 ++++++++ app/src/main/res/drawable-hdpi/below_shadow.xml | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 app/src/main/res/drawable-hdpi/above_shadow.xml create mode 100644 app/src/main/res/drawable-hdpi/below_shadow.xml diff --git a/app/src/main/res/drawable-hdpi/above_shadow.xml b/app/src/main/res/drawable-hdpi/above_shadow.xml new file mode 100644 index 0000000..dc2064b --- /dev/null +++ b/app/src/main/res/drawable-hdpi/above_shadow.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-hdpi/below_shadow.xml b/app/src/main/res/drawable-hdpi/below_shadow.xml new file mode 100644 index 0000000..3fe8152 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/below_shadow.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file