all tests fixed
This commit is contained in:
parent
31e78856c0
commit
0a55771ece
4 changed files with 13 additions and 10 deletions
|
@ -1,9 +1,6 @@
|
||||||
package be.ugent.sel.studeez.screens.session
|
package be.ugent.sel.studeez.screens.session
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.media.MediaPlayer
|
import android.media.MediaPlayer
|
||||||
import android.media.RingtoneManager
|
|
||||||
import android.net.Uri
|
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
import kotlin.time.Duration.Companion.seconds
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
@ -13,10 +10,8 @@ object InvisibleSessionManager {
|
||||||
private var viewModel: SessionViewModel? = null
|
private var viewModel: SessionViewModel? = null
|
||||||
private lateinit var mediaPlayer: MediaPlayer
|
private lateinit var mediaPlayer: MediaPlayer
|
||||||
|
|
||||||
fun setParameters(viewModel: SessionViewModel, context: Context) {
|
fun setParameters(viewModel: SessionViewModel, mediaPlayer: MediaPlayer) {
|
||||||
val uri: Uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
|
this.mediaPlayer = mediaPlayer
|
||||||
this.mediaPlayer = MediaPlayer.create(context, uri)
|
|
||||||
this.mediaPlayer.isLooping = false
|
|
||||||
this.viewModel = viewModel
|
this.viewModel = viewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package be.ugent.sel.studeez.screens.session
|
package be.ugent.sel.studeez.screens.session
|
||||||
|
|
||||||
|
import android.media.MediaPlayer
|
||||||
|
import android.media.RingtoneManager
|
||||||
|
import android.net.Uri
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
|
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
|
||||||
|
@ -28,8 +31,11 @@ fun SessionRoute(
|
||||||
openAndPopUp: (String, String) -> Unit,
|
openAndPopUp: (String, String) -> Unit,
|
||||||
viewModel: SessionViewModel,
|
viewModel: SessionViewModel,
|
||||||
) {
|
) {
|
||||||
|
val uri: Uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
|
||||||
|
val mediaPlayer = MediaPlayer.create(LocalContext.current, uri)
|
||||||
|
mediaPlayer.isLooping = false
|
||||||
|
|
||||||
InvisibleSessionManager.setParameters(viewModel = viewModel, context = LocalContext.current)
|
InvisibleSessionManager.setParameters(viewModel = viewModel, mediaPlayer = mediaPlayer)
|
||||||
|
|
||||||
val soundPlayer = SoundPlayer(LocalContext.current)
|
val soundPlayer = SoundPlayer(LocalContext.current)
|
||||||
val sessionActions = getSessionActions(viewModel, openAndPopUp)
|
val sessionActions = getSessionActions(viewModel, openAndPopUp)
|
||||||
|
|
|
@ -7,13 +7,14 @@ import org.junit.Test
|
||||||
class FunctionalPomodoroTimerUnitTest : FunctionalTimerUnitTest() {
|
class FunctionalPomodoroTimerUnitTest : FunctionalTimerUnitTest() {
|
||||||
private val breakTime = 10
|
private val breakTime = 10
|
||||||
private val breaks = 2
|
private val breaks = 2
|
||||||
|
private val repeats = 3 // = breaks + 1
|
||||||
override val hours = 0
|
override val hours = 0
|
||||||
override val minutes = 0
|
override val minutes = 0
|
||||||
override val seconds = 10
|
override val seconds = 10
|
||||||
private lateinit var pomodoroTimer: FunctionalPomodoroTimer
|
private lateinit var pomodoroTimer: FunctionalPomodoroTimer
|
||||||
|
|
||||||
override fun setTimer() {
|
override fun setTimer() {
|
||||||
pomodoroTimer = FunctionalPomodoroTimer(time, breakTime, breaks)
|
pomodoroTimer = FunctionalPomodoroTimer(time, breakTime, repeats)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -22,6 +22,7 @@ class InvisibleSessionManagerTest {
|
||||||
private var selectedTimer: SelectedTimer = SelectedTimer()
|
private var selectedTimer: SelectedTimer = SelectedTimer()
|
||||||
private lateinit var viewModel: SessionViewModel
|
private lateinit var viewModel: SessionViewModel
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun InvisibleEndlessTimerTest() = runTest {
|
fun InvisibleEndlessTimerTest() = runTest {
|
||||||
selectedTimer.set(FunctionalEndlessTimer())
|
selectedTimer.set(FunctionalEndlessTimer())
|
||||||
|
@ -45,7 +46,7 @@ class InvisibleSessionManagerTest {
|
||||||
fun InvisiblePomodoroTimerTest() = runTest {
|
fun InvisiblePomodoroTimerTest() = runTest {
|
||||||
val studyTime = 10
|
val studyTime = 10
|
||||||
val breakTime = 5
|
val breakTime = 5
|
||||||
val repeats = 1
|
val repeats = 2
|
||||||
selectedTimer.set(FunctionalPomodoroTimer(studyTime, breakTime, repeats))
|
selectedTimer.set(FunctionalPomodoroTimer(studyTime, breakTime, repeats))
|
||||||
viewModel = SessionViewModel(selectedTimer, SelectedSessionReport(), SelectedTask(), LogServiceImpl())
|
viewModel = SessionViewModel(selectedTimer, SelectedSessionReport(), SelectedTask(), LogServiceImpl())
|
||||||
InvisibleSessionManager.setParameters(viewModel, mock())
|
InvisibleSessionManager.setParameters(viewModel, mock())
|
||||||
|
|
Reference in a new issue