Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Razeeman committed Nov 22, 2024
1 parent 01d9d7e commit c807aff
Show file tree
Hide file tree
Showing 5 changed files with 978 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ object Deps {
"junit:junit:${Versions.junit}"
const val mockito =
"org.mockito:mockito-core:${Versions.mockito}"
const val mockitoKotlin =
"org.mockito.kotlin:mockito-kotlin:${Versions.mockitoKotlin}"
const val coroutines =
"org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.coroutinesTest}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ object Versions {
const val junitUi = "1.1.4"
const val espresso = "3.5.0"
const val mockito = "5.14.2"
const val mockitoKotlin = "5.4.0"
const val coroutinesTest = "1.7.1"
}
2 changes: 1 addition & 1 deletion domain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ dependencies {
api(Deps.kotlin)

testImplementation(Deps.Test.junit)
testImplementation(Deps.Test.mockito)
testImplementation(Deps.Test.mockitoKotlin)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.example.util.simpletimetracker.domain.model.RecordDataSelectionDialog
import com.example.util.simpletimetracker.domain.model.RecordType
import com.example.util.simpletimetracker.domain.model.ResultContainer
import com.example.util.simpletimetracker.domain.model.RunningRecord
import com.example.util.simpletimetracker.domain.provider.CurrentTimestampProvider
import java.util.concurrent.TimeUnit
import javax.inject.Inject

Expand All @@ -22,6 +23,7 @@ class AddRunningRecordMediator @Inject constructor(
private val pomodoroStartInteractor: PomodoroStartInteractor,
private val complexRuleProcessActionInteractor: ComplexRuleProcessActionInteractor,
private val updateExternalViewsInteractor: UpdateExternalViewsInteractor,
private val currentTimestampProvider: CurrentTimestampProvider,
) {

/**
Expand Down Expand Up @@ -54,9 +56,6 @@ class AddRunningRecordMediator @Inject constructor(
}
}

// TODO test retroactive mode
// TODO test several prev records at the same time, merge accordingly.
// TODO test retroactive multitask
suspend fun startTimer(
typeId: Long,
tagIds: List<Long>,
Expand All @@ -65,14 +64,17 @@ class AddRunningRecordMediator @Inject constructor(
updateNotificationSwitch: Boolean = true,
checkDefaultDuration: Boolean = true,
) {
val currentTime = System.currentTimeMillis()
val currentTime = currentTimestampProvider.get()
val actualTimeStarted = when (timeStarted) {
is StartTime.Current -> timeStarted.currentTimeStampMs
is StartTime.TakeCurrent -> currentTime
is StartTime.Timestamp -> timeStarted.timestampMs
}
val retroactiveTrackingMode = prefsInteractor.getRetroactiveTrackingMode()
val actualPrevRecords = if (retroactiveTrackingMode) {
val actualPrevRecords = if (
retroactiveTrackingMode ||
complexRuleProcessActionInteractor.hasRules()
) {
recordInteractor.getAllPrev(actualTimeStarted)
} else {
emptyList()
Expand Down
Loading

0 comments on commit c807aff

Please sign in to comment.