diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..81a7416 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +EspressoUITestExamples \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 169fd0d..2c7e034 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -1,10 +1,13 @@ + diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..a5f05cd --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 8a8f75b..e31a632 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,7 +5,14 @@ - + + + + diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/DirectorsFragmentTest.kt b/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/DirectorsFragmentTest.kt index d2638c8..75421ad 100644 --- a/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/DirectorsFragmentTest.kt +++ b/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/DirectorsFragmentTest.kt @@ -14,25 +14,26 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4ClassRunner::class) class DirectorsFragmentTest{ - - @Test fun test_isDirectorsListVisible() { - - // GIVEN + //SETUP val directors = arrayListOf("R.J. Stewart", "James Vanderbilt") val fragmentFactory = MovieFragmentFactory() val bundle = Bundle() bundle.putStringArrayList("args_directors", directors) + val scenario = launchFragmentInContainer( - fragmentArgs = bundle, - factory = fragmentFactory + fragmentArgs = bundle, factory = fragmentFactory ) - // VERIFY - onView(withId(R.id.directors_text)) - .check(matches(withText( - DirectorsFragment.stringBuilderForDirectors(directors) - ))) + onView(withId(R.id.directors_text)).check( + matches( + withText( + DirectorsFragment.stringBuilderForDirectors( + directors + ) + ) + ) + ) } } \ No newline at end of file diff --git a/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/MovieDetailFragmentTest.kt b/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/MovieDetailFragmentTest.kt index 93a8cfd..ff00e07 100644 --- a/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/MovieDetailFragmentTest.kt +++ b/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/MovieDetailFragmentTest.kt @@ -17,24 +17,19 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4ClassRunner::class) class MovieDetailFragmentTest{ - - @Test fun test_isMovieDataVisible() { + //SET UP - // SETUP val movie = THE_RUNDOWN val fragmentFactory = MovieFragmentFactory() val bundle = Bundle() bundle.putInt("movie_id", movie.id) + val scenario = launchFragmentInContainer( - fragmentArgs = bundle, - factory = fragmentFactory + fragmentArgs = bundle, factory = fragmentFactory ) - - // VERIFY onView(withId(R.id.movie_title)).check(matches(withText(movie.title))) - onView(withId(R.id.movie_description)).check(matches(withText(movie.description))) } } diff --git a/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/MovieFragmentTestSuite.kt b/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/MovieFragmentTestSuite.kt index ebdc6b5..e69d501 100644 --- a/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/MovieFragmentTestSuite.kt +++ b/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/MovieFragmentTestSuite.kt @@ -7,6 +7,7 @@ import org.junit.runners.Suite @Suite.SuiteClasses( MovieDetailFragmentTest::class, DirectorsFragmentTest::class, - StarActorsFragmentTest::class + StarActorsFragmentTest::class, + MovieNavigationTest::class ) class MovieFragmentTestSuite \ No newline at end of file diff --git a/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/MovieNavigationTest.kt b/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/MovieNavigationTest.kt new file mode 100644 index 0000000..2765e1d --- /dev/null +++ b/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/MovieNavigationTest.kt @@ -0,0 +1,40 @@ +package com.codingwithmitch.espressouitestexamples.ui.movie + +import androidx.test.core.app.ActivityScenario +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.Espresso.pressBack +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.ViewMatchers.isDisplayed +import androidx.test.espresso.matcher.ViewMatchers.withId +import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner +import com.codingwithmitch.espressouitestexamples.R +import org.junit.Test +import org.junit.runner.RunWith + + +@RunWith(AndroidJUnit4ClassRunner::class) +class MovieNavigationTest { + @Test + fun test_MovieFragmentNavigation() { + //setUp + val activityScenario = ActivityScenario.launch(MainActivity::class.java) + + //navigate to directors fragment + onView(withId(R.id.movie_directiors)).perform(click()) + + //verify + onView(withId(R.id.fragment_movie_directors_parent)).check(matches(isDisplayed())) + + pressBack() + + //verify + onView(withId(R.id.fragment_movie_details_parent)).check(matches(isDisplayed())) + + //navigate to movie starts fragment + onView(withId(R.id.movie_directiors)).perform(click()) + + //verify + onView(withId(R.id.fragment_movie_starts_parent)).check(matches(isDisplayed())) + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/StarActorsFragmentTest.kt b/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/StarActorsFragmentTest.kt index 148f672..3b02e00 100644 --- a/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/StarActorsFragmentTest.kt +++ b/app/src/androidTest/java/com/codingwithmitch/espressouitestexamples/ui/movie/StarActorsFragmentTest.kt @@ -16,31 +16,30 @@ import java.lang.StringBuilder @RunWith(AndroidJUnit4ClassRunner::class) class StarActorsFragmentTest{ - - @Test - fun test_isActorsListVisible() { - - // GIVEN - val actors = arrayListOf( - "Dwayne Johnson", - "Seann William Scott", - "Rosario Dawson", - "Christopher Walken" + fun test_isDirectorsListVisible() { + //SETUP + val startActors = arrayListOf( + "Dwayne Johnson", "Seann William Scott", + "Rosario Dawson", "Christopher Walken" ) val fragmentFactory = MovieFragmentFactory() val bundle = Bundle() - bundle.putStringArrayList("args_actors", actors) + bundle.putStringArrayList("args_actors", startActors) + val scenario = launchFragmentInContainer( - fragmentArgs = bundle, - factory = fragmentFactory + fragmentArgs = bundle, factory = fragmentFactory ) - // VERIFY - onView(withId(R.id.star_actors_text)) - .check(matches(withText( - StarActorsFragment.stringBuilderForStarActors(actors) - ))) + onView(withId(R.id.star_actors_text)).check( + matches( + withText( + StarActorsFragment.stringBuilderForStarActors( + startActors + ) + ) + ) + ) } } diff --git a/app/src/main/res/layout/fragment_directors.xml b/app/src/main/res/layout/fragment_directors.xml index 78bd6b6..996f31e 100644 --- a/app/src/main/res/layout/fragment_directors.xml +++ b/app/src/main/res/layout/fragment_directors.xml @@ -1,48 +1,43 @@ - + app:layout_constraintTop_toTopOf="parent"> + android:textSize="30sp" /> - + android:background="@color/grey4"> + android:textSize="21sp" /> diff --git a/app/src/main/res/layout/fragment_movie_detail.xml b/app/src/main/res/layout/fragment_movie_detail.xml index 2a19d2c..491ec69 100644 --- a/app/src/main/res/layout/fragment_movie_detail.xml +++ b/app/src/main/res/layout/fragment_movie_detail.xml @@ -1,93 +1,83 @@ - + android:background="#fff"> + app:layout_constraintBottom_toTopOf="@+id/movie_image" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + android:scaleType="fitXY" + app:layout_constraintBottom_toTopOf="@+id/container1" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toBottomOf="@+id/movie_title" /> + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toBottomOf="@id/movie_image"> + android:textSize="15sp" /> + android:textSize="15sp" /> + android:background="@color/grey4"> - + android:textSize="17sp" /> - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_star_actors.xml b/app/src/main/res/layout/fragment_star_actors.xml index 58e5260..b5ee9cd 100644 --- a/app/src/main/res/layout/fragment_star_actors.xml +++ b/app/src/main/res/layout/fragment_star_actors.xml @@ -1,48 +1,43 @@ - + app:layout_constraintTop_toTopOf="parent"> + android:textSize="30sp" /> - + android:background="@color/grey4"> + android:textSize="21sp" />