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

Verified Commit 88ba29f5 authored by Fahim M. Choudhury's avatar Fahim M. Choudhury
Browse files

refactor: rename AppInstallDevicePreconditions to DevicePreconditions

parent 523ad797
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ class AppInstallPreEnqueueChecker @Inject constructor(
    private val appInstallDownloadUrlRefresher: AppInstallDownloadUrlRefresher,
    private val appManagerWrapper: AppManagerWrapper,
    private val ageLimitGate: AgeLimitGate,
    private val appInstallDevicePreconditions: AppInstallDevicePreconditions,
    private val devicePreconditions: DevicePreconditions,
) {
    suspend fun canEnqueue(appInstall: AppInstall, isAnUpdate: Boolean = false): Boolean {
        val hasUpdatedDownloadUrls = appInstall.type == Type.PWA ||
@@ -37,7 +37,7 @@ class AppInstallPreEnqueueChecker @Inject constructor(
        val isDownloadAdded = hasUpdatedDownloadUrls && addDownload(appInstall)
        val isAgeLimitAllowed = isDownloadAdded && ageLimitGate.allow(appInstall)

        return isAgeLimitAllowed && appInstallDevicePreconditions.canProceed(appInstall)
        return isAgeLimitAllowed && devicePreconditions.canProceed(appInstall)
    }

    private suspend fun addDownload(appInstall: AppInstall): Boolean {
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ import foundation.e.apps.data.install.wrapper.StorageSpaceChecker
import timber.log.Timber
import javax.inject.Inject

class AppInstallDevicePreconditions @Inject constructor(
class DevicePreconditions @Inject constructor(
    private val appManagerWrapper: AppManagerWrapper,
    private val appEventDispatcher: AppEventDispatcher,
    private val storageNotificationManager: StorageNotificationManager,
+9 −9
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ import foundation.e.apps.data.enums.Type
import foundation.e.apps.data.install.AppManagerWrapper
import foundation.e.apps.data.install.models.AppInstall
import foundation.e.apps.data.install.core.helper.AgeLimitGate
import foundation.e.apps.data.install.core.helper.AppInstallDevicePreconditions
import foundation.e.apps.data.install.core.helper.DevicePreconditions
import foundation.e.apps.data.install.core.helper.AppInstallDownloadUrlRefresher
import foundation.e.apps.data.install.core.helper.AppInstallPreEnqueueChecker
import foundation.e.apps.domain.model.install.Status
@@ -42,7 +42,7 @@ class AppInstallPreEnqueueCheckerTest {
    private lateinit var appInstallDownloadUrlRefresher: AppInstallDownloadUrlRefresher
    private lateinit var appManagerWrapper: AppManagerWrapper
    private lateinit var ageLimitGate: AgeLimitGate
    private lateinit var appInstallDevicePreconditions: AppInstallDevicePreconditions
    private lateinit var devicePreconditions: DevicePreconditions
    private lateinit var checker: AppInstallPreEnqueueChecker

    @Before
@@ -50,12 +50,12 @@ class AppInstallPreEnqueueCheckerTest {
        appInstallDownloadUrlRefresher = mockk(relaxed = true)
        appManagerWrapper = mockk(relaxed = true)
        ageLimitGate = mockk(relaxed = true)
        appInstallDevicePreconditions = mockk(relaxed = true)
        devicePreconditions = mockk(relaxed = true)
        checker = AppInstallPreEnqueueChecker(
            appInstallDownloadUrlRefresher,
            appManagerWrapper,
            ageLimitGate,
            appInstallDevicePreconditions
            devicePreconditions
        )
    }

@@ -64,7 +64,7 @@ class AppInstallPreEnqueueCheckerTest {
        val appInstall = createPwaInstall()
        coEvery { appManagerWrapper.addDownload(appInstall) } returns true
        coEvery { ageLimitGate.allow(appInstall) } returns true
        coEvery { appInstallDevicePreconditions.canProceed(appInstall) } returns true
        coEvery { devicePreconditions.canProceed(appInstall) } returns true

        val result = checker.canEnqueue(appInstall)

@@ -84,7 +84,7 @@ class AppInstallPreEnqueueCheckerTest {
        assertFalse(result)
        coVerify(exactly = 0) { appManagerWrapper.addDownload(any()) }
        coVerify(exactly = 0) { ageLimitGate.allow(any()) }
        coVerify(exactly = 0) { appInstallDevicePreconditions.canProceed(any()) }
        coVerify(exactly = 0) { devicePreconditions.canProceed(any()) }
    }

    @Test
@@ -97,7 +97,7 @@ class AppInstallPreEnqueueCheckerTest {

        assertFalse(result)
        coVerify(exactly = 0) { ageLimitGate.allow(any()) }
        coVerify(exactly = 0) { appInstallDevicePreconditions.canProceed(any()) }
        coVerify(exactly = 0) { devicePreconditions.canProceed(any()) }
    }

    @Test
@@ -110,7 +110,7 @@ class AppInstallPreEnqueueCheckerTest {
        val result = checker.canEnqueue(appInstall)

        assertFalse(result)
        coVerify(exactly = 0) { appInstallDevicePreconditions.canProceed(any()) }
        coVerify(exactly = 0) { devicePreconditions.canProceed(any()) }
    }

    @Test
@@ -119,7 +119,7 @@ class AppInstallPreEnqueueCheckerTest {
        coEvery { appInstallDownloadUrlRefresher.updateDownloadUrls(appInstall, false) } returns true
        coEvery { appManagerWrapper.addDownload(appInstall) } returns true
        coEvery { ageLimitGate.allow(appInstall) } returns true
        coEvery { appInstallDevicePreconditions.canProceed(appInstall) } returns true
        coEvery { devicePreconditions.canProceed(appInstall) } returns true

        val result = checker.canEnqueue(appInstall)

+3 −3
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ import foundation.e.apps.data.install.AppManagerWrapper
import foundation.e.apps.data.install.models.AppInstall
import foundation.e.apps.data.install.notification.StorageNotificationManager
import foundation.e.apps.data.install.core.helper.AgeLimitGate
import foundation.e.apps.data.install.core.helper.AppInstallDevicePreconditions
import foundation.e.apps.data.install.core.helper.DevicePreconditions
import foundation.e.apps.data.install.core.helper.AppInstallDownloadUrlRefresher
import foundation.e.apps.data.install.core.helper.AppInstallPreEnqueueChecker
import foundation.e.apps.data.install.core.helper.AppInstallStartCoordinator
@@ -73,7 +73,7 @@ class AppInstallStartCoordinatorTest {
    private lateinit var storageSpaceChecker: StorageSpaceChecker
    private lateinit var networkStatusChecker: NetworkStatusChecker
    private lateinit var appManager: AppManager
    private lateinit var devicePreconditions: AppInstallDevicePreconditions
    private lateinit var devicePreconditions: DevicePreconditions
    private lateinit var downloadUrlRefresher: AppInstallDownloadUrlRefresher
    private lateinit var preflightChecker: AppInstallPreEnqueueChecker
    private lateinit var coordinator: AppInstallStartCoordinator
@@ -101,7 +101,7 @@ class AppInstallStartCoordinatorTest {
            appEventDispatcher,
            appManager
        )
        devicePreconditions = AppInstallDevicePreconditions(
        devicePreconditions = DevicePreconditions(
            appManagerWrapper,
            appEventDispatcher,
            storageNotificationManager,
+4 −4
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ import foundation.e.apps.data.event.AppEvent
import foundation.e.apps.data.install.AppManagerWrapper
import foundation.e.apps.data.install.models.AppInstall
import foundation.e.apps.data.install.notification.StorageNotificationManager
import foundation.e.apps.data.install.core.helper.AppInstallDevicePreconditions
import foundation.e.apps.data.install.core.helper.DevicePreconditions
import foundation.e.apps.data.install.wrapper.NetworkStatusChecker
import foundation.e.apps.data.install.wrapper.StorageSpaceChecker
import foundation.e.apps.domain.model.install.Status
@@ -39,13 +39,13 @@ import org.junit.Before
import org.junit.Test

@OptIn(ExperimentalCoroutinesApi::class)
class AppInstallDevicePreconditionsTest {
class DevicePreconditionsTest {
    private lateinit var appManagerWrapper: AppManagerWrapper
    private lateinit var appEventDispatcher: FakeAppEventDispatcher
    private lateinit var storageNotificationManager: StorageNotificationManager
    private lateinit var storageSpaceChecker: StorageSpaceChecker
    private lateinit var networkStatusChecker: NetworkStatusChecker
    private lateinit var preconditions: AppInstallDevicePreconditions
    private lateinit var preconditions: DevicePreconditions

    @Before
    fun setup() {
@@ -54,7 +54,7 @@ class AppInstallDevicePreconditionsTest {
        storageNotificationManager = mockk(relaxed = true)
        storageSpaceChecker = mockk(relaxed = true)
        networkStatusChecker = mockk(relaxed = true)
        preconditions = AppInstallDevicePreconditions(
        preconditions = DevicePreconditions(
            appManagerWrapper,
            appEventDispatcher,
            storageNotificationManager,