ziv kesten
08/02/2022, 2:44 PM@Test
fun test_button_completed_state_correct(): Unit = runBlocking {
val completedText = mockStateButtonsList.items.first().contents.first { it.state == StateButtonListContent.ButtonState.COMPLETED }.button.caption.orEmpty()
// Given
composeTestRule.setContent {
TestStateButtonList(
StateButtonListStateReducer(mockStateButtonsList, this)
)
}
// When
composeTestRule
.onAllNodesWithTag(STATE_BUTTON)
.onFirst()
.performClick()
// Wait 5000 milliseconds
// Then
composeTestRule
.onAllNodesWithTag(STATE_BUTTON)
.onFirst()
.assert(hasText(completedText))
}
Landry Norris
08/02/2022, 2:46 PMoianmol
08/02/2022, 2:47 PMoianmol
08/02/2022, 2:48 PMrule.mainClock.advanceTimeBy(DefaultDurationMillis.toLong())
can you use advanceTimeBy to test this ? 🤔Landry Norris
08/02/2022, 2:48 PMoianmol
08/02/2022, 2:49 PMziv kesten
08/02/2022, 2:49 PMmainClock.autoAdvance = false
failes the testziv kesten
08/02/2022, 2:49 PMdelay
workedziv kesten
08/02/2022, 2:50 PMLandry Norris
08/02/2022, 2:50 PMziv kesten
08/02/2022, 2:51 PMziv kesten
08/02/2022, 2:51 PMjava.lang.AssertionError: Failed to assert the following: (Text + EditableText contains 'IN PROGRESS' (ignoreCase: false))
Semantics of the node:
Node #66 at (l=605.0, t=107.0, r=1033.0, b=258.0)px, Tag: 'test_button'
Role = 'Button'
Focused = 'false'
Text = '[CONNECT]'
Actions = [OnClick, GetTextLayoutResult]
MergeDescendants = 'true'
Has 11 siblings
Selector used: ((TestTag = 'test_button')[0])
Landry Norris
08/02/2022, 2:52 PMziv kesten
08/02/2022, 2:53 PMziv kesten
08/02/2022, 2:53 PMLandry Norris
08/02/2022, 2:53 PMziv kesten
08/02/2022, 2:54 PMLandry Norris
08/02/2022, 2:54 PMLandry Norris
08/02/2022, 2:54 PMziv kesten
08/02/2022, 2:55 PMrunBlockingTest
worked!!!ziv kesten
08/02/2022, 2:55 PMStylianos Gakis
08/02/2022, 9:30 PMrunBlockingTest
come from?Landry Norris
08/02/2022, 9:31 PMStylianos Gakis
08/02/2022, 9:38 PM