mirror of
https://github.com/nextcloud/android.git
synced 2024-10-23 04:26:01 +03:00
Pass test vars as instrumentation runner argumments
This commit is contained in:
parent
7beb1325f6
commit
822a62c513
2 changed files with 19 additions and 13 deletions
|
@ -21,20 +21,18 @@ package com.owncloud.android.authentication;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import com.owncloud.android.BuildConfig;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import com.owncloud.android.R;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
|
@ -58,10 +56,10 @@ public class AuthenticatorActivityTest {
|
|||
public static final String EXTRA_ACTION = "ACTION";
|
||||
public static final String EXTRA_ACCOUNT = "ACCOUNT";
|
||||
|
||||
private static int WAIT_LOGIN = 5000;
|
||||
private static final int WAIT_LOGIN = 5000;
|
||||
|
||||
private static String ERROR_MESSAGE = "Activity not finished";
|
||||
private static String RESULT_CODE = "mResultCode";
|
||||
private static final String ERROR_MESSAGE = "Activity not finished";
|
||||
private static final String RESULT_CODE = "mResultCode";
|
||||
|
||||
|
||||
@Rule
|
||||
|
@ -80,7 +78,14 @@ public class AuthenticatorActivityTest {
|
|||
};
|
||||
|
||||
@Test
|
||||
public void check_login() throws InterruptedException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
|
||||
public void check_login()
|
||||
throws InterruptedException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
|
||||
Bundle arguments = InstrumentationRegistry.getArguments();
|
||||
|
||||
// Get values passed
|
||||
String testUser = arguments.getString("TEST_USER");
|
||||
String testPassword = arguments.getString("TEST_PASSWORD");
|
||||
String testServerURL = arguments.getString("TEST_SERVER_URL");
|
||||
|
||||
// Check that login button is disabled
|
||||
onView(withId(R.id.buttonOK))
|
||||
|
@ -88,16 +93,16 @@ public class AuthenticatorActivityTest {
|
|||
|
||||
// Type server url
|
||||
onView(withId(R.id.hostUrlInput))
|
||||
.perform(typeText(BuildConfig.TEST_SERVER_URL), closeSoftKeyboard());
|
||||
.perform(typeText(testServerURL), closeSoftKeyboard());
|
||||
onView(withId(R.id.account_username)).perform(click());
|
||||
|
||||
// Type user
|
||||
onView(withId(R.id.account_username))
|
||||
.perform(typeText(BuildConfig.TEST_USER), closeSoftKeyboard());
|
||||
.perform(typeText(testUser), closeSoftKeyboard());
|
||||
|
||||
// Type user pass
|
||||
onView(withId(R.id.account_password))
|
||||
.perform(typeText(BuildConfig.TEST_PASSWORD), closeSoftKeyboard());
|
||||
.perform(typeText(testPassword), closeSoftKeyboard());
|
||||
onView(withId(R.id.buttonOK)).perform(click());
|
||||
|
||||
// Check that the Activity ends after clicking
|
||||
|
|
|
@ -73,9 +73,10 @@ 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}\""
|
||||
testInstrumentationRunnerArgument "TEST_USER", "\"${TEST_USER}\""
|
||||
testInstrumentationRunnerArgument "TEST_PASSWORD", "\"${TEST_PASSWORD}\""
|
||||
testInstrumentationRunnerArgument "TEST_SERVER_URL", "\"${TEST_SERVER_URL}\""
|
||||
|
||||
}
|
||||
|
||||
// adapt structure from Eclipse to Gradle/Android Studio expectations;
|
||||
|
|
Loading…
Reference in a new issue