Skip to content

Commit

Permalink
test: add NavigationRailScreenshotTests, NavigationDrawerScreenshotTests
Browse files Browse the repository at this point in the history
  • Loading branch information
azrael8576 committed Oct 8, 2023
1 parent ed0c2fc commit de9a375
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import com.github.takahirom.roborazzi.captureRoboImage
import com.google.accompanist.testharness.TestHarness
import com.wei.amazingtalker.core.designsystem.component.AtNavigationBar
import com.wei.amazingtalker.core.designsystem.component.AtNavigationBarItem
import com.wei.amazingtalker.core.designsystem.component.AtNavigationDrawer
import com.wei.amazingtalker.core.designsystem.component.AtNavigationDrawerItem
import com.wei.amazingtalker.core.designsystem.component.AtNavigationRail
import com.wei.amazingtalker.core.designsystem.component.AtNavigationRailItem
import com.wei.amazingtalker.core.designsystem.icon.AtIcons
import com.wei.amazingtalker.core.designsystem.theme.AtTheme
import com.wei.amazingtalker.core.testing.util.DefaultRoborazziOptions
Expand All @@ -36,16 +40,16 @@ class NavigationScreenshotTests() {
val composeTestRule = createAndroidComposeRule<ComponentActivity>()

@Test
fun navigation_multipleThemes() {
composeTestRule.captureMultiTheme("Navigation") {
fun navigationBar_multipleThemes() {
composeTestRule.captureMultiTheme("NavigationBar") {
Surface {
AtNavigationBarExample()
}
}
}

@Test
fun navigation_hugeFont() {
fun navigationBar_hugeFont() {
composeTestRule.setContent {
CompositionLocalProvider(
LocalInspectionMode provides true,
Expand All @@ -59,8 +63,47 @@ class NavigationScreenshotTests() {
}
composeTestRule.onRoot()
.captureRoboImage(
"src/test/screenshots/Navigation" +
"/Navigation_fontScale2.png",
"src/test/screenshots/NavigationBar" +
"/NavigationBar_fontScale2.png",
roborazziOptions = DefaultRoborazziOptions,
)
}

@Test
fun navigationRail_multipleThemes() {
composeTestRule.captureMultiTheme("NavigationRail") {
Surface {
AtNavigationRailExample()
}
}
}

@Test
fun navigationDrawer_multipleThemes() {
composeTestRule.captureMultiTheme("NavigationDrawer") {
Surface {
AtNavigationDrawerExample()
}
}
}

@Test
fun navigationDrawer_hugeFont() {
composeTestRule.setContent {
CompositionLocalProvider(
LocalInspectionMode provides true,
) {
TestHarness(fontScale = 2f) {
AtTheme {
AtNavigationDrawerExample("Loooooooooooooooong item")
}
}
}
}
composeTestRule.onRoot()
.captureRoboImage(
"src/test/screenshots/NavigationDrawer" +
"/NavigationDrawer_fontScale2.png",
roborazziOptions = DefaultRoborazziOptions,
)
}
Expand Down Expand Up @@ -89,4 +132,53 @@ class NavigationScreenshotTests() {
}
}
}

@Composable
private fun AtNavigationRailExample() {
AtNavigationRail {
(0..2).forEach { index ->
AtNavigationRailItem(
selected = index == 0,
onClick = { },
icon = {
Icon(
imageVector = AtIcons.UpcomingBorder,
contentDescription = "",
)
},
selectedIcon = {
Icon(
imageVector = AtIcons.Upcoming,
contentDescription = "",
)
},
)
}
}
}

@Composable
private fun AtNavigationDrawerExample(label: String = "Item") {
AtNavigationDrawer {
(0..2).forEach { index ->
AtNavigationDrawerItem(
selected = index == 0,
onClick = { },
icon = {
Icon(
imageVector = AtIcons.UpcomingBorder,
contentDescription = "",
)
},
selectedIcon = {
Icon(
imageVector = AtIcons.Upcoming,
contentDescription = "",
)
},
label = { Text(label) },
)
}
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit de9a375

Please sign in to comment.