From 5cf5f61164ca2b1549e88c3dd23ae9cdf3b8c1e3 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Thu, 2 Jan 2025 17:28:29 +0530 Subject: [PATCH] Fixed: ZimManageViewModelTest, NewRecentSearchDaoTest, and SearchViewModelTest, etc, which were failing. --- .../zimManager/ZimManageViewModelTest.kt | 19 +++++- .../res/layout/dialog_navigation_history.xml | 3 +- .../search/viewmodel/SearchViewModelTest.kt | 58 +++++++++++++------ 3 files changed, 59 insertions(+), 21 deletions(-) diff --git a/app/src/test/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModelTest.kt b/app/src/test/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModelTest.kt index b2b1bd54d6..333c6b3156 100644 --- a/app/src/test/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModelTest.kt +++ b/app/src/test/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModelTest.kt @@ -22,6 +22,7 @@ import android.app.Application import android.net.ConnectivityManager import android.net.NetworkCapabilities import android.net.NetworkCapabilities.TRANSPORT_WIFI +import android.os.Build import com.jraska.livedata.test import io.mockk.clearAllMocks import io.mockk.every @@ -139,7 +140,12 @@ class ZimManageViewModelTest { every { newLanguagesDao.languages() } returns languages every { fat32Checker.fileSystemStates } returns fileSystemStates every { connectivityBroadcastReceiver.networkStates } returns networkStates - every { application.registerReceiver(any(), any(), any()) } returns mockk() + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + every { application.registerReceiver(any(), any(), any()) } returns mockk() + } else { + @Suppress("UnspecifiedRegisterReceiverFlag") + every { application.registerReceiver(any(), any()) } returns mockk() + } every { dataSource.booksOnDiskAsListItems() } returns booksOnDiskListItems every { connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork) @@ -167,8 +173,15 @@ class ZimManageViewModelTest { inner class Context { @Test fun `registers broadcastReceiver in init`() { - verify { - application.registerReceiver(connectivityBroadcastReceiver, any(), any()) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + verify { + application.registerReceiver(connectivityBroadcastReceiver, any(), any()) + } + } else { + @Suppress("UnspecifiedRegisterReceiverFlag") + verify { + application.registerReceiver(connectivityBroadcastReceiver, any()) + } } } diff --git a/core/src/main/res/layout/dialog_navigation_history.xml b/core/src/main/res/layout/dialog_navigation_history.xml index c8f65ca302..153001b263 100644 --- a/core/src/main/res/layout/dialog_navigation_history.xml +++ b/core/src/main/res/layout/dialog_navigation_history.xml @@ -1,4 +1,5 @@ -