Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
@ -1,9 +0,0 @@
|
||||
package org.jetbrains.compose.demo.widgets.platform |
||||
|
||||
object Res { |
||||
object strings { |
||||
val spotify_nav_home = "Home" |
||||
val spotify_nav_search = "Search" |
||||
val spotify_nav_library = "Your Library" |
||||
} |
||||
} |
@ -1,41 +1,34 @@
|
||||
package org.jetbrains.compose.demo.widgets.ui.screens |
||||
|
||||
import androidx.compose.foundation.layout.Arrangement |
||||
import androidx.compose.foundation.layout.Column |
||||
import androidx.compose.foundation.layout.Row |
||||
import androidx.compose.foundation.layout.fillMaxWidth |
||||
import androidx.compose.foundation.layout.padding |
||||
import androidx.compose.material.CircularProgressIndicator |
||||
import androidx.compose.material.LinearProgressIndicator |
||||
import androidx.compose.material.Text |
||||
import androidx.compose.runtime.Composable |
||||
import androidx.compose.ui.Alignment |
||||
import androidx.compose.ui.Modifier |
||||
import androidx.compose.ui.platform.testTag |
||||
import androidx.compose.ui.unit.dp |
||||
import org.jetbrains.compose.demo.widgets.ui.WidgetsType |
||||
|
||||
@Composable |
||||
fun Loaders() { |
||||
AlignedColumn { |
||||
Column( |
||||
modifier = Modifier |
||||
.padding(16.dp) |
||||
.testTag(WidgetsType.LOADERS.testTag), |
||||
verticalArrangement = Arrangement.spacedBy(16.dp) |
||||
) { |
||||
CircularProgressIndicator() |
||||
} |
||||
|
||||
AlignedColumn { |
||||
CircularProgressIndicator(strokeWidth = 8.dp) |
||||
} |
||||
|
||||
AlignedColumn { |
||||
LinearProgressIndicator() |
||||
} |
||||
|
||||
AlignedColumn { |
||||
Column { |
||||
LinearProgressIndicator() |
||||
Text(text = "Loading with text...", modifier = Modifier.padding(8.dp)) |
||||
} |
||||
} |
||||
@Composable |
||||
private fun AlignedColumn(content: @Composable () -> Unit) { |
||||
Column( |
||||
modifier = Modifier.fillMaxWidth().padding(16.dp) |
||||
) { |
||||
content() |
||||
} |
||||
} |
@ -0,0 +1,34 @@
|
||||
import androidx.compose.material.* |
||||
import androidx.compose.runtime.* |
||||
import androidx.compose.ui.Modifier |
||||
import androidx.compose.ui.platform.testTag |
||||
import androidx.compose.ui.test.* |
||||
import kotlin.test.Test |
||||
|
||||
|
||||
/** |
||||
* This is a simple, sample test. |
||||
*/ |
||||
class ExampleTest { |
||||
@OptIn(ExperimentalTestApi::class) |
||||
@Test |
||||
fun myTest() = runComposeUiTest { |
||||
setContent { |
||||
var text by remember { mutableStateOf("Hello") } |
||||
Text( |
||||
text = text, |
||||
modifier = Modifier.testTag("text") |
||||
) |
||||
Button( |
||||
onClick = { text = "Compose" }, |
||||
modifier = Modifier.testTag("button") |
||||
){ |
||||
Text("Click me") |
||||
} |
||||
} |
||||
|
||||
onNodeWithTag("text").assertTextEquals("Hello") |
||||
onNodeWithTag("button").performClick() |
||||
onNodeWithTag("text").assertTextEquals("Compose") |
||||
} |
||||
} |
@ -0,0 +1,28 @@
|
||||
import androidx.compose.ui.test.ExperimentalTestApi |
||||
import androidx.compose.ui.test.onNodeWithTag |
||||
import androidx.compose.ui.test.performClick |
||||
import androidx.compose.ui.test.runComposeUiTest |
||||
import org.jetbrains.compose.demo.widgets.ui.WidgetsPanel |
||||
import org.jetbrains.compose.demo.widgets.ui.WidgetsType |
||||
import org.jetbrains.compose.demo.widgets.ui.listItemTestTag |
||||
import kotlin.test.Test |
||||
|
||||
|
||||
@OptIn(ExperimentalTestApi::class) |
||||
class WidgetsPanelTest { |
||||
/** |
||||
* Tests that clicking on each widget type in the list shows the corresponding widgets view. |
||||
*/ |
||||
@OptIn(ExperimentalTestApi::class) |
||||
@Test |
||||
fun clickingOnWidgetListItemShowsCorrectWidgetUi() = runComposeUiTest { |
||||
setContent { |
||||
WidgetsPanel() |
||||
} |
||||
|
||||
for (widgetsType in WidgetsType.entries) { |
||||
onNodeWithTag(widgetsType.listItemTestTag).performClick() |
||||
onNodeWithTag(widgetsType.testTag).assertExists() |
||||
} |
||||
} |
||||
} |