-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #175 from tarkalabs/younes/screenshotsNew
Adding Missing Screenshot tests.
- Loading branch information
Showing
6 changed files
with
307 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
.../src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUICheckBoxScreenShotTest.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,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 = {}) | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...java/com/tarkalabs/uicomponents/screenshots/TUIMultiLevelSelectionHeaderScreenshotTest.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,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 = {}) | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...androidTest/java/com/tarkalabs/uicomponents/screenshots/TUINavigationRowScreenShotTest.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,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 | ||
) | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUISearchBarScreenshotTest.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,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 = {}, | ||
) | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...droidTest/java/com/tarkalabs/uicomponents/screenshots/TUIStatusIndicatorScreenshotTest.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,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) | ||
} | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
...i/src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUITextRowScreenshotTest.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,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 | ||
} |