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