diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 53a1745..cd54531 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -42,5 +42,6 @@
+
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index bca9a30..6489d31 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -66,6 +66,7 @@ dependencies {
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.compose.material:material:1.2.0'
+
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
// ViewModel
@@ -97,6 +98,9 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
+ // Coroutine testing
+ testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4'
+
// Mocking
testImplementation 'org.mockito.kotlin:mockito-kotlin:3.2.0'
diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/session/SessionScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/session/SessionScreen.kt
index 7b0ad3c..ac2d225 100644
--- a/app/src/main/java/be/ugent/sel/studeez/screens/session/SessionScreen.kt
+++ b/app/src/main/java/be/ugent/sel/studeez/screens/session/SessionScreen.kt
@@ -46,7 +46,6 @@ fun SessionScreen(
val mediaplayer = MediaPlayer.create(context, uri)
mediaplayer.isLooping = false
- // evt mediaplayer meegeven vanaf hier als reserve oplossing
InvisibleSessionManager.setParameters(viewModel = viewModel, mediaplayer = mediaplayer)
Column(
diff --git a/app/src/test/java/be/ugent/sel/studeez/timer_functional/InvisibleSessionManagerTest.kt b/app/src/test/java/be/ugent/sel/studeez/timer_functional/InvisibleSessionManagerTest.kt
new file mode 100644
index 0000000..5649f46
--- /dev/null
+++ b/app/src/test/java/be/ugent/sel/studeez/timer_functional/InvisibleSessionManagerTest.kt
@@ -0,0 +1,83 @@
+package be.ugent.sel.studeez.timer_functional
+
+import android.media.MediaPlayer
+import be.ugent.sel.studeez.data.SelectedTimerState
+import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalEndlessTimer
+import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalPomodoroTimer
+import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
+import be.ugent.sel.studeez.screens.session.InvisibleSessionManager
+import be.ugent.sel.studeez.screens.session.SessionViewModel
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.test.advanceTimeBy
+import kotlinx.coroutines.test.runTest
+import org.junit.Assert
+import org.junit.Test
+import org.mockito.kotlin.mock
+
+@ExperimentalCoroutinesApi
+class InvisibleSessionManagerTest {
+ private var timerState: SelectedTimerState = SelectedTimerState()
+ private lateinit var viewModel: SessionViewModel
+ private val mediaPlayer = mock()
+
+ @Test
+ fun InvisibleEndlessTimerTest() = runTest {
+ timerState.selectedTimer = FunctionalEndlessTimer()
+ viewModel = SessionViewModel(timerState, mock())
+ InvisibleSessionManager.setParameters(viewModel, mediaPlayer)
+
+ val test = launch {
+ InvisibleSessionManager.updateTimer()
+ }
+
+ Assert.assertEquals(viewModel.getTimer().time.time, 0)
+ advanceTimeBy(1_000) // Start tikker
+ advanceTimeBy(10_000_000)
+ Assert.assertEquals(viewModel.getTimer().time.time, 10000)
+
+ test.cancel()
+ return@runTest
+ }
+
+ @Test
+ fun InvisiblePomodoroTimerTest() = runTest {
+ val studyTime = 10
+ val breakTime = 5
+ val repeats = 1
+ timerState.selectedTimer = FunctionalPomodoroTimer(studyTime, breakTime, repeats)
+ viewModel = SessionViewModel(timerState, mock())
+ InvisibleSessionManager.setParameters(viewModel, mediaPlayer)
+
+ val test = launch {
+ InvisibleSessionManager.updateTimer()
+ }
+
+ Assert.assertEquals(viewModel.getTimer().time.time, 10)
+ advanceTimeBy(1_000) // start tikker
+
+ advanceTimeBy(9_000)
+ Assert.assertEquals(viewModel.getTimer().view, FunctionalTimer.StudyState.FOCUS) // Tijdens het focussen
+
+ advanceTimeBy(1_000)
+ Assert.assertEquals(viewModel.getTimer().time.time, 0) // Focussen gedaan
+
+ advanceTimeBy(4_000)
+ Assert.assertEquals(viewModel.getTimer().view, FunctionalTimer.StudyState.BREAK) // Tijdens pauze
+
+ advanceTimeBy(1_000)
+ Assert.assertEquals(viewModel.getTimer().time.time, 0) // Pauze gedaan
+
+ advanceTimeBy(9_000)
+ Assert.assertEquals(viewModel.getTimer().view, FunctionalTimer.StudyState.FOCUS_REMAINING) // Tijdens 2e focus
+
+ advanceTimeBy(1_000)
+ Assert.assertEquals(viewModel.getTimer().time.time, 0) // 2e focus gedaan
+
+ advanceTimeBy(4_000)
+ Assert.assertEquals(viewModel.getTimer().view, FunctionalTimer.StudyState.DONE) // Done
+
+ test.cancel()
+ return@runTest
+ }
+}
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index 3c5031e..edf11ef 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -7,6 +7,8 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+org.gradle.daemon=true
+org.gradle.parallel=true
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects