-
-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathHomeTest.kt
More file actions
75 lines (66 loc) · 2.33 KB
/
HomeTest.kt
File metadata and controls
75 lines (66 loc) · 2.33 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.mitteloupe.whoami.test
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.test.espresso.intent.Intents
import com.mitteloupe.whoami.launcher.FromScreen
import com.mitteloupe.whoami.screen.HomeScreen
import com.mitteloupe.whoami.screen.OpenSourceNoticesScreen
import com.mitteloupe.whoami.server.REQUEST_RESPONSE_GET_IP
import com.mitteloupe.whoami.server.REQUEST_RESPONSE_GET_IP_DETAILS
import com.mitteloupe.whoami.test.annotation.ServerRequestResponse
import com.mitteloupe.whoami.test.test.BaseTest
import com.mitteloupe.whoami.ui.main.MainActivity
import com.mitteloupe.whoami.ui.main.route.Home
import dagger.hilt.android.testing.HiltAndroidTest
import javax.inject.Inject
import org.junit.Test
@HiltAndroidTest
@ExperimentalTestApi
class HomeTest : BaseTest() {
override val composeTestRule = createAndroidComposeRule<MainActivity>()
override val startActivityLauncher: AppLauncher by lazy {
FromScreen(composeTestRule, Home)
}
@Inject
lateinit var homeScreen: HomeScreen
@Inject
lateinit var openSourceNoticesScreen: OpenSourceNoticesScreen
@Test
@ServerRequestResponse([REQUEST_RESPONSE_GET_IP, REQUEST_RESPONSE_GET_IP_DETAILS])
fun givenConnectedWhenStartingAppThenIpAddressPresented() {
with(composeTestRule) {
with(homeScreen) {
seesIpAddressLabel()
seesIpAddressSubtitleLabel()
}
}
}
@Test
@ServerRequestResponse([REQUEST_RESPONSE_GET_IP, REQUEST_RESPONSE_GET_IP_DETAILS])
fun givenConnectedWhenStartingAppThenIpAddressDetailsPresented() {
with(composeTestRule) {
with(homeScreen) {
seesCityLabel()
seesRegionLabel()
seesCountryLabel()
seesGeolocationLabel()
seesPostCodeLabel()
seesTimeZoneLabel()
seesInternetServiceProviderLabel()
}
}
}
@Test
fun whenTappingOnOpenSourceNoticesLaunchesActivity() {
Intents.init()
with(composeTestRule) {
with(homeScreen) {
tapOpenSourceNotices()
}
with(openSourceNoticesScreen) {
seesScreen()
}
}
Intents.release()
}
}