mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-17 22:37:03 +05:30
Expand UI tests for addition
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
2c0b4fc072
commit
3d77f397f6
2 changed files with 23 additions and 10 deletions
|
@ -2,9 +2,11 @@ package dev.msfjarvis.todo
|
|||
|
||||
import androidx.ui.test.android.createAndroidComposeRule
|
||||
import androidx.ui.test.assertIsDisplayed
|
||||
import androidx.ui.test.hasTestTag
|
||||
import androidx.ui.test.onNode
|
||||
import androidx.ui.test.onNodeWithText
|
||||
import androidx.ui.test.performClick
|
||||
import dev.msfjarvis.todo.ui.TodoTheme
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
|
@ -13,17 +15,25 @@ class MainActivityTest {
|
|||
@get:Rule
|
||||
val composeTestRule = createAndroidComposeRule<MainActivity>(disableTransitions = true)
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
composeTestRule.setContent {
|
||||
TodoTheme {
|
||||
TodoApp()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_default_item() {
|
||||
composeTestRule.setContent {
|
||||
TodoTheme {
|
||||
TodoApp()
|
||||
}
|
||||
}
|
||||
onNodeWithText("Default item").assertIsDisplayed()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_item_addition() {
|
||||
composeTestRule.setContent {
|
||||
TodoTheme {
|
||||
TodoApp()
|
||||
}
|
||||
}
|
||||
onNodeWithText("Default item").assertIsDisplayed()
|
||||
onNode(hasTestTag("fab")).performClick()
|
||||
onNodeWithText("Item 2").assertIsDisplayed()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.runtime.mutableStateListOf
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.setContent
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.semantics.testTag
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.ui.tooling.preview.Preview
|
||||
import dev.msfjarvis.todo.data.TodoItem
|
||||
|
@ -47,6 +49,7 @@ fun TodoApp() {
|
|||
items.add(TodoItem("Item ${items.size + 1}"))
|
||||
},
|
||||
elevation = 8.dp,
|
||||
modifier = Modifier.semantics { testTag = "fab" }
|
||||
) {
|
||||
Icon(asset = Icons.Filled.ExposurePlus1, tint = MaterialTheme.colors.onSurface)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue