diff --git a/app/build.gradle b/app/build.gradle index ae26f2f0..6ea1cb74 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 25 - buildToolsVersion "25.0.2" + buildToolsVersion '27.0.3' defaultConfig { applicationId "com.example.android.teatime" minSdkVersion 16 @@ -20,14 +20,14 @@ android { } dependencies { - compile 'com.android.support:design:25.1.0' - compile 'com.android.support:support-annotations:25.1.0' - compile 'com.google.android.gms:play-services-appindexing:9.8.0' - + implementation 'com.android.support:design:25.1.0' + implementation 'com.android.support:support-annotations:27.1.1' + implementation 'com.google.android.gms:play-services-appindexing:9.8.0' // Testing-only dependencies - androidTestCompile 'com.android.support:support-annotations:25.1.0' - androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' + androidTestImplementation 'com.android.support:support-annotations:27.1.1' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2' // TODO (5) Add build dependencies required to use Espresso-Intents + androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.2' } \ No newline at end of file diff --git a/app/src/androidTest/java/com/example/android/teatime/OrderSummaryActivityTest.java b/app/src/androidTest/java/com/example/android/teatime/OrderSummaryActivityTest.java index 1f7d01ca..7fd5d3b3 100644 --- a/app/src/androidTest/java/com/example/android/teatime/OrderSummaryActivityTest.java +++ b/app/src/androidTest/java/com/example/android/teatime/OrderSummaryActivityTest.java @@ -16,24 +16,79 @@ package com.example.android.teatime; +import android.app.Activity; +import android.app.Instrumentation; +import android.content.Intent; +import android.net.Uri; +import android.support.test.espresso.intent.rule.IntentsTestRule; +import android.support.test.filters.LargeTest; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.intent.Intents.intended; +import static android.support.test.espresso.intent.Intents.intending; +import static android.support.test.espresso.intent.matcher.IntentMatchers.hasAction; +import static android.support.test.espresso.intent.matcher.IntentMatchers.hasCategories; +import static android.support.test.espresso.intent.matcher.IntentMatchers.hasData; +import static android.support.test.espresso.intent.matcher.IntentMatchers.hasExtra; +import static android.support.test.espresso.intent.matcher.IntentMatchers.isInternal; +import static android.support.test.espresso.intent.matcher.IntentMatchers.toPackage; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.not; + // TODO (1) Add annotation to specify AndroidJUnitRunner class as the default test runner +@RunWith(AndroidJUnit4.class) +@LargeTest public class OrderSummaryActivityTest { + private static final String emailMessage = "I just ordered a delicious tea from TeaTime. Next time you are craving a tea, check them out!"; + // TODO (2) Add the rule that indicates we want to use Espresso-Intents APIs in functional UI tests + @Rule + public IntentsTestRule mActivityRule = new IntentsTestRule<>( + OrderSummaryActivity.class); + // TODO (3) Finish this method which runs before each test and will stub all external // intents so all external intents will be blocked + @Before public void stubAllExternalIntents() { - + // By default Espresso Intents does not stub any Intents. Stubbing needs to be setup before + // every test run. In this case all external Intents will be blocked. + intending(not(isInternal())).respondWith(new Instrumentation.ActivityResult( Activity.RESULT_OK, null)); } + + // TODO (4) Finish this method which verifies that the intent sent by clicking the send email // button matches the intent sent by the application + @Test public void clickSendEmailButton_SendsEmail() { + onView((withId(R.id.send_email_button))).perform( click() ); + + intended(allOf( + hasAction( Intent.ACTION_SENDTO), + hasExtra( Intent.EXTRA_TEXT,emailMessage ))); + + + + + } + + } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 74b2ab0d..44bac8f9 100644 --- a/build.gradle +++ b/build.gradle @@ -3,9 +3,10 @@ buildscript { repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.android.tools.build:gradle:3.1.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -15,6 +16,7 @@ buildscript { allprojects { repositories { jcenter() + google() } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 04e285f3..48c376e7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Dec 28 10:00:20 PST 2015 +#Mon Oct 08 00:34:15 EDT 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip