From 7f6b996085b973ff777501c2aa2d847ae0d59d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Moczkowski?= Date: Thu, 29 Jun 2023 15:14:10 +0200 Subject: [PATCH] Add test Change-Id: I908084076ea353fa343f10c40e1ce21944f293e1 --- .../apps/nowinandroid/ui/NavigationUiTest.kt | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NavigationUiTest.kt b/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NavigationUiTest.kt index b52aa2aba..26502e820 100644 --- a/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NavigationUiTest.kt +++ b/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NavigationUiTest.kt @@ -149,6 +149,27 @@ class NavigationUiTest { composeTestRule.onNodeWithTag("adaptiveScaffold:permanentDrawer").assertDoesNotExist() } + @Test + fun extraLargeWidth_compactHeight_showsPermanentDrawer() { + composeTestRule.setContent { + TestHarness(size = DpSize(1300.dp, 400.dp)) { + BoxWithConstraints { + NiaApp( + windowSizeClass = WindowSizeClass.calculateFromSize( + DpSize(maxWidth, maxHeight), + ), + networkMonitor = networkMonitor, + userNewsResourceRepository = userNewsResourceRepository, + ) + } + } + } + + composeTestRule.onNodeWithTag("adaptiveScaffold:navigationRail").assertDoesNotExist() + composeTestRule.onNodeWithTag("adaptiveScaffold:navigationBar").assertDoesNotExist() + composeTestRule.onNodeWithTag("adaptiveScaffold:permanentDrawer").assertIsDisplayed() + } + @Test fun compactWidth_mediumHeight_showsNavigationBar() { composeTestRule.setContent { @@ -212,6 +233,27 @@ class NavigationUiTest { composeTestRule.onNodeWithTag("adaptiveScaffold:permanentDrawer").assertDoesNotExist() } + @Test + fun extraLargeWidth_mediumHeight_showsPermanentDrawer() { + composeTestRule.setContent { + TestHarness(size = DpSize(1300.dp, 500.dp)) { + BoxWithConstraints { + NiaApp( + windowSizeClass = WindowSizeClass.calculateFromSize( + DpSize(maxWidth, maxHeight), + ), + networkMonitor = networkMonitor, + userNewsResourceRepository = userNewsResourceRepository, + ) + } + } + } + + composeTestRule.onNodeWithTag("adaptiveScaffold:navigationRail").assertDoesNotExist() + composeTestRule.onNodeWithTag("adaptiveScaffold:navigationBar").assertDoesNotExist() + composeTestRule.onNodeWithTag("adaptiveScaffold:permanentDrawer").assertIsDisplayed() + } + @Test fun compactWidth_expandedHeight_showsNavigationBar() { composeTestRule.setContent { @@ -274,4 +316,25 @@ class NavigationUiTest { composeTestRule.onNodeWithTag("adaptiveScaffold:navigationBar").assertDoesNotExist() composeTestRule.onNodeWithTag("adaptiveScaffold:permanentDrawer").assertDoesNotExist() } + + @Test + fun extraLargeWidth_expandedHeight_showsPermanentDrawer() { + composeTestRule.setContent { + TestHarness(size = DpSize(1300.dp, 900.dp)) { + BoxWithConstraints { + NiaApp( + windowSizeClass = WindowSizeClass.calculateFromSize( + DpSize(maxWidth, maxHeight), + ), + networkMonitor = networkMonitor, + userNewsResourceRepository = userNewsResourceRepository, + ) + } + } + } + + composeTestRule.onNodeWithTag("adaptiveScaffold:navigationRail").assertDoesNotExist() + composeTestRule.onNodeWithTag("adaptiveScaffold:navigationBar").assertDoesNotExist() + composeTestRule.onNodeWithTag("adaptiveScaffold:permanentDrawer").assertIsDisplayed() + } }