-
-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathHomeScreen.kt
More file actions
68 lines (55 loc) · 2.25 KB
/
HomeScreen.kt
File metadata and controls
68 lines (55 loc) · 2.25 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
package com.mitteloupe.whoami.screen
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.SemanticsMatcher
import androidx.compose.ui.test.click
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.performTouchInput
import com.mitteloupe.whoami.constant.IP_ADDRESS
@ExperimentalTestApi
class HomeScreen {
private val ipAddressLabel = hasText(IP_ADDRESS)
private val ipAddressSubtitleLabel =
hasText("This is the address from which you are sending network requests.")
private val cityLabel = hasText("Brentwood")
private val regionLabel = hasText("England")
private val countryLabel = hasText("United Kingdom")
private val geolocationLabel = hasText("51.6213, 0.3056")
private val postCodeLabel = hasText("CM14")
private val timeZoneLabel = hasText("Europe/London")
private val internetServiceProviderLabel = hasText("TalkTalk Limited")
private val openSourceNoticesButton = hasText("Open Source Notices")
fun ComposeContentTestRule.seeIpAddressLabel() {
assertIsDisplayed(ipAddressLabel)
}
fun ComposeContentTestRule.seeIpAddressSubtitleLabel() {
assertIsDisplayed(ipAddressSubtitleLabel)
}
fun ComposeContentTestRule.seeCityLabel() {
assertIsDisplayed(cityLabel)
}
fun ComposeContentTestRule.seeRegionLabel() {
assertIsDisplayed(regionLabel)
}
fun ComposeContentTestRule.seeCountryLabel() {
assertIsDisplayed(countryLabel)
}
fun ComposeContentTestRule.seeGeolocationLabel() {
assertIsDisplayed(geolocationLabel)
}
fun ComposeContentTestRule.seePostCodeLabel() {
assertIsDisplayed(postCodeLabel)
}
fun ComposeContentTestRule.seeTimeZoneLabel() {
assertIsDisplayed(timeZoneLabel)
}
fun ComposeContentTestRule.seeInternetServiceProviderLabel() {
assertIsDisplayed(internetServiceProviderLabel)
}
fun ComposeContentTestRule.tapOpenSourceNotices() {
onNode(openSourceNoticesButton).performTouchInput { click() }
}
private fun ComposeContentTestRule.assertIsDisplayed(matcher: SemanticsMatcher) {
waitUntilExactlyOneExists(matcher, timeoutMillis = 5_000L)
}
}