Skip to content

minor changes #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: fragments-in-isolation
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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<DirectorsFragment>(
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
)
)
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<MovieDetailFragment>(
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)))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.junit.runners.Suite
@Suite.SuiteClasses(
MovieDetailFragmentTest::class,
DirectorsFragmentTest::class,
StarActorsFragmentTest::class
StarActorsFragmentTest::class,
MovieNavigationTest::class
)
class MovieFragmentTestSuite
Original file line number Diff line number Diff line change
@@ -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()))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<StarActorsFragment>(
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
)
)
)
)
}
}

29 changes: 12 additions & 17 deletions app/src/main/res/layout/fragment_directors.xml
Original file line number Diff line number Diff line change
@@ -1,48 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:id="@+id/fragment_movie_directors_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
android:orientation="vertical"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:orientation="vertical"
>
app:layout_constraintTop_toTopOf="parent">

<TextView
android:id="@+id/directors_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="textStart"
android:id="@+id/directors_title"
android:text="@string/text_directors"
android:textAlignment="textStart"
android:textColor="#000"
android:textSize="30sp"
/>
android:textSize="30sp" />

<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/grey4"
android:layout_marginTop="10dp"
>
</View>
android:background="@color/grey4"></View>

<TextView
android:id="@+id/directors_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textAlignment="textStart"
android:id="@+id/directors_text"
android:textColor="#000"
android:textSize="21sp"
android:layout_marginTop="10dp"
/>
android:textSize="21sp" />

</LinearLayout>

Expand Down
Loading