Skip to content
This repository was archived by the owner on Dec 6, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions espresso_sample/espresso/BasicSample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ android {

defaultConfig {
applicationId "com.example.android.testing.espresso.BasicSample"
minSdkVersion 12
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0"

//testInstrumentationRunner "com.google.android.droiddriver.runner.TestRunner"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "io.appium.droiddriver.android_support_test.D2AndroidJUnitRunner"
}
packagingOptions {
exclude 'LICENSE.txt'
Expand All @@ -41,6 +41,8 @@ dependencies {
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
androidTestCompile 'io.appium:droiddriver:0.9.1'
// Update this with droiddriver-android_support_test in maven before submit!
androidTestCompile project(':droiddriver-android_support_test')
}

tasks.withType(JavaCompile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
import android.support.test.espresso.action.ViewActions;
import android.support.test.espresso.matcher.ViewMatchers;

// BaseDroidDriverTest extends D2ActivityInstrumentationTestCase2 extends ActivityInstrumentationTestCase2
// test runner (set in build.gradle)
// TestRunner extends InstrumentationTestRunner -- handles droiddriver init
// run tests: ./gradlew clean assemble connectedCheck
// run tests quickly: ./gradlew connectedCheck

Expand Down Expand Up @@ -51,7 +48,6 @@ public void testChangeText_sameActivity() {
String expected = STRING_TO_BE_TYPED;
String actual = id(R.id.textToBeChanged).getText();

// Often flakes out with: junit.framework.ComparisonFailure: expected:<[E]spresso> but was:<[]spresso>
assertEquals(expected, actual);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
package com.example.android.testing.espresso.BasicSample;

import android.app.Activity;
import android.support.test.internal.runner.lifecycle.ActivityLifecycleMonitorRegistry;
import android.support.test.runner.lifecycle.Stage;

import com.android.support.test.deps.guava.collect.Iterables;

import java.util.Collection;
import java.util.Iterator;

import io.appium.droiddriver.UiElement;
import io.appium.droiddriver.finders.By;
import io.appium.droiddriver.finders.Finder;
import io.appium.droiddriver.helpers.BaseDroidDriverTest;
import io.appium.droiddriver.helpers.DroidDrivers;
import io.appium.droiddriver.util.ActivityUtils;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static com.example.android.testing.espresso.BasicSample.CloseSoftKeyboard.closeSoftKeyboard;

// Tip: you can specify the type of driver as an am option instead of using the platform-dependent
// default DroidDriver instance. E.g. "-e driver io.appium.droiddriver.instrumentation.InstrumentationDriver".
public abstract class DDTest<T extends Activity> extends BaseDroidDriverTest<T> {

protected DDTest(Class<T> activityClass) {
Expand All @@ -30,13 +24,6 @@ protected DDTest(Class<T> activityClass) {
protected void setUp() throws Exception {
super.setUp();

ActivityUtils.setRunningActivitySupplier(new ActivityUtils.Supplier<Activity>() {
@Override
public Activity get() {
return Iterables.getFirst(ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(Stage.RESUMED), null);
}
});

// For each test method invocation, the Activity will not actually be created
// until the first time this method is called.
getActivity();
Expand Down
4 changes: 4 additions & 0 deletions espresso_sample/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
include ':espresso:BasicSample:app'
// Delete the two lines before submit!
include(':droiddriver-android_support_test')
project(':droiddriver-android_support_test').projectDir = file('../../../aosp/droiddriver-dev/external/droiddriver/droiddriver-android_support_test')