Improve coverage of BugReportView.
This commit is contained in:
parent
e120ca7163
commit
968f7f80fc
2 changed files with 17 additions and 7 deletions
|
|
@ -16,8 +16,19 @@
|
|||
|
||||
package io.element.android.features.rageshake.bugreport
|
||||
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import io.element.android.libraries.architecture.Async
|
||||
|
||||
open class BugReportStateProvider : PreviewParameterProvider<BugReportState> {
|
||||
override val values: Sequence<BugReportState>
|
||||
get() = sequenceOf(
|
||||
aBugReportState(),
|
||||
aBugReportState().copy(formState = BugReportFormState.Default.copy(description = "A long enough description"), hasCrashLogs = true),
|
||||
aBugReportState().copy(sending = Async.Loading()),
|
||||
aBugReportState().copy(sending = Async.Success(Unit)),
|
||||
)
|
||||
}
|
||||
|
||||
fun aBugReportState() = BugReportState(
|
||||
formState = BugReportFormState.Default,
|
||||
hasCrashLogs = false,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import androidx.compose.ui.text.input.ImeAction
|
|||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import coil.compose.AsyncImage
|
||||
|
|
@ -107,7 +108,7 @@ fun BugReportView(
|
|||
.padding(horizontal = 16.dp, vertical = 16.dp),
|
||||
fontSize = 16.sp,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
)
|
||||
var descriptionFieldState by textFieldState(
|
||||
stateValue = state.formState.description
|
||||
)
|
||||
|
|
@ -209,15 +210,13 @@ fun BugReportView(
|
|||
|
||||
@Preview
|
||||
@Composable
|
||||
fun BugReportViewLightPreview() = ElementPreviewLight { ContentToPreview() }
|
||||
fun BugReportViewLightPreview(@PreviewParameter(BugReportStateProvider::class) state: BugReportState) = ElementPreviewLight { ContentToPreview(state) }
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun BugReportViewDarkPreview() = ElementPreviewDark { ContentToPreview() }
|
||||
fun BugReportViewDarkPreview(@PreviewParameter(BugReportStateProvider::class) state: BugReportState) = ElementPreviewDark { ContentToPreview(state) }
|
||||
|
||||
@Composable
|
||||
private fun ContentToPreview() {
|
||||
BugReportView(
|
||||
state = aBugReportState(),
|
||||
)
|
||||
private fun ContentToPreview(state: BugReportState) {
|
||||
BugReportView(state = state)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue