-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
memindahkan fungsi addtofavorite dan removefavorite ke detailpresenter
- Loading branch information
Showing
22 changed files
with
656 additions
and
188 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
198 changes: 198 additions & 0 deletions
198
app/src/androidTest/java/com/example/wijaya_pc/eplmatchschedule/MainActivityTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
package com.example.wijaya_pc.eplmatchschedule | ||
|
||
import android.support.test.espresso.Espresso | ||
import android.support.test.espresso.Espresso.onView | ||
import android.support.test.espresso.Espresso.pressBack | ||
import android.support.test.espresso.action.ViewActions.click | ||
import android.support.test.espresso.assertion.ViewAssertions.matches | ||
import android.support.test.espresso.contrib.RecyclerViewActions | ||
import android.support.test.espresso.matcher.ViewMatchers | ||
import android.support.test.espresso.matcher.ViewMatchers.isDisplayed | ||
import android.support.test.espresso.matcher.ViewMatchers.withId | ||
import android.support.test.rule.ActivityTestRule | ||
import android.support.test.runner.AndroidJUnit4 | ||
import android.support.v7.widget.RecyclerView | ||
import com.example.wijaya_pc.eplmatchschedule.R.id.* | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class MainActivityTest { | ||
@Rule | ||
@JvmField var activityRule = ActivityTestRule(MainActivity::class.java) | ||
|
||
@Test | ||
fun testRecyclerViewLastMatchBehaviour() { | ||
Thread.sleep(1000) | ||
|
||
onView(withId(listMatch)).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
onView(withId(listMatch)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(14)) | ||
Thread.sleep(1000) | ||
onView(withId(listMatch)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(1)) | ||
Thread.sleep(1000) | ||
onView(withId(listMatch)).perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(1, click())) | ||
} | ||
|
||
@Test | ||
fun testRecyclerViewNextMatchBehaviour() { | ||
Thread.sleep(1000) | ||
|
||
onView(withId(bottom_navigation)).check(matches(isDisplayed())) | ||
onView(withId(tab_next_match)).perform(click()) | ||
Thread.sleep(1000) | ||
|
||
onView(withId(listMatch)).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
onView(withId(listMatch)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(7)) | ||
Thread.sleep(1000) | ||
onView(withId(listMatch)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(3)) | ||
Thread.sleep(1000) | ||
onView(withId(listMatch)).perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(3, click())) | ||
} | ||
|
||
@Test | ||
fun testRecyclerViewFavoritesBehaviour() { | ||
Thread.sleep(1000) | ||
|
||
onView(withId(bottom_navigation)).check(matches(isDisplayed())) | ||
onView(withId(favorites)).perform(click()) | ||
Thread.sleep(1000) | ||
|
||
onView(withId(listFav)).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
onView(withId(listFav)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(14)) | ||
Thread.sleep(1000) | ||
onView(withId(listFav)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(0)) | ||
Thread.sleep(1000) | ||
onView(withId(listFav)).perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(0, click())) | ||
} | ||
|
||
|
||
@Test | ||
fun testAddFavoriteFromLastMatchBehaviour() { | ||
Thread.sleep(1000) | ||
|
||
onView(withId(listMatch)).check(matches(isDisplayed())) | ||
onView(ViewMatchers.withText("Crystal Palace")).perform(click()) | ||
Thread.sleep(1000) | ||
|
||
onView(withId(add_to_favorite)).check(matches(isDisplayed())) | ||
onView(withId(add_to_favorite)).perform(click()) | ||
onView(ViewMatchers.withText("Added to FavoriteMatches")).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
|
||
onView(withId(add_to_favorite)).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
onView(withId(add_to_favorite)).perform(click()) | ||
Thread.sleep(1000) | ||
onView(ViewMatchers.withText("Removed from FavoriteMatches")).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
|
||
onView(withId(add_to_favorite)).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
onView(withId(add_to_favorite)).perform(click()) | ||
Thread.sleep(1000) | ||
onView(ViewMatchers.withText("Added to FavoriteMatches")).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
|
||
pressBack() | ||
|
||
onView(withId(listMatch)).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
|
||
onView(withId(listMatch)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(5)) | ||
Thread.sleep(1000) | ||
onView(withId(listMatch)).perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(5, click())) | ||
Thread.sleep(1000) | ||
|
||
onView(withId(add_to_favorite)).check(matches(isDisplayed())) | ||
onView(withId(add_to_favorite)).perform(click()) | ||
onView(ViewMatchers.withText("Added to FavoriteMatches")).check(matches(isDisplayed())) | ||
|
||
pressBack() | ||
|
||
onView(withId(bottom_navigation)).check(matches(isDisplayed())) | ||
onView(withId(favorites)).perform(click()) | ||
Thread.sleep(1000) | ||
} | ||
|
||
@Test | ||
fun testAddFavoriteFromNextMatchBehaviour() { | ||
Thread.sleep(1000) | ||
|
||
onView(withId(listMatch)).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
|
||
onView(withId(bottom_navigation)).check(matches(isDisplayed())) | ||
onView(withId(tab_next_match)).perform(click()) | ||
Thread.sleep(1000) | ||
|
||
onView(withId(listMatch)).check(matches(isDisplayed())) | ||
onView(ViewMatchers.withText("Liverpool")).perform(click()) | ||
Thread.sleep(1000) | ||
|
||
onView(withId(add_to_favorite)).check(matches(isDisplayed())) | ||
onView(withId(add_to_favorite)).perform(click()) | ||
onView(ViewMatchers.withText("Added to FavoriteMatches")).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
|
||
onView(withId(add_to_favorite)).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
onView(withId(add_to_favorite)).perform(click()) | ||
Thread.sleep(1000) | ||
onView(ViewMatchers.withText("Removed from FavoriteMatches")).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
|
||
onView(withId(add_to_favorite)).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
onView(withId(add_to_favorite)).perform(click()) | ||
Thread.sleep(1000) | ||
onView(ViewMatchers.withText("Added to FavoriteMatches")).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
|
||
pressBack() | ||
|
||
onView(withId(listMatch)).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
|
||
onView(withId(listMatch)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(8)) | ||
Thread.sleep(1000) | ||
onView(withId(listMatch)).perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(8, click())) | ||
Thread.sleep(1000) | ||
|
||
onView(withId(add_to_favorite)).check(matches(isDisplayed())) | ||
onView(withId(add_to_favorite)).perform(click()) | ||
onView(ViewMatchers.withText("Added to FavoriteMatches")).check(matches(isDisplayed())) | ||
|
||
pressBack() | ||
|
||
onView(withId(bottom_navigation)).check(matches(isDisplayed())) | ||
onView(withId(favorites)).perform(click()) | ||
Thread.sleep(1000) | ||
} | ||
|
||
@Test | ||
fun testDeleteFavoriteFromFavoritesFragmentBehaviour() { | ||
Thread.sleep(1000) | ||
|
||
onView(withId(listMatch)).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
|
||
onView(withId(bottom_navigation)).check(matches(isDisplayed())) | ||
onView(withId(favorites)).perform(click()) | ||
Thread.sleep(1000) | ||
|
||
onView(withId(listFav)).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
onView(withId(listFav)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(0)) | ||
Thread.sleep(1000) | ||
onView(withId(listFav)).perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(0, click())) | ||
|
||
onView(withId(add_to_favorite)).check(matches(isDisplayed())) | ||
onView(withId(add_to_favorite)).perform(click()) | ||
onView(ViewMatchers.withText("Removed from FavoriteMatches")).check(matches(isDisplayed())) | ||
Thread.sleep(1000) | ||
} | ||
} |
Oops, something went wrong.