This commit is contained in:
Rune Dyselinck 2023-05-15 21:53:04 +02:00
parent 74526bc984
commit 860fb5fac1
20 changed files with 1492 additions and 49 deletions

View file

@ -1,6 +1,9 @@
package be.ugent.sel.studeez
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onAllNodesWithContentDescription
import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import be.ugent.sel.studeez.common.composable.drawer.DrawerActions
@ -8,6 +11,7 @@ import be.ugent.sel.studeez.common.composable.feed.FeedUiState
import be.ugent.sel.studeez.common.composable.navbar.NavigationBarActions
import be.ugent.sel.studeez.data.local.models.FeedEntry
import be.ugent.sel.studeez.screens.home.HomeScreen
import org.junit.Assert
import org.junit.Rule
import org.junit.Test
@ -16,20 +20,31 @@ class HomeScreenTest {
val composeTestRule = createComposeRule()
@Test
fun sessionRecapTestt() {
var saveCalled = false
fun homeScreenTest() {
var continueTask = false
composeTestRule.setContent {
HomeScreen(
open = {},
drawerActions = DrawerActions({}, {}, {}, {}, {}),
navigationBarActions = NavigationBarActions({false}, {}, {}, {}, {}, {}, {}, {}),
feedUiState = FeedUiState.Succes(mapOf()),
continueTask = {_, _ -> },
feedUiState = FeedUiState.Succes(mapOf(
"08 May 2023" to listOf(
FeedEntry(
argb_color = 0xFFABD200,
subJectName = "Test Subject",
taskName = "Test Task",
totalStudyTime = 600,
)
)
)),
continueTask = {_, _ -> continueTask = true },
onEmptyFeedHelp = {}
)
}
composeTestRule.waitForIdle()
composeTestRule
.onNodeWithText(
"continue",
@ -38,5 +53,155 @@ class HomeScreenTest {
)
.assertExists()
.performClick()
Assert.assertTrue(continueTask)
}
@Test
fun drawerTest() {
var homebuttontest = false
var timersbuttontest = false
var settingsbuttontest = false
var logoutbuttontest = false
var aboutbuttontest = false
composeTestRule.setContent {
HomeScreen(
open = {},
drawerActions = DrawerActions(
{homebuttontest = true},
{timersbuttontest = true},
{settingsbuttontest = true},
{logoutbuttontest = true},
{aboutbuttontest = true}
),
navigationBarActions = NavigationBarActions({false}, {}, {}, {}, {}, {}, {}, {}),
feedUiState = FeedUiState.Succes(mapOf()),
continueTask = {_, _ -> },
onEmptyFeedHelp = {}
)
}
composeTestRule.waitForIdle()
composeTestRule
.onAllNodesWithText(
"home",
substring = true,
ignoreCase = true
)[2] // Third node has the button
.assertExists()
.performClick()
composeTestRule
.onNodeWithText(
"timer",
substring = true,
ignoreCase = true
)
.assertExists()
.performClick()
composeTestRule
.onNodeWithText(
"settings",
substring = true,
ignoreCase = true
)
.assertExists()
.performClick()
composeTestRule
.onNodeWithText(
"log out",
substring = true,
ignoreCase = true
)
.assertExists()
.performClick()
composeTestRule
.onNodeWithText(
"about",
substring = true,
ignoreCase = true
)
.assertExists()
.performClick()
Assert.assertTrue(homebuttontest)
Assert.assertTrue(timersbuttontest)
Assert.assertTrue(settingsbuttontest)
Assert.assertTrue(logoutbuttontest)
Assert.assertTrue(aboutbuttontest)
}
@Test
fun navigationbarTest() {
var hometest = false
var tasktest = false
var sessiontest = false
var profiletest = false
composeTestRule.setContent {
HomeScreen(
open = {},
drawerActions = DrawerActions({}, {}, {}, {}, {}),
navigationBarActions = NavigationBarActions(
{false},
{hometest = true},
{tasktest = true},
{sessiontest = true},
{profiletest = true},
{}, {}, {}
),
feedUiState = FeedUiState.Succes(mapOf()),
continueTask = {_, _ -> },
onEmptyFeedHelp = {}
)
}
composeTestRule.waitForIdle()
composeTestRule
.onAllNodesWithContentDescription(
"Home",
substring = true,
ignoreCase = true
)[0] // Third node has the button
.assertExists()
.performClick()
composeTestRule
.onNodeWithContentDescription(
"tasks",
substring = true,
ignoreCase = true
)
.assertExists()
.performClick()
composeTestRule
.onNodeWithContentDescription(
"session",
substring = true,
ignoreCase = true
)
.assertExists()
.performClick()
composeTestRule
.onNodeWithContentDescription(
"profile",
substring = true,
ignoreCase = true
)
.assertExists()
.performClick()
Assert.assertTrue(hometest)
Assert.assertTrue(tasktest)
Assert.assertTrue(sessiontest)
Assert.assertTrue(profiletest)
}
}