Skip to content

Commit bb6ab4a

Browse files
committed
tests updated.
1 parent 1546dd6 commit bb6ab4a

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

mobile/src/androidTest/java/io/syslogic/demo/colorpicker/TestComposeActivity.kt

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,107 +46,107 @@ class TestComposeActivity : TestSuite() {
4646
@OptIn(ExperimentalTestApi::class)
4747
fun huePanelTest() {
4848

49-
interaction = composeTestRule.onNodeWithTag(testTag = "hue")
49+
interaction = getNodeWithTag("hue")
5050
interaction.assertExists().assertIsDisplayed()
5151

5252
/* Randomly tapping the huePanel for 5 seconds. */
5353
for (i in 0..99) {
5454
randomlyClick(interaction)
55-
Thread.sleep(50)
55+
sleep(50)
5656
}
5757
}
5858

5959
@Test
6060
@OptIn(ExperimentalTestApi::class)
6161
fun satValPanelTest() {
6262

63-
interaction = composeTestRule.onNodeWithTag(testTag = "sat_val")
63+
interaction = getNodeWithTag("sat_val")
6464
interaction.assertExists().assertIsDisplayed()
6565

6666
/* Randomly tapping the satValPanel for 5 seconds. */
6767
for (i in 0..99) {
6868
randomlyClick(interaction)
69-
Thread.sleep(50)
69+
sleep(50)
7070
}
7171
}
7272

7373
@Test
7474
@OptIn(ExperimentalTestApi::class)
7575
fun alphaPanelTest() {
7676

77-
interaction = composeTestRule.onNodeWithTag(testTag = "alpha")
77+
interaction = getNodeWithTag("alpha")
7878
interaction.assertExists().assertIsDisplayed()
7979

8080
/* Randomly tapping the alphaPanel for 5 seconds. */
8181
for (i in 0..99) {
8282
randomlyClick(interaction)
83-
Thread.sleep(50)
83+
sleep(50)
8484
}
8585
}
8686

8787
@Test
8888
fun hexColorTest() {
89-
interaction = composeTestRule.onNodeWithTag(testTag = "hex")
89+
interaction = getNodeWithTag("hex")
9090
interaction.assertExists().assertIsDisplayed()
9191
}
9292

9393
@Test
9494
fun oldColorTest() {
95-
interaction = composeTestRule.onNodeWithTag(testTag = "old_color")
95+
interaction = getNodeWithTag("old_color")
9696
interaction.assertExists().assertIsDisplayed()
9797
}
9898

9999
@Test
100100
fun newColorTest() {
101-
interaction = composeTestRule.onNodeWithTag(testTag = "new_color")
101+
interaction = getNodeWithTag("new_color")
102102
interaction.assertExists().assertIsDisplayed()
103103
}
104104

105105
@Test
106106
fun valueHueTest() {
107-
interaction = composeTestRule.onNodeWithTag(testTag = "value_hue")
107+
interaction = getNodeWithTag("value_hue")
108108
interaction.assertExists().assertIsDisplayed()
109109
}
110110

111111
@Test
112112
fun valueSatTest() {
113-
interaction = composeTestRule.onNodeWithTag(testTag = "value_sat")
113+
interaction = getNodeWithTag("value_sat")
114114
interaction.assertExists().assertIsDisplayed()
115115
}
116116

117117
@Test
118118
fun valueValTest() {
119-
interaction = composeTestRule.onNodeWithTag(testTag = "value_val")
119+
interaction = getNodeWithTag("value_val")
120120
interaction.assertExists().assertIsDisplayed()
121121
}
122122

123123
@Test
124124
fun valueAlphaTest() {
125-
interaction = composeTestRule.onNodeWithTag(testTag = "value_alpha")
125+
interaction = getNodeWithTag("value_alpha")
126126
interaction.assertExists().assertIsDisplayed()
127127
}
128128

129129
@Test
130130
fun valueBlueTest() {
131-
interaction = composeTestRule.onNodeWithTag(testTag = "value_blue")
131+
interaction = getNodeWithTag("value_blue")
132132
interaction.assertExists().assertIsDisplayed()
133133
}
134134

135135
@Test
136136
fun valueRedTest() {
137-
interaction = composeTestRule.onNodeWithTag(testTag = "value_red")
137+
interaction = getNodeWithTag("value_red")
138138
interaction.assertExists().assertIsDisplayed()
139139
}
140140

141141
@Test
142142
fun valueGreenTest() {
143-
interaction = composeTestRule.onNodeWithTag(testTag = "value_green")
143+
interaction = getNodeWithTag("value_green")
144144
interaction.assertExists().assertIsDisplayed()
145145
}
146146

147147
@Override
148148
@ExperimentalTestApi
149-
fun randomlyClick(interaction: SemanticsNodeInteraction) {
149+
private fun randomlyClick(interaction: SemanticsNodeInteraction) {
150150
val rect = interaction.getBoundsInRoot()
151151
val rnd = Random()
152152
val coordinate = longArrayOf(
@@ -158,4 +158,8 @@ class TestComposeActivity : TestSuite() {
158158
click(position)
159159
}
160160
}
161+
162+
private fun getNodeWithTag(testTag: String): SemanticsNodeInteraction {
163+
return composeTestRule.onNodeWithTag(testTag = testTag)
164+
}
161165
}

0 commit comments

Comments
 (0)