Bläddra i källkod

Encrypt connection parameters in AndroidTest and launch tests from travis (WIP)

jabarros 9 år sedan
förälder
incheckning
bfbf3704de

+ 11 - 5
.travis.yml

@@ -2,11 +2,17 @@ sudo: false
 language: android
 android:
   components:
-  - platform-tools
-  - tools
   - build-tools-23.0.3
   - android-23
-  - extra-android-m2repository
+  - android-22
+  - android-19
 script:
-  - ./gradlew testDebug
-
+  - ./setup_env.sh ant
+  - ant clean
+  - ant debug
+#  - ./gradlew connectedAndroidTest
+env:
+  global:
+  - secure: bm8mkBKaujxI/C7Kp2NjwDl0vsfWd3qDGZ+7WiLPGTbXnwJf8urxFQLrMkhqIR4wZs2M1LSW+P9SfD2FwL5Y0GDo29IeYLqhW5LIT8tGCZevBUfMDqd4w+eFHY73FXEAwLWVavfKmeuyisK/JNwGr75penOuQkZXTow6wgNLBjs=
+  - secure: EqLPMLaAcr+6NKeXWJdaUiNfMHJ+zdocKw7SyWsezKMMfsY6hME22m8TNHJZpt0nPCDoX7iPjJoh8svOe2RZo6UZG2q4hjcLxBu29b7QvJeChq7oJvjXPVNRUg2P2zJ2OUBbnyOhpw3cZruIncSr+QasSD8FGI7j3kw3t/86YE0=
+  - secure: pfNH4RVBy0vRPKRY3z4EQD9SRPyCuqYISQ+87cOlfpVbYHOc7xspaQSg7L9sB/sBMumOuMgGSLD6RincRrSy6nHhd70Vm4ccJxJYOynqDxC3EXNihDesw9Q+MJh1mr7WpTP21sXpP4+HkLQV0U+bKl3xcnGgeR4FU3BWYigNMkA=

+ 4 - 7
androidTest/java/com/owncloud/android/authentication/AuthenticatorActivityTest.java

@@ -26,6 +26,7 @@ import android.support.test.rule.ActivityTestRule;
 import android.support.test.runner.AndroidJUnit4;
 import android.test.suitebuilder.annotation.LargeTest;
 
+import com.owncloud.android.BuildConfig;
 import com.owncloud.android.R;
 
 import org.junit.Rule;
@@ -51,10 +52,6 @@ public class AuthenticatorActivityTest {
     public static final String EXTRA_ACTION = "ACTION";
     public static final String EXTRA_ACCOUNT = "ACCOUNT";
 
-    public static final String TEST_USER = ""; // Fill with custom values
-    public static final String TEST_PASSWORD = ""; // Fill with custom values
-    public static final String TEST_SERVER_URL = ""; // Fill with custom values
-
 
     @Rule
     public ActivityTestRule<AuthenticatorActivity> mActivityRule = new ActivityTestRule<AuthenticatorActivity>(
@@ -79,16 +76,16 @@ public class AuthenticatorActivityTest {
 
         // Type server url
         onView(withId(R.id.hostUrlInput))
-                .perform(typeText(TEST_SERVER_URL), closeSoftKeyboard());
+                .perform(typeText(BuildConfig.TEST_SERVER_URL), closeSoftKeyboard());
         onView(withId(R.id.account_username)).perform(click());
 
         // Type user
         onView(withId(R.id.account_username))
-                .perform(typeText(TEST_USER), closeSoftKeyboard());
+                .perform(typeText(BuildConfig.TEST_USER), closeSoftKeyboard());
 
         // Type user pass
         onView(withId(R.id.account_password))
-                .perform(typeText(TEST_PASSWORD), closeSoftKeyboard());
+                .perform(typeText(BuildConfig.TEST_PASSWORD), closeSoftKeyboard());
         onView(withId(R.id.buttonOK)).perform(click());
 
         // Check that login button is now enabled

+ 11 - 0
build.gradle

@@ -18,6 +18,9 @@ apply plugin: 'com.android.application'
 
 ext {
     supportLibraryVersion = '23.1.1'
+    TEST_USER = "$System.env.TEST_USER"
+    TEST_PASSWORD = "$System.env.TEST_PASSWORD"
+    TEST_SERVER_URL = "$System.env.TEST_SERVER_URL"
 }
 
 repositories {
@@ -62,6 +65,14 @@ android {
 
     defaultConfig {
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+        buildConfigField "String", "TEST_USER", "${TEST_USER}"
+        buildConfigField "String", "TEST_PASSWORD", "${TEST_PASSWORD}"
+        buildConfigField "String", "TEST_SERVER_URL", "${TEST_SERVER_URL}"
+
+        testInstrumentationRunnerArguments TEST_USER: "${TEST_USER}"
+        testInstrumentationRunnerArguments TEST_PASSWORD: "${TEST_PASSWORD}"
+        testInstrumentationRunnerArguments TEST_SERVER_URL: "${TEST_SERVER_URL}"
     }
 
     // adapt structure from Eclipse to Gradle/Android Studio expectations;