-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathHomeTest.kt
More file actions
48 lines (43 loc) · 1.4 KB
/
HomeTest.kt
File metadata and controls
48 lines (43 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.android.tvflix.home
import androidx.test.espresso.Espresso.pressBack
import androidx.test.espresso.IdlingRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.rule.ActivityTestRule
import com.android.tvflix.idlingresource.LoadingIdlingResource
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@LargeTest
@RunWith(AndroidJUnit4::class)
class HomeTest {
@get:Rule
val homeActivityTestRule = ActivityTestRule(HomeActivity::class.java)
private lateinit var loadingIdlingResource: LoadingIdlingResource
@Before
fun setUp() {
loadingIdlingResource =
LoadingIdlingResource(homeActivityTestRule.activity)
IdlingRegistry.getInstance().register(loadingIdlingResource)
}
@Test
fun testHomePageWithFavorites() {
launchHome {
verifyHome()
// Click on add to favorites icon
verifyFavorite()
// Verify that added to favorites toast is shown
verifyToast(homeActivityTestRule.activity)
verifyFavoriteScreen()
// Verify that pressing back from favorites goes to home
pressBack()
verifyHome()
}
}
@After
fun tearDown() {
IdlingRegistry.getInstance().unregister(loadingIdlingResource)
}
}