From 095cb8d3a17e27596a9e22e84fabd1bdc664ba76 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Thu, 25 Feb 2021 19:54:43 +0530 Subject: [PATCH] Remove BottomNavigationLayoutTest Boss man Jim Sproch recommends we use screenshot testing rather than asserting on nodes since they can change under us at any time as more optimisations come into play. Signed-off-by: Harsh Shandilya --- .../lobsters/BottomNavigationLayoutTest.kt | 108 ------------------ 1 file changed, 108 deletions(-) delete mode 100644 app/src/androidTest/java/dev/msfjarvis/lobsters/BottomNavigationLayoutTest.kt diff --git a/app/src/androidTest/java/dev/msfjarvis/lobsters/BottomNavigationLayoutTest.kt b/app/src/androidTest/java/dev/msfjarvis/lobsters/BottomNavigationLayoutTest.kt deleted file mode 100644 index e0c61417..00000000 --- a/app/src/androidTest/java/dev/msfjarvis/lobsters/BottomNavigationLayoutTest.kt +++ /dev/null @@ -1,108 +0,0 @@ -package dev.msfjarvis.lobsters - -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.test.assertContentDescriptionEquals -import androidx.compose.ui.test.assertCountEquals -import androidx.compose.ui.test.assertHasClickAction -import androidx.compose.ui.test.assertIsDisplayed -import androidx.compose.ui.test.assertIsNotSelected -import androidx.compose.ui.test.assertIsSelected -import androidx.compose.ui.test.assertTextEquals -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.compose.ui.test.onChildAt -import androidx.compose.ui.test.onChildren -import androidx.compose.ui.test.onNodeWithTag -import androidx.compose.ui.test.performClick -import dev.msfjarvis.lobsters.ui.main.LobstersBottomNav -import dev.msfjarvis.lobsters.ui.navigation.Destination -import dev.msfjarvis.lobsters.ui.theme.LobstersTheme -import org.junit.Before -import org.junit.Rule -import org.junit.Test - - -class BottomNavigationLayoutTest { - - @get:Rule - val composeTestRule = createComposeRule() - - @Before - fun setUp() { - composeTestRule.setContent { - LobstersTheme { - var mutableDestination by remember { mutableStateOf(Destination.startDestination) } - - LobstersBottomNav( - currentDestination = mutableDestination, - navigateToDestination = { mutableDestination = it }, - jumpToIndex = {} - ) - } - } - } - - @Test - fun bottomNavItemCountTest() { - // Test to make sure total items are equal to enum objects present in Destination - composeTestRule.onNodeWithTag("LobstersBottomNav") - .assertIsDisplayed() - .onChildren() - .assertCountEquals(Destination.values().size) - } - - @Test - fun bottomNavItemTest() { - // Check hottest BottomNavItem is rendered correctly - composeTestRule.onNodeWithTag("LobstersBottomNav") - .assertIsDisplayed() - .onChildAt(0) - .assertTextEquals("Hottest") - .assertContentDescriptionEquals("Hottest") - .assertHasClickAction() - - // Check saved BottomNavItem is rendered correctly - composeTestRule.onNodeWithTag("LobstersBottomNav") - .assertIsDisplayed() - .onChildAt(1) - .assertTextEquals("Saved") - .assertContentDescriptionEquals("Saved") - .assertHasClickAction() - } - - @Test - fun bottomNavItemSelectedTest() { - // Check hottest BottomNav item is selected - composeTestRule.onNodeWithTag("LobstersBottomNav") - .assertIsDisplayed() - .onChildAt(0) - .assertIsSelected() - .assertTextEquals("Hottest") - - // Check saved BottomNav item is not selected - composeTestRule.onNodeWithTag("LobstersBottomNav") - .assertIsDisplayed() - .onChildAt(1) - .assertIsNotSelected() - - // Select the saved BottomNav item - composeTestRule.onNodeWithTag("LobstersBottomNav") - .onChildAt(1) - .performClick() - - // Check hottest BottomNav item is not selected - composeTestRule.onNodeWithTag("LobstersBottomNav") - .assertIsDisplayed() - .onChildAt(0) - .assertIsNotSelected() - - // Check saved BottomNav item is selected - composeTestRule.onNodeWithTag("LobstersBottomNav") - .assertIsDisplayed() - .onChildAt(1) - .assertIsSelected() - .assertTextEquals("Saved") - } -}