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 { |
||||
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() |
||||
Column { |
||||
LinearProgressIndicator() |
||||
Text(text = "Loading with text...", modifier = Modifier.padding(8.dp)) |
||||
} |
||||
} |
||||
} |
@ -1,38 +1,46 @@
|
||||
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.padding |
||||
import androidx.compose.material.Snackbar |
||||
import androidx.compose.material.Text |
||||
import androidx.compose.material.TextButton |
||||
import androidx.compose.runtime.Composable |
||||
import androidx.compose.ui.Modifier |
||||
import androidx.compose.ui.platform.testTag |
||||
import androidx.compose.ui.unit.dp |
||||
import org.jetbrains.compose.demo.widgets.theme.typography |
||||
import org.jetbrains.compose.demo.widgets.ui.WidgetsType |
||||
|
||||
@Composable |
||||
fun SnackBars() { |
||||
Snackbar(modifier = Modifier.padding(4.dp)) { |
||||
Text(text = "This is a basic snackbar") |
||||
} |
||||
Snackbar( |
||||
modifier = Modifier.padding(4.dp), |
||||
action = { |
||||
TextButton(onClick = {}) { |
||||
Text(text = "Remove") |
||||
Column( |
||||
modifier = Modifier |
||||
.padding(4.dp) |
||||
.testTag(WidgetsType.SNACK_BARS.testTag), |
||||
verticalArrangement = Arrangement.spacedBy(8.dp) |
||||
) { |
||||
Snackbar { |
||||
Text(text = "This is a basic snackbar") |
||||
} |
||||
Snackbar( |
||||
action = { |
||||
TextButton(onClick = {}) { |
||||
Text(text = "Remove") |
||||
} |
||||
} |
||||
) { |
||||
Text(text = "This is a basic snackbar with action item") |
||||
} |
||||
) { |
||||
Text(text = "This is a basic Snackbar with action item") |
||||
} |
||||
Snackbar( |
||||
modifier = Modifier.padding(4.dp), |
||||
actionOnNewLine = true, |
||||
action = { |
||||
TextButton(onClick = {}) { |
||||
Text(text = "Remove") |
||||
Snackbar( |
||||
actionOnNewLine = true, |
||||
action = { |
||||
TextButton(onClick = {}) { |
||||
Text(text = "Remove") |
||||
} |
||||
} |
||||
) { |
||||
Text(text = "Snackbar with action item below text") |
||||
} |
||||
) { |
||||
Text(text = "Snackbar with action item below text") |
||||
} |
||||
} |
||||
|
@ -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() |
||||
} |
||||
} |
||||
} |