-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [ANDROAPP-6122] add Snapshot test to Button class with all opti…
…ons displayed in button screen
- Loading branch information
1 parent
4d2fb9a
commit 2b71770
Showing
2 changed files
with
287 additions
and
0 deletions.
There are no files selected for viewing
284 changes: 284 additions & 0 deletions
284
...tem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/ButtonSnapshotTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,284 @@ | ||
package org.hisp.dhis.mobile.ui.designsystem | ||
|
||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Add | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.ui.Modifier | ||
import org.hisp.dhis.mobile.ui.designsystem.component.Button | ||
import org.hisp.dhis.mobile.ui.designsystem.component.ButtonStyle | ||
import org.hisp.dhis.mobile.ui.designsystem.component.ColorStyle | ||
import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer | ||
import org.hisp.dhis.mobile.ui.designsystem.component.RowComponentContainer | ||
import org.hisp.dhis.mobile.ui.designsystem.component.SubTitle | ||
import org.hisp.dhis.mobile.ui.designsystem.component.Title | ||
import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class ButtonSnapshotTest { | ||
|
||
@get:Rule | ||
val paparazzi = paparazzi() | ||
|
||
@Test | ||
fun launchButtonSnapshot() { | ||
paparazzi.snapshot { | ||
ColumnComponentContainer() { | ||
Title("Buttons") | ||
SubTitle("Filled") | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.FILLED, onClick = {}) | ||
Button(text = "Label", style = ButtonStyle.FILLED, enabled = false, onClick = {}) | ||
} | ||
RowComponentContainer { | ||
Button(text = "Label", style = ButtonStyle.FILLED, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
Button(text = "Label", style = ButtonStyle.FILLED, enabled = false, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
} | ||
|
||
Spacer(Modifier.size(Spacing.Spacing18)) | ||
SubTitle("Outlined") | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.OUTLINED, onClick = {}) | ||
Button(text = "Label", style = ButtonStyle.OUTLINED, enabled = false, onClick = {}) | ||
} | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.OUTLINED, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
Button(text = "Label", style = ButtonStyle.OUTLINED, enabled = false, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
} | ||
Spacer(Modifier.size(Spacing.Spacing18)) | ||
|
||
SubTitle("Text") | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.TEXT, enabled = true, onClick = {}) | ||
Button(text = "Label", style = ButtonStyle.TEXT, enabled = false, onClick = {}) | ||
} | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.TEXT, enabled = true, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
Button(text = "Label", style = ButtonStyle.TEXT, enabled = false, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
} | ||
Spacer(Modifier.size(Spacing.Spacing18)) | ||
|
||
SubTitle("Elevated") | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.ELEVATED, enabled = true, onClick = {}) | ||
Button(text = "Label", style = ButtonStyle.ELEVATED, enabled = false, onClick = {}) | ||
} | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.ELEVATED, enabled = true, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
Button(text = "Label", style = ButtonStyle.ELEVATED, enabled = false, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
} | ||
Spacer(Modifier.size(Spacing.Spacing18)) | ||
|
||
SubTitle("Tonal") | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.TONAL, enabled = true, onClick = {}) | ||
Button(text = "Label", style = ButtonStyle.TONAL, enabled = false, onClick = {}) | ||
} | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.TONAL, enabled = true, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
Button(text = "Label", style = ButtonStyle.TONAL, enabled = false, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
} | ||
Spacer(Modifier.size(Spacing.Spacing18)) | ||
|
||
SubTitle("Keyboard") | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.KEYBOARDKEY, onClick = {}) | ||
Button(text = "Label", style = ButtonStyle.KEYBOARDKEY, enabled = false, onClick = {}) | ||
} | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.KEYBOARDKEY, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
Button(text = "Label", style = ButtonStyle.KEYBOARDKEY, enabled = false, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
} | ||
|
||
Title("Error Buttons") | ||
SubTitle("Filled") | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.FILLED, enabled = true, colorStyle = ColorStyle.ERROR, onClick = {}) | ||
Button(text = "Label", style = ButtonStyle.FILLED, enabled = false, colorStyle = ColorStyle.ERROR, onClick = {}) | ||
} | ||
RowComponentContainer { | ||
Button(text = "Label", style = ButtonStyle.FILLED, enabled = true, colorStyle = ColorStyle.ERROR, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
Button(text = "Label", style = ButtonStyle.FILLED, enabled = false, colorStyle = ColorStyle.ERROR, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
} | ||
|
||
Spacer(Modifier.size(Spacing.Spacing18)) | ||
SubTitle("Outlined") | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.OUTLINED, enabled = true, colorStyle = ColorStyle.ERROR, onClick = {}) | ||
Button(text = "Label", style = ButtonStyle.OUTLINED, enabled = false, colorStyle = ColorStyle.ERROR, onClick = {}) | ||
} | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.OUTLINED, enabled = true, colorStyle = ColorStyle.ERROR, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
Button(text = "Label", style = ButtonStyle.OUTLINED, enabled = false, colorStyle = ColorStyle.ERROR, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
} | ||
Spacer(Modifier.size(Spacing.Spacing18)) | ||
|
||
SubTitle("Text") | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.TEXT, enabled = true, colorStyle = ColorStyle.ERROR, onClick = {}) | ||
Button(text = "Label", style = ButtonStyle.TEXT, enabled = false, colorStyle = ColorStyle.ERROR, onClick = {}) | ||
} | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.TEXT, enabled = true, colorStyle = ColorStyle.ERROR, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
Button(text = "Label", style = ButtonStyle.TEXT, enabled = false, colorStyle = ColorStyle.ERROR, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
} | ||
Spacer(Modifier.size(Spacing.Spacing18)) | ||
|
||
Title("Warning Buttons") | ||
SubTitle("Filled") | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.FILLED, enabled = true, colorStyle = ColorStyle.WARNING, onClick = {}) | ||
Button(text = "Label", style = ButtonStyle.FILLED, enabled = false, colorStyle = ColorStyle.WARNING, onClick = {}) | ||
} | ||
RowComponentContainer { | ||
Button(text = "Label", style = ButtonStyle.FILLED, enabled = true, colorStyle = ColorStyle.WARNING, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
Button(text = "Label", style = ButtonStyle.FILLED, enabled = false, colorStyle = ColorStyle.WARNING, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
} | ||
|
||
Spacer(Modifier.size(Spacing.Spacing18)) | ||
SubTitle("Outlined") | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.OUTLINED, enabled = true, colorStyle = ColorStyle.WARNING, onClick = {}) | ||
Button(text = "Label", style = ButtonStyle.OUTLINED, enabled = false, colorStyle = ColorStyle.WARNING, onClick = {}) | ||
} | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.OUTLINED, enabled = true, colorStyle = ColorStyle.WARNING, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
Button(text = "Label", style = ButtonStyle.OUTLINED, enabled = false, colorStyle = ColorStyle.WARNING, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
} | ||
Spacer(Modifier.size(Spacing.Spacing18)) | ||
|
||
SubTitle("Text") | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.TEXT, enabled = true, colorStyle = ColorStyle.WARNING, onClick = {}) | ||
Button(text = "Label", style = ButtonStyle.TEXT, enabled = false, colorStyle = ColorStyle.WARNING, onClick = {}) | ||
} | ||
RowComponentContainer() { | ||
Button(text = "Label", style = ButtonStyle.TEXT, enabled = true, colorStyle = ColorStyle.WARNING, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
Button(text = "Label", style = ButtonStyle.TEXT, enabled = false, colorStyle = ColorStyle.WARNING, onClick = {}, icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Add, | ||
contentDescription = "Button", | ||
) | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...rg.hisp.dhis.mobile.ui.designsystem_ButtonSnapshotTest_launchButtonSnapshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.