-
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 #177 from tarkalabs/ms/floatingNav_ssTest
ScreenShot test for TUIFloatingNavButton
- Loading branch information
Showing
15 changed files
with
566 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file added
BIN
+2.83 KB
...TUIFloatingNavButtonScreenShotTest__floatingNavBurgerButton_darkTheme_false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.47 KB
....TUIFloatingNavButtonScreenShotTest__floatingNavBurgerButton_darkTheme_true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.75 KB
...shots.TUIFloatingNavButtonScreenShotTest__floatingNavButton_darkTheme_false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.15 KB
...nshots.TUIFloatingNavButtonScreenShotTest__floatingNavButton_darkTheme_true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.12 KB
...s.TUIFloatingNavButtonScreenShotTest__floatingNavListButton_darkTheme_false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.75 KB
...ts.TUIFloatingNavButtonScreenShotTest__floatingNavListButton_darkTheme_true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.31 KB
...loatingNavButtonScreenShotTest__floatingNavViewToggleButton_darkTheme_false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.65 KB
...FloatingNavButtonScreenShotTest__floatingNavViewToggleButton_darkTheme_true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
157 changes: 157 additions & 0 deletions
157
tarkaui/src/androidTest/java/com/tarkalabs/uicomponents/TUIFloatingNavButtonTest.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,157 @@ | ||
package com.tarkalabs.uicomponents | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.performClick | ||
import com.tarkalabs.tarkaicons.CalendarRtl24 | ||
import com.tarkalabs.tarkaicons.Directions24 | ||
import com.tarkalabs.tarkaicons.Diversity24 | ||
import com.tarkalabs.tarkaicons.Map24 | ||
import com.tarkalabs.tarkaicons.TarkaIcons | ||
import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButton | ||
import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonContentType.Burger | ||
import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonContentType.List | ||
import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonContentType.Navigation | ||
import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.BURGER | ||
import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.LIST | ||
import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.VIEW_TOGGLE | ||
import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonTags | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.mockito.kotlin.mock | ||
import org.mockito.kotlin.verify | ||
|
||
class TUIFloatingNavButtonTest { | ||
|
||
@get:Rule val composable = createComposeRule() | ||
private val tags = TUIFloatingNavButtonTags() | ||
|
||
|
||
@Test fun floating_nav_btn_is_displayed() { | ||
val onClick: () -> Unit = mock() | ||
composable.run { | ||
setContent { | ||
TUIFloatingNavButton( | ||
contentType = Navigation(TarkaIcons.Filled.Diversity24, text = "Test"), | ||
onClicked = onClick, tags = tags | ||
) | ||
} | ||
onNodeWithTag(tags.parentTag).run { | ||
assertIsDisplayed() | ||
performClick() | ||
verify(onClick)() | ||
} | ||
|
||
onNodeWithTag(tags.leadingIconTag, true).assertIsDisplayed() | ||
onNodeWithTag(tags.trailingIconTag, true).assertIsDisplayed() | ||
} | ||
} | ||
|
||
@Test fun floating_nav_btn_trailing_icon_is_not_displayed() { | ||
val onClick: () -> Unit = mock() | ||
composable.run { | ||
setContent { | ||
TUIFloatingNavButton( | ||
contentType = Navigation(TarkaIcons.Filled.Diversity24, text = "Test"), | ||
onClicked = onClick, tags = tags, style = VIEW_TOGGLE | ||
) | ||
} | ||
onNodeWithTag(tags.parentTag).run { | ||
assertIsDisplayed() | ||
performClick() | ||
verify(onClick)() | ||
} | ||
|
||
onNodeWithTag(tags.leadingIconTag, true).assertIsDisplayed() | ||
onNodeWithTag(tags.trailingIconTag, true).assertDoesNotExist() | ||
} | ||
} | ||
|
||
@Test fun floating_nav_list_type_all_icons_are_displayed() { | ||
val onIconOneClick: () -> Unit = mock() | ||
val onIconTwoClick: () -> Unit = mock() | ||
val onIconThreeClick: () -> Unit = mock() | ||
|
||
composable.run { | ||
setContent { | ||
TUIFloatingNavButton( | ||
contentType = List( | ||
iconOne = TarkaIcons.Filled.CalendarRtl24, | ||
onIconOneClick = onIconOneClick, | ||
iconTwo = TarkaIcons.Filled.Map24, | ||
onIconTwoClick = onIconTwoClick, | ||
iconThree = TarkaIcons.Filled.Directions24, | ||
onIconThreeClick = onIconThreeClick | ||
), | ||
style = LIST | ||
) | ||
} | ||
onNodeWithTag(tags.iconOneTag).run { | ||
assertIsDisplayed() | ||
performClick() | ||
verify(onIconOneClick)() | ||
} | ||
onNodeWithTag(tags.iconTwoTag).run { | ||
assertIsDisplayed() | ||
performClick() | ||
verify(onIconTwoClick)() | ||
} | ||
onNodeWithTag(tags.iconThreeTag).run { | ||
assertIsDisplayed() | ||
performClick() | ||
verify(onIconThreeClick)() | ||
} | ||
} | ||
} | ||
|
||
@Test fun floating_nav_list_type_few_icons_are_displayed() { | ||
val onIconOneClick: () -> Unit = mock() | ||
val onIconTwoClick: () -> Unit = mock() | ||
|
||
composable.run { | ||
setContent { | ||
TUIFloatingNavButton( | ||
contentType = List( | ||
iconOne = TarkaIcons.Filled.CalendarRtl24, | ||
onIconOneClick = onIconOneClick, | ||
iconTwo = TarkaIcons.Filled.Map24, | ||
onIconTwoClick = onIconTwoClick, | ||
), | ||
style = LIST | ||
) | ||
} | ||
onNodeWithTag(tags.iconOneTag).run { | ||
assertIsDisplayed() | ||
performClick() | ||
verify(onIconOneClick)() | ||
} | ||
onNodeWithTag(tags.iconTwoTag).run { | ||
assertIsDisplayed() | ||
performClick() | ||
verify(onIconTwoClick)() | ||
} | ||
onNodeWithTag(tags.iconThreeTag).run { | ||
assertDoesNotExist() | ||
} | ||
} | ||
} | ||
|
||
@Test fun floating_nav_burger_button_is_displayed() { | ||
val onClick: () -> Unit = mock() | ||
composable.run { | ||
setContent { | ||
TUIFloatingNavButton( | ||
contentType = Burger, | ||
style = BURGER, | ||
onClicked = onClick | ||
) | ||
} | ||
onNodeWithTag(tags.burgerIconTag, true).run { | ||
assertIsDisplayed() | ||
performClick() | ||
verify(onClick)() | ||
} | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...oidTest/java/com/tarkalabs/uicomponents/screenshots/TUIFloatingNavButtonScreenShotTest.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,68 @@ | ||
package com.tarkalabs.uicomponents.screenshots | ||
|
||
import com.tarkalabs.tarkaicons.CalendarRtl24 | ||
import com.tarkalabs.tarkaicons.Directions24 | ||
import com.tarkalabs.tarkaicons.Diversity24 | ||
import com.tarkalabs.tarkaicons.Map24 | ||
import com.tarkalabs.tarkaicons.TarkaIcons | ||
import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButton | ||
import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonContentType.Burger | ||
import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonContentType.List | ||
import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonContentType.Navigation | ||
import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.BURGER | ||
import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.LIST | ||
import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.NAVIGATION | ||
import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.VIEW_TOGGLE | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.Parameterized | ||
|
||
@RunWith(Parameterized::class) | ||
class TUIFloatingNavButtonScreenShotTest( | ||
private val darkTheme: Boolean, | ||
private val testName: String, | ||
) : ComposeScreenshotComparator() { | ||
|
||
companion object { | ||
@JvmStatic | ||
@Parameterized.Parameters | ||
fun data(): Collection<Array<Any?>> { | ||
return mutableListOf<Array<Any?>>().apply { | ||
for (darkTheme in listOf(true, false)) { | ||
val testName = "darkTheme_${darkTheme}" | ||
add(arrayOf(darkTheme, testName)) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Test fun floatingNavButton() = compareScreenshotFor(darkTheme, "_floatingNavButton_$testName") { | ||
TUIFloatingNavButton( | ||
contentType = Navigation(leadingIcon = TarkaIcons.Filled.Diversity24, text = "Overview"), | ||
style = NAVIGATION | ||
) | ||
} | ||
|
||
@Test fun floatingNavViewToggleButton() = | ||
compareScreenshotFor(darkTheme, "_floatingNavViewToggleButton_$testName") { | ||
TUIFloatingNavButton( | ||
contentType = Navigation(leadingIcon = TarkaIcons.Filled.Diversity24, text = "Overview"), | ||
style = VIEW_TOGGLE | ||
) | ||
} | ||
|
||
@Test fun floatingNavBurgerButton() = | ||
compareScreenshotFor(darkTheme, "_floatingNavBurgerButton_$testName") { | ||
TUIFloatingNavButton(contentType = Burger, style = BURGER) | ||
} | ||
|
||
@Test fun floatingNavListButton() = | ||
compareScreenshotFor(darkTheme, "_floatingNavListButton_$testName") { | ||
TUIFloatingNavButton( | ||
contentType = List( | ||
iconOne = TarkaIcons.Filled.CalendarRtl24, iconTwo = TarkaIcons.Filled.Map24, | ||
iconThree = TarkaIcons.Filled.Directions24 | ||
), style = LIST | ||
) | ||
} | ||
} |
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
Oops, something went wrong.