Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d745f915 authored by mitulsheth's avatar mitulsheth
Browse files

fix(test): FerrostarWarapper for Race Condition

parent 25521192
Loading
Loading
Loading
Loading
+55 −59
Original line number Diff line number Diff line
@@ -70,8 +70,6 @@ class FerrostarWrapperRepository @Inject constructor(
    }

    fun setValhallaEndpoint(endpoint: String) {
        thread {
            Thread.sleep(30000)
        _walking = FerrostarWrapper(
            context,
            locationRepository,
@@ -129,8 +127,6 @@ class FerrostarWrapperRepository @Inject constructor(

        _isInitialized.value = true

        }

        // Apply pending options
        synchronized(pendingOptions) {
            pendingOptions.forEach { (mode, options) ->
+22 −0
Original line number Diff line number Diff line
/*
 *     Cardinal Maps
 *     Copyright (C) 2025 Cardinal Maps Authors
 *
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package earth.maps.cardinal.ui.directions

import earth.maps.cardinal.MainCoroutineRule
@@ -95,6 +113,8 @@ class DirectionsViewModelTest {
        )
        coEvery { mockRoutingProfileRepository.getProfilesForMode(any()) } returns flowOf(emptyList())

        // Mock FerrostarWrapperRepository
        coEvery { mockFerrostarWrapperRepository.awaitInitialization() } returns Unit
        coEvery { mockFerrostarWrapperRepository.resetOptionsToDefaultsForMode(any()) } returns Unit

        viewModel = DirectionsViewModel(
@@ -253,6 +273,8 @@ class DirectionsViewModelTest {
            address = null
        )

        mockFerrostarWrapperRepository.awaitInitialization()

        // Setup mock to throw an exception
        val mockFerrostarWrapper = mockk<FerrostarWrapper>()
        coEvery { mockFerrostarWrapperRepository.driving } returns mockFerrostarWrapper