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
|
||||
|
||||
import android.content.Context
|
||||
import android.media.MediaPlayer
|
||||
import android.media.RingtoneManager
|
||||
import android.net.Uri
|
||||
import kotlinx.coroutines.delay
|
||||
import javax.inject.Singleton
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
@ -13,10 +10,8 @@ object InvisibleSessionManager {
|
|||
private var viewModel: SessionViewModel? = null
|
||||
private lateinit var mediaPlayer: MediaPlayer
|
||||
|
||||
fun setParameters(viewModel: SessionViewModel, context: Context) {
|
||||
val uri: Uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
|
||||
this.mediaPlayer = MediaPlayer.create(context, uri)
|
||||
this.mediaPlayer.isLooping = false
|
||||
fun setParameters(viewModel: SessionViewModel, mediaPlayer: MediaPlayer) {
|
||||
this.mediaPlayer = mediaPlayer
|
||||
this.viewModel = viewModel
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
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.ui.platform.LocalContext
|
||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
|
||||
|
@ -28,8 +31,11 @@ fun SessionRoute(
|
|||
openAndPopUp: (String, String) -> Unit,
|
||||
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 sessionActions = getSessionActions(viewModel, openAndPopUp)
|
||||
|
|
|
@ -7,13 +7,14 @@ import org.junit.Test
|
|||
class FunctionalPomodoroTimerUnitTest : FunctionalTimerUnitTest() {
|
||||
private val breakTime = 10
|
||||
private val breaks = 2
|
||||
private val repeats = 3 // = breaks + 1
|
||||
override val hours = 0
|
||||
override val minutes = 0
|
||||
override val seconds = 10
|
||||
private lateinit var pomodoroTimer: FunctionalPomodoroTimer
|
||||
|
||||
override fun setTimer() {
|
||||
pomodoroTimer = FunctionalPomodoroTimer(time, breakTime, breaks)
|
||||
pomodoroTimer = FunctionalPomodoroTimer(time, breakTime, repeats)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -22,6 +22,7 @@ class InvisibleSessionManagerTest {
|
|||
private var selectedTimer: SelectedTimer = SelectedTimer()
|
||||
private lateinit var viewModel: SessionViewModel
|
||||
|
||||
|
||||
@Test
|
||||
fun InvisibleEndlessTimerTest() = runTest {
|
||||
selectedTimer.set(FunctionalEndlessTimer())
|
||||
|
@ -45,7 +46,7 @@ class InvisibleSessionManagerTest {
|
|||
fun InvisiblePomodoroTimerTest() = runTest {
|
||||
val studyTime = 10
|
||||
val breakTime = 5
|
||||
val repeats = 1
|
||||
val repeats = 2
|
||||
selectedTimer.set(FunctionalPomodoroTimer(studyTime, breakTime, repeats))
|
||||
viewModel = SessionViewModel(selectedTimer, SelectedSessionReport(), SelectedTask(), LogServiceImpl())
|
||||
InvisibleSessionManager.setParameters(viewModel, mock())
|
||||
|
|
Reference in a new issue