Skip to content

Commit

Permalink
Merge pull request #175 from tarkalabs/younes/screenshotsNew
Browse files Browse the repository at this point in the history
Adding Missing Screenshot tests.
  • Loading branch information
rajajawahar authored Jan 30, 2024
2 parents 6acf003 + 4ab81f5 commit c889226
Show file tree
Hide file tree
Showing 6 changed files with 307 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.tarkalabs.uicomponents.screenshots

import com.tarkalabs.uicomponents.components.checkbox.TUICheckBox
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

@RunWith(Parameterized::class)
open class TUICheckBoxScreenShotTest(
private val isChecked: Boolean,
private val testName: String,
private val darkTheme: Boolean,
) : ComposeScreenshotComparator() {

companion object {
@JvmStatic
@Parameterized.Parameters
fun data(): Collection<Array<Any>> {
val booleanList = listOf(true, false)
return mutableListOf<Array<Any>>().apply {
for (darkTheme in booleanList)
for (isChecked in booleanList)
add(arrayOf(isChecked, "darkTheme_${darkTheme}_checked_{$isChecked}", darkTheme))
}
}
}

@Test fun testTUICheckBoxScreenshot() =
compareScreenshotFor(darkTheme, "_testTUICheckBox_$testName") {
TUICheckBox(checked = isChecked, onCheckedChange = {})
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.tarkalabs.uicomponents.screenshots

import com.tarkalabs.uicomponents.components.TUIMultiLevelSelectorHeader
import com.tarkalabs.uicomponents.components.TUIStatus
import com.tarkalabs.uicomponents.components.TUIStatusIndicator
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

@RunWith(Parameterized::class)
class TUIMultiLevelSelectionHeaderScreenshotTest(
private val darkTheme: Boolean,
private val isSelected: Boolean,
private val testName: String,
) : ComposeScreenshotComparator() {

companion object {
@JvmStatic
@Parameterized.Parameters
fun data(): Collection<Array<Any?>> {

val booleanValues = listOf(true, false)

val testData = arrayListOf<Array<Any?>>()

for (darkTheme in booleanValues)
for (isSelected in booleanValues)
testData.add(
arrayOf(
darkTheme, isSelected, "darkTheme_${darkTheme}_isSelected_${isSelected}"
)
)

return testData
}
}

@Test
fun testTUMultiLevelSelectionHeader() {
compareScreenshotFor(darkTheme = darkTheme, imageName = testName) {
TUIMultiLevelSelectorHeader(title = "Title", isSelected = isSelected, onClick = {})
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.tarkalabs.uicomponents.screenshots

import com.tarkalabs.tarkaicons.AddCircle24
import com.tarkalabs.tarkaicons.TarkaIcon
import com.tarkalabs.tarkaicons.TarkaIcons
import com.tarkalabs.uicomponents.components.TUINavigationRow
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

@RunWith(Parameterized::class)
open class TUINavigationRowScreenShotTest(
private val showArrowRight: Boolean,
private val leadingIcon: TarkaIcon?,
private val testName: String,
private val darkTheme: Boolean,
) : ComposeScreenshotComparator() {

companion object {
@JvmStatic
@Parameterized.Parameters
fun data(): Collection<Array<Any?>> {
val booleans = listOf(true, false)
val icons: List<TarkaIcon?> = listOf(null, TarkaIcons.Filled.AddCircle24)
return mutableListOf<Array<Any?>>().apply {
for (darkTheme in booleans)
for (showArrow in booleans)
for (icon in icons)
add(
arrayOf(
showArrow,
icon,
"darkTheme_${darkTheme}_showArrow_{$showArrow}_${if (icon == null) null else "Icon"}",
darkTheme
)
)
}
}
}

@Test fun testNavigationRow() =
compareScreenshotFor(darkTheme, "_testNavigationRow_$testName") {
TUINavigationRow(
title = "Title",
leadingIcon = leadingIcon,
onClick = {},
showRightArrow = showArrowRight
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.tarkalabs.uicomponents.screenshots

import com.tarkalabs.tarkaicons.Person24
import com.tarkalabs.tarkaicons.TarkaIcon
import com.tarkalabs.tarkaicons.TarkaIcons
import com.tarkalabs.uicomponents.components.TUISearchBar
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

@RunWith(Parameterized::class)
class TUISearchBarScreenshotTest(
private val darkTheme: Boolean,
private val leadingIcon: TarkaIcon?,
private val query: String,
private val placeHolder: String,
private val testName: String,
) : ComposeScreenshotComparator() {

companion object {
@JvmStatic
@Parameterized.Parameters
fun data(): Collection<Array<Any?>> {

val darkThemeValues = listOf(true, false)
val leadingIconValues = listOf(TarkaIcons.Regular.Person24, null)
val queryValues = listOf("", "Query")
val placeHoldersValues = listOf("null", "Hint")

val testData = arrayListOf<Array<Any?>>()

for (darkTheme in darkThemeValues)
for (leadingIconValue in leadingIconValues)
for (queryValue in queryValues)
for (placeHoldersValue in placeHoldersValues)
testData.add(
arrayOf(
darkTheme, leadingIconValue, queryValue, placeHoldersValue,
"darkTheme_${darkTheme}_leadingIconValue_${if (leadingIconValue == null) "null" else "normal"}_query_${queryValue}_placeHolder_${placeHoldersValue}"
)
)

return testData
}
}

@Test
fun testTUISearchBar() {
compareScreenshotFor(darkTheme = darkTheme, imageName = testName) {
TUISearchBar(
query = query,
placeholder = placeHolder,
leadingIcon = leadingIcon,
onQueryTextChange = {},
onLeadingIconClick = {},
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.tarkalabs.uicomponents.screenshots

import com.tarkalabs.uicomponents.components.TUIStatus
import com.tarkalabs.uicomponents.components.TUIStatusIndicator
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

@RunWith(Parameterized::class)
class TUIStatusIndicatorScreenshotTest(
private val darkTheme: Boolean,
private val status: TUIStatus,
private val testName: String,
) : ComposeScreenshotComparator() {

companion object {
@JvmStatic
@Parameterized.Parameters
fun data(): Collection<Array<Any?>> {

val darkThemeValues = listOf(true, false)
val tuiStatuses = TUIStatus.values()

val testData = arrayListOf<Array<Any?>>()

for (darkTheme in darkThemeValues)
for (tuiStatus in tuiStatuses)
testData.add(
arrayOf(
darkTheme, tuiStatus, "darkTheme_${darkTheme}_TUIStatus_${tuiStatus}"
)
)

return testData
}
}

@Test
fun testTUIStatusIndicator() {
compareScreenshotFor(darkTheme = darkTheme, imageName = testName) {
TUIStatusIndicator(text = "Value", status = status)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.tarkalabs.uicomponents.screenshots

import com.tarkalabs.tarkaicons.Person24
import com.tarkalabs.tarkaicons.TarkaIcon
import com.tarkalabs.tarkaicons.TarkaIcons
import com.tarkalabs.uicomponents.components.TUITextRow
import com.tarkalabs.uicomponents.components.TextRowStyle
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

@RunWith(Parameterized::class)
class TUITextRowScreenshotTest(
private val darkTheme: Boolean,
private val style: TextRowStyle,
private val iconOne: TarkaIcon?,
private val iconTwo: TarkaIcon?,
private val infoIcon: TarkaIcon?,
private val buttonTitle: String?,
private val testName: String,
) : ComposeScreenshotComparator() {

companion object {
@JvmStatic
@Parameterized.Parameters
fun data(): Collection<Array<Any?>> {

val darkThemeValues = listOf(true, false)
val iconValues = listOf(TarkaIcons.Regular.Person24, null)
val buttonTitleValues = listOf(null, "Button")
val styles = listOf(TextRowStyle.Title, TextRowStyle.TitleWithDescription("description"))
val testData = arrayListOf<Array<Any?>>()

for (darkTheme in darkThemeValues)
for (style in styles)
for (iconOne in iconValues) {
for (iconTwo in iconValues) {
for (infoIcon in iconValues) {
for (buttonTitleValue in buttonTitleValues) {
testData.add(
arrayOf(
darkTheme,
style,
iconOne,
iconTwo,
infoIcon,
buttonTitleValue,
"darkTheme_${darkTheme}_style_${style}_iconOne_${iconOne.iconName()}_iconTwo_${iconTwo.iconName()}_infoicon_${infoIcon.iconName()}_buttonTitle_${buttonTitleValue}"
)
)
}
}
}
}


return testData
}
}

@Test
fun testTUIStatusIndicator() {
compareScreenshotFor(darkTheme = darkTheme, imageName = testName) {
TUITextRow(
title = "Some Title",
style = style,
iconOne = iconOne,
iconTwo = iconTwo,
buttonTitle = buttonTitle,
infoIcon = infoIcon,
)
}
}
}

fun TarkaIcon?.iconName(name: String = "normal"): String {
return if (this == null) "null" else name
}

0 comments on commit c889226

Please sign in to comment.