-
Notifications
You must be signed in to change notification settings - Fork 718
/
Copy pathRallyActivityBaseRockGeneratedTest.kt
149 lines (128 loc) · 5.14 KB
/
RallyActivityBaseRockGeneratedTest.kt
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package com.example.compose.rally
import androidx.compose.ui.test.*
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.espresso.IdlingPolicies
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import java.util.concurrent.TimeUnit
@RunWith(AndroidJUnit4::class)
class RallyActivityBaseRockGeneratedTest {
@get:Rule
val composeTestRule = createComposeRule()
@Before
fun setUp() {
IdlingPolicies.setIdlingResourceTimeout(3, TimeUnit.SECONDS)
composeTestRule.mainClock.autoAdvance = false
composeTestRule.mainClock.advanceTimeBy(1000)
}
@Test(timeout = 15000)
fun testRallyAppInitialState() {
composeTestRule.setContent {
RallyApp()
}
try {
composeTestRule.onNodeWithContentDescription("Overview").assertIsSelected()
composeTestRule.onNodeWithContentDescription("Accounts").assertExists()
composeTestRule.onNodeWithContentDescription("Bills").assertExists()
} catch (e: AssertionError) {
throw AssertionError(e.message + " Current tree: " + getRootTrees())
}
}
@Test(timeout = 15000)
fun testRallyAppTabNavigation() {
composeTestRule.setContent {
RallyApp()
}
try {
composeTestRule.onNodeWithContentDescription("Accounts").performClick()
composeTestRule.onNodeWithContentDescription("Accounts").assertExists()
composeTestRule.onNodeWithContentDescription("Bills").performClick()
composeTestRule.onNodeWithContentDescription("Bills").assertExists()
composeTestRule.onNodeWithContentDescription("Overview").performClick()
composeTestRule.onNodeWithContentDescription("Overview").assertExists()
} catch (e: AssertionError) {
throw AssertionError(e.message + " Current tree: " + getRootTrees())
}
}
@Test(timeout = 15000)
fun testRallyAppOverviewScreen() {
composeTestRule.setContent {
RallyApp()
}
try {
composeTestRule.onNodeWithContentDescription("Overview").assertIsSelected()
composeTestRule.onNodeWithText("Accounts").assertExists()
composeTestRule.onNodeWithText("Bills").assertExists()
} catch (e: AssertionError) {
throw AssertionError(e.message + " Current tree: " + getRootTrees())
}
}
@Test(timeout = 15000)
fun testRallyAppAccountsScreen() {
composeTestRule.setContent {
RallyApp()
}
try {
composeTestRule.onNodeWithContentDescription("Accounts").performClick()
composeTestRule.onNodeWithText("Accounts").assertExists()
composeTestRule.onNodeWithContentDescription("Accounts").assertExists()
} catch (e: AssertionError) {
throw AssertionError(e.message + " Current tree: " + getRootTrees())
}
}
@Test(timeout = 15000)
fun testRallyAppBillsScreen() {
composeTestRule.setContent {
RallyApp()
}
try {
composeTestRule.onNodeWithContentDescription("Bills").performClick()
composeTestRule.onNodeWithText("Bills").assertExists()
composeTestRule.onNodeWithContentDescription("Bills").assertExists()
} catch (e: AssertionError) {
throw AssertionError(e.message + " Current tree: " + getRootTrees())
}
}
@Test(timeout = 15000)
fun testRallyAppTopBarVisibility() {
composeTestRule.setContent {
RallyApp()
}
try {
composeTestRule.onNodeWithContentDescription("Overview").assertExists()
composeTestRule.onNodeWithContentDescription("Accounts").assertExists()
composeTestRule.onNodeWithContentDescription("Bills").assertExists()
} catch (e: AssertionError) {
throw AssertionError(e.message + " Current tree: " + getRootTrees())
}
}
@Test(timeout = 15000)
fun testRallyAppScreenContentChanges() {
composeTestRule.setContent {
RallyApp()
}
try {
composeTestRule.onNodeWithContentDescription("Overview").assertExists()
composeTestRule.onNodeWithContentDescription("Accounts").performClick()
composeTestRule.onNodeWithContentDescription("Accounts").assertExists()
composeTestRule.onNodeWithContentDescription("Bills").performClick()
composeTestRule.onNodeWithContentDescription("Bills").assertExists()
} catch (e: AssertionError) {
throw AssertionError(e.message + " Current tree: " + getRootTrees())
}
}
private fun getRootTrees(): String {
val allRootNodes = composeTestRule.onAllNodes(isRoot())
val builder = StringBuilder()
for (i in 0 until allRootNodes.fetchSemanticsNodes().size) {
builder.append("\n")
builder.append("Root Node #$i: \n")
builder.append(allRootNodes[i].printToString())
builder.append("\n")
}
return builder.toString()
}
}