StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.
Kotlin iptv-player
test: stub live grouping preference flows
David Nashash998fb2f85e07
diff --git a/data/src/test/java/com/streamvault/data/repository/ChannelRepositoryImplTest.kt b/data/src/test/java/com/streamvault/data/repository/ChannelRepositoryImplTest.ktindex 50adfe5b..d5241d25 100644--- a/data/src/test/java/com/streamvault/data/repository/ChannelRepositoryImplTest.kt+++ b/data/src/test/java/com/streamvault/data/repository/ChannelRepositoryImplTest.kt@@ -13,10 +13,14 @@ import com.streamvault.data.remote.xtream.XtreamStreamUrlResolverimport com.streamvault.domain.manager.ParentalControlManagerimport com.streamvault.domain.model.ChannelNumberingModeimport com.streamvault.domain.model.ContentType+import com.streamvault.domain.model.GroupedChannelLabelMode+import com.streamvault.domain.model.LiveChannelGroupingMode+import com.streamvault.domain.model.LiveVariantPreferenceModeimport kotlinx.coroutines.flow.firstimport kotlinx.coroutines.flow.flowimport kotlinx.coroutines.flow.flowOfimport kotlinx.coroutines.test.runTest+import org.junit.Beforeimport org.junit.Testimport org.mockito.kotlin.anyimport org.mockito.kotlin.eq@@ -34,6 +38,17 @@ class ChannelRepositoryImplTest {private val parentalControlManager: ParentalControlManager = mock()private val xtreamStreamUrlResolver: XtreamStreamUrlResolver = mock()+ @Before+ fun setUpDefaults() {+ whenever(preferencesRepository.parentalControlLevel).thenReturn(flowOf(0))+ whenever(preferencesRepository.liveChannelNumberingMode).thenReturn(flowOf(ChannelNumberingMode.PROVIDER))+ whenever(preferencesRepository.liveChannelGroupingMode).thenReturn(flowOf(LiveChannelGroupingMode.GROUPED))+ whenever(preferencesRepository.groupedChannelLabelMode).thenReturn(flowOf(GroupedChannelLabelMode.HYBRID))+ whenever(preferencesRepository.liveVariantPreferenceMode).thenReturn(flowOf(LiveVariantPreferenceMode.BALANCED))+ whenever(preferencesRepository.liveVariantSelections).thenReturn(flowOf(emptyMap()))+ whenever(preferencesRepository.liveVariantObservations).thenReturn(flowOf(emptyMap()))+ }+@Testfun `getCategories uses grouped counts without loading all channels`() = runTest {whenever(categoryDao.getByProviderAndType(7L, ContentType.LIVE.name)).thenReturn(@@ -52,7 +67,6 @@ class ChannelRepositoryImplTest {)))- whenever(preferencesRepository.parentalControlLevel).thenReturn(flowOf(0))whenever(parentalControlManager.unlockedCategoriesForProvider(7L)).thenReturn(flowOf(emptySet()))val repository = createRepository()@@ -119,7 +133,6 @@ class ChannelRepositoryImplTest {)))- whenever(preferencesRepository.parentalControlLevel).thenReturn(flowOf(0))whenever(parentalControlManager.unlockedCategoriesForProvider(7L)).thenReturn(flowOf(emptySet()))whenever(preferencesRepository.liveChannelNumberingMode).thenReturn(flowOf(ChannelNumberingMode.HIDDEN))@@ -136,7 +149,6 @@ class ChannelRepositoryImplTest {whenever(channelDao.search(eq(7L), any(), any())).thenReturn(flow { throw SQLiteException("malformed MATCH expression") })- whenever(preferencesRepository.parentalControlLevel).thenReturn(flowOf(0))whenever(preferencesRepository.liveChannelNumberingMode).thenReturn(flowOf(ChannelNumberingMode.PROVIDER))whenever(parentalControlManager.unlockedCategoriesForProvider(7L)).thenReturn(flowOf(emptySet()))whenever(favoriteDao.getAllByType(7L, ContentType.LIVE.name)).thenReturn(flowOf(emptyList()))