Add first Espresso interaction test
// FREEBIE
This commit is contained in:
parent
8277e4e102
commit
fc21d2038f
7 changed files with 85 additions and 15 deletions
|
@ -329,6 +329,5 @@
|
|||
<action android:name="org.thoughtcrime.securesms.MessageNotifier.DELETE_REMINDER_ACTION"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<uses-library android:name="android.test.runner" />
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package org.thoughtcrime.securesms;
|
||||
|
||||
import static android.support.test.espresso.Espresso.*;
|
||||
import static android.support.test.espresso.action.ViewActions.*;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.*;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.*;
|
||||
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
@LargeTest
|
||||
public class RegistrationActivityTest extends RoutedInstrumentationTestCase {
|
||||
private final static String TAG = RegistrationActivityTest.class.getSimpleName();
|
||||
|
||||
public RegistrationActivityTest() {
|
||||
super();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testRegistrationButtons() throws Exception {
|
||||
waitOn(RegistrationActivity.class);
|
||||
onView(withId(R.id.registerButton)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.skipButton)).check(matches(isDisplayed())).perform(click());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Instrumentation.ActivityMonitor;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
||||
|
||||
public class RoutedInstrumentationTestCase extends ActivityInstrumentationTestCase2<RoutingActivity> {
|
||||
private static final String TAG = RoutedInstrumentationTestCase.class.getSimpleName();
|
||||
|
||||
public RoutedInstrumentationTestCase() {
|
||||
super(RoutingActivity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
System.setProperty("dexmaker.dexcache", getInstrumentation().getTargetContext().getCacheDir().getPath());
|
||||
super.setUp();
|
||||
clearSharedPrefs();
|
||||
getActivity();
|
||||
}
|
||||
|
||||
protected void clearSharedPrefs() {
|
||||
PreferenceManager.getDefaultSharedPreferences(getInstrumentation().getTargetContext())
|
||||
.edit().clear().commit();
|
||||
getInstrumentation().getTargetContext().getSharedPreferences(MasterSecretUtil.PREFERENCES_NAME, 0)
|
||||
.edit().clear().commit();
|
||||
}
|
||||
|
||||
protected static void waitOn(Class<? extends Activity> clazz) {
|
||||
Log.w(TAG, "waiting for " + clazz.getName());
|
||||
new ActivityMonitor(clazz.getName(), null, true).waitForActivityWithTimeout(10000);
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ package org.thoughtcrime.securesms.database;
|
|||
|
||||
import org.thoughtcrime.securesms.TextSecureTestCase;
|
||||
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class CanonicalAddressDatabaseTest extends TextSecureTestCase {
|
||||
private static final String AMBIGUOUS_NUMBER = "222-3333";
|
||||
|
|
|
@ -7,7 +7,8 @@ import junit.framework.AssertionFailedError;
|
|||
import org.thoughtcrime.securesms.TextSecureTestCase;
|
||||
import org.whispersystems.textsecure.api.util.InvalidNumberException;
|
||||
import org.whispersystems.textsecure.api.util.PhoneNumberFormatter;
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class PhoneNumberFormatterTest extends TextSecureTestCase {
|
||||
private static final String LOCAL_NUMBER = "+15555555555";
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
|
||||
public class UtilTest extends AndroidTestCase {
|
||||
|
||||
}
|
24
build.gradle
24
build.gradle
|
@ -59,9 +59,19 @@ dependencies {
|
|||
compile 'org.whispersystems:jobmanager:0.10.0'
|
||||
compile 'org.whispersystems:libpastelog:1.0.4'
|
||||
|
||||
androidTestCompile 'com.squareup:fest-android:1.0.8'
|
||||
androidTestCompile 'com.google.dexmaker:dexmaker:1.1'
|
||||
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.1'
|
||||
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
|
||||
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
|
||||
|
||||
androidTestCompile ('org.assertj:assertj-core:1.7.1') {
|
||||
exclude group: 'org.hamcrest', module: 'hamcrest-core'
|
||||
}
|
||||
androidTestCompile ('com.squareup.assertj:assertj-android:1.0.0') {
|
||||
exclude group: 'org.hamcrest', module: 'hamcrest-core'
|
||||
}
|
||||
androidTestCompile ('com.android.support.test.espresso:espresso-core:2.0') {
|
||||
exclude group: 'javax.inject'
|
||||
}
|
||||
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
|
||||
|
||||
compile project(':libtextsecure')
|
||||
}
|
||||
|
@ -112,6 +122,7 @@ android {
|
|||
minSdkVersion 9
|
||||
targetSdkVersion 19
|
||||
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L"
|
||||
}
|
||||
|
||||
|
@ -120,6 +131,13 @@ android {
|
|||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
exclude 'LICENSE.txt'
|
||||
exclude 'LICENSE'
|
||||
exclude 'NOTICE'
|
||||
exclude 'asm-license.txt'
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
release
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue