From fdbde9143b03596a629588158765afa2500e6b4e Mon Sep 17 00:00:00 2001 From: Mahendran Date: Tue, 12 Mar 2024 15:06:17 +0530 Subject: [PATCH] ScreenShot Test & UI Test Included for TUIBadge latest changes. --- ...st__testBadgeWithCount_darkTheme_false.png | Bin 0 -> 1597 bytes ...est__testBadgeWithCount_darkTheme_true.png | Bin 0 -> 1357 bytes ...est__testBadgeWithIcon_darkTheme_false.png | Bin 0 -> 2483 bytes ...Test__testBadgeWithIcon_darkTheme_true.png | Bin 0 -> 2287 bytes .../tarkalabs/uicomponents/TUIBadgeTest.kt | 33 ++++++++++++++++-- .../screenshots/TUIBadgeScreenShotTest.kt | 10 +++--- .../tarkaui/components/base/TUIBadge.kt | 2 ++ 7 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 tarka-ui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIBadgeScreenShotTest__testBadgeWithCount_darkTheme_false.png create mode 100644 tarka-ui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIBadgeScreenShotTest__testBadgeWithCount_darkTheme_true.png create mode 100644 tarka-ui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIBadgeScreenShotTest__testBadgeWithIcon_darkTheme_false.png create mode 100644 tarka-ui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIBadgeScreenShotTest__testBadgeWithIcon_darkTheme_true.png diff --git a/tarka-ui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIBadgeScreenShotTest__testBadgeWithCount_darkTheme_false.png b/tarka-ui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIBadgeScreenShotTest__testBadgeWithCount_darkTheme_false.png new file mode 100644 index 0000000000000000000000000000000000000000..e291aecc945586840b31adec663d0628ca75325f GIT binary patch literal 1597 zcmV-D2EzG?P)Px#1am@3R0s$N2z&@+hyVZu=Sf6CR9J=0nSD$XcNoXNzoUiru7bP{!773xVG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ePxJlrls(qmqb-}T9r;C&4tdi{+R``;N$aax*vs1OyA0%t>e!j^nNNjhuz zgsxVM3C$m+;t!Uh(#Ar?ol1qXTBB04Pf7Z1Np0zAWk}*=3d2&>_7zz*xGpr;Et~T~ zu~$nTR)Xj{YHm_!E=bKek)QfhgNn_s6gsjec)PV^hY~c@Fvk*3fp;lO#FVO4gEf=# zqC*R|YUkjqO*_r{C{8Q50jJTJ5Sm$>uFtq|dJ5NtQ?afW{s&cei5Eezn;!rG002ov JPDHLkV1gt-Y@7f9 literal 0 HcmV?d00001 diff --git a/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/TUIBadgeTest.kt b/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/TUIBadgeTest.kt index e8930b71..02a1b33d 100644 --- a/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/TUIBadgeTest.kt +++ b/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/TUIBadgeTest.kt @@ -3,9 +3,14 @@ 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.onNodeWithText import com.tarkalabs.tarkaui.components.base.BadgeSize.L +import com.tarkalabs.tarkaui.components.base.BadgeStyle import com.tarkalabs.tarkaui.components.base.TUIBadge import com.tarkalabs.tarkaui.components.base.TUIBadgeTags +import com.tarkalabs.tarkaui.icons.Symbols16 +import com.tarkalabs.tarkaui.icons.TarkaIcon +import com.tarkalabs.tarkaui.icons.TarkaIcons import org.junit.Rule import org.junit.Test @@ -14,12 +19,34 @@ class TUIBadgeTest { private val tags = TUIBadgeTags(parentTag = "testTag") - @Test fun badge_Displayed() { + @Test fun text_badge_Displayed() { composeTestRule.setContent { TUIBadge( - badgeSize = L, tags = tags, count = 299 + badgeSize = L, tags = tags, style = BadgeStyle.Count(299) ) } - composeTestRule.onNodeWithTag(tags.parentTag).assertIsDisplayed() + composeTestRule.onNodeWithText("299").assertIsDisplayed() + composeTestRule.onNodeWithTag(tags.iconTag).assertDoesNotExist() } + + + @Test fun icon_badge_Displayed() { + composeTestRule.setContent { + TUIBadge( + badgeSize = L, tags = tags, style = BadgeStyle.Icon(TarkaIcons.Regular.Symbols16) + ) + } + composeTestRule.onNodeWithTag(tags.iconTag).assertIsDisplayed() + } + + @Test fun empty_badge_Displayed() { + composeTestRule.setContent { + TUIBadge( + badgeSize = L, tags = tags + ) + } + composeTestRule.onNodeWithTag(tags.iconTag).assertDoesNotExist() + composeTestRule.onNodeWithTag(tags.parentTag).assertExists() + } + } \ No newline at end of file diff --git a/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUIBadgeScreenShotTest.kt b/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUIBadgeScreenShotTest.kt index a8356441..b1098ce9 100644 --- a/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUIBadgeScreenShotTest.kt +++ b/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUIBadgeScreenShotTest.kt @@ -1,8 +1,10 @@ package com.tarkalabs.uicomponents.screenshots import com.tarkalabs.tarkaui.components.base.BadgeSize.M -import com.tarkalabs.tarkaui.components.base.BadgeSize.S +import com.tarkalabs.tarkaui.components.base.BadgeStyle import com.tarkalabs.tarkaui.components.base.TUIBadge +import com.tarkalabs.tarkaui.icons.Info20 +import com.tarkalabs.tarkaui.icons.TarkaIcons import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized @@ -27,10 +29,10 @@ open class TUIBadgeScreenShotTest( } @Test fun test_badge_with_count() = compareScreenshotFor(darkTheme, "_testBadgeWithCount_$testName") { - TUIBadge(count = 2, badgeSize = M) + TUIBadge(style = BadgeStyle.Count(2), badgeSize = M) } - @Test fun test_badge_with_out_count() = compareScreenshotFor(darkTheme, "_testBadgeWithoutCount_$testName") { - TUIBadge(badgeSize = S) + @Test fun test_badge_with_icon() = compareScreenshotFor(darkTheme, "_testBadgeWithIcon_$testName") { + TUIBadge(style = BadgeStyle.Icon(TarkaIcons.Regular.Info20), badgeSize = M) } } \ No newline at end of file diff --git a/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/base/TUIBadge.kt b/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/base/TUIBadge.kt index 220cec76..e7fbe34b 100644 --- a/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/base/TUIBadge.kt +++ b/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/base/TUIBadge.kt @@ -90,6 +90,7 @@ sealed class BadgeStyle { is BadgeStyle.Icon -> { Icon( modifier = Modifier + .testTag(tags.iconTag) .defaultMinSize(minHeight = 10.dp, minWidth = 10.dp) .wrapContentSize(), painter = painterResource(id = style.icon.iconRes), @@ -102,6 +103,7 @@ sealed class BadgeStyle { data class TUIBadgeTags( val parentTag: String = "TUIBadge", + val iconTag: String = "BadgeIcon", ) @Preview(showBackground = true) @Composable fun BadgePreview() {