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

Verified Commit 523ad797 authored by Fahim M. Choudhury's avatar Fahim M. Choudhury
Browse files

refactor: rename AppInstallAgeLimitGate to AgeLimitGate

parent b3a68599
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import foundation.e.apps.domain.model.ContentRatingValidity
import kotlinx.coroutines.CompletableDeferred
import javax.inject.Inject

class AppInstallAgeLimitGate @Inject constructor(
class AgeLimitGate @Inject constructor(
    private val validateAppAgeLimitUseCase: ValidateAppAgeLimitUseCase,
    private val appManagerWrapper: AppManagerWrapper,
    private val appEventDispatcher: AppEventDispatcher,
+2 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ import javax.inject.Inject
class AppInstallPreEnqueueChecker @Inject constructor(
    private val appInstallDownloadUrlRefresher: AppInstallDownloadUrlRefresher,
    private val appManagerWrapper: AppManagerWrapper,
    private val appInstallAgeLimitGate: AppInstallAgeLimitGate,
    private val ageLimitGate: AgeLimitGate,
    private val appInstallDevicePreconditions: AppInstallDevicePreconditions,
) {
    suspend fun canEnqueue(appInstall: AppInstall, isAnUpdate: Boolean = false): Boolean {
@@ -35,7 +35,7 @@ class AppInstallPreEnqueueChecker @Inject constructor(
            appInstallDownloadUrlRefresher.updateDownloadUrls(appInstall, isAnUpdate)

        val isDownloadAdded = hasUpdatedDownloadUrls && addDownload(appInstall)
        val isAgeLimitAllowed = isDownloadAdded && appInstallAgeLimitGate.allow(appInstall)
        val isAgeLimitAllowed = isDownloadAdded && ageLimitGate.allow(appInstall)

        return isAgeLimitAllowed && appInstallDevicePreconditions.canProceed(appInstall)
    }
+4 −4
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import foundation.e.apps.data.enums.ResultStatus
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.core.helper.AppInstallAgeLimitGate
import foundation.e.apps.data.install.core.helper.AgeLimitGate
import foundation.e.apps.data.install.wrapper.ParentalControlAuthGateway
import foundation.e.apps.domain.ValidateAppAgeLimitUseCase
import foundation.e.apps.domain.model.ContentRatingValidity
@@ -41,12 +41,12 @@ import org.junit.Test
import org.mockito.Mockito

@OptIn(ExperimentalCoroutinesApi::class)
class AppInstallAgeLimitGateTest {
class AgeLimitGateTest {
    private lateinit var validateAppAgeLimitUseCase: ValidateAppAgeLimitUseCase
    private lateinit var appManagerWrapper: AppManagerWrapper
    private lateinit var parentalControlAuthGateway: ParentalControlAuthGateway
    private lateinit var appEventDispatcher: FakeAppEventDispatcher
    private lateinit var gate: AppInstallAgeLimitGate
    private lateinit var gate: AgeLimitGate

    @Before
    fun setup() {
@@ -54,7 +54,7 @@ class AppInstallAgeLimitGateTest {
        appManagerWrapper = mockk(relaxed = true)
        parentalControlAuthGateway = mockk(relaxed = true)
        appEventDispatcher = FakeAppEventDispatcher(autoCompleteDeferred = true)
        gate = AppInstallAgeLimitGate(
        gate = AgeLimitGate(
            validateAppAgeLimitUseCase,
            appManagerWrapper,
            appEventDispatcher,
+9 −9
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import foundation.e.apps.data.enums.Source
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.AppInstallAgeLimitGate
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.AppInstallDownloadUrlRefresher
import foundation.e.apps.data.install.core.helper.AppInstallPreEnqueueChecker
@@ -41,7 +41,7 @@ import org.junit.Test
class AppInstallPreEnqueueCheckerTest {
    private lateinit var appInstallDownloadUrlRefresher: AppInstallDownloadUrlRefresher
    private lateinit var appManagerWrapper: AppManagerWrapper
    private lateinit var appInstallAgeLimitGate: AppInstallAgeLimitGate
    private lateinit var ageLimitGate: AgeLimitGate
    private lateinit var appInstallDevicePreconditions: AppInstallDevicePreconditions
    private lateinit var checker: AppInstallPreEnqueueChecker

@@ -49,12 +49,12 @@ class AppInstallPreEnqueueCheckerTest {
    fun setup() {
        appInstallDownloadUrlRefresher = mockk(relaxed = true)
        appManagerWrapper = mockk(relaxed = true)
        appInstallAgeLimitGate = mockk(relaxed = true)
        ageLimitGate = mockk(relaxed = true)
        appInstallDevicePreconditions = mockk(relaxed = true)
        checker = AppInstallPreEnqueueChecker(
            appInstallDownloadUrlRefresher,
            appManagerWrapper,
            appInstallAgeLimitGate,
            ageLimitGate,
            appInstallDevicePreconditions
        )
    }
@@ -63,7 +63,7 @@ class AppInstallPreEnqueueCheckerTest {
    fun canEnqueue_skipsDownloadUrlRefreshForPwaInstalls() = runTest {
        val appInstall = createPwaInstall()
        coEvery { appManagerWrapper.addDownload(appInstall) } returns true
        coEvery { appInstallAgeLimitGate.allow(appInstall) } returns true
        coEvery { ageLimitGate.allow(appInstall) } returns true
        coEvery { appInstallDevicePreconditions.canProceed(appInstall) } returns true

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

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

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

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

@@ -105,7 +105,7 @@ class AppInstallPreEnqueueCheckerTest {
        val appInstall = createNativeInstall()
        coEvery { appInstallDownloadUrlRefresher.updateDownloadUrls(appInstall, false) } returns true
        coEvery { appManagerWrapper.addDownload(appInstall) } returns true
        coEvery { appInstallAgeLimitGate.allow(appInstall) } returns false
        coEvery { ageLimitGate.allow(appInstall) } returns false

        val result = checker.canEnqueue(appInstall)

@@ -118,7 +118,7 @@ class AppInstallPreEnqueueCheckerTest {
        val appInstall = createNativeInstall()
        coEvery { appInstallDownloadUrlRefresher.updateDownloadUrls(appInstall, false) } returns true
        coEvery { appManagerWrapper.addDownload(appInstall) } returns true
        coEvery { appInstallAgeLimitGate.allow(appInstall) } returns true
        coEvery { ageLimitGate.allow(appInstall) } returns true
        coEvery { appInstallDevicePreconditions.canProceed(appInstall) } returns true

        val result = checker.canEnqueue(appInstall)
+9 −9
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ import foundation.e.apps.data.install.AppInstallRepository
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.AppInstallAgeLimitGate
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.AppInstallDownloadUrlRefresher
import foundation.e.apps.data.install.core.helper.AppInstallPreEnqueueChecker
@@ -68,7 +68,7 @@ class AppInstallStartCoordinatorTest {
    private lateinit var sessionRepository: SessionRepository
    private lateinit var playStoreAuthStore: PlayStoreAuthStore
    private lateinit var storageNotificationManager: StorageNotificationManager
    private lateinit var appInstallAgeLimitGate: AppInstallAgeLimitGate
    private lateinit var ageLimitGate: AgeLimitGate
    private lateinit var appEventDispatcher: FakeAppEventDispatcher
    private lateinit var storageSpaceChecker: StorageSpaceChecker
    private lateinit var networkStatusChecker: NetworkStatusChecker
@@ -87,7 +87,7 @@ class AppInstallStartCoordinatorTest {
        sessionRepository = mockk(relaxed = true)
        playStoreAuthStore = mockk(relaxed = true)
        storageNotificationManager = mockk(relaxed = true)
        appInstallAgeLimitGate = mockk(relaxed = true)
        ageLimitGate = mockk(relaxed = true)
        appEventDispatcher = FakeAppEventDispatcher()
        storageSpaceChecker = mockk(relaxed = true)
        networkStatusChecker = mockk(relaxed = true)
@@ -111,7 +111,7 @@ class AppInstallStartCoordinatorTest {
        preflightChecker = AppInstallPreEnqueueChecker(
            downloadUrlRefresher,
            appManagerWrapper,
            appInstallAgeLimitGate,
            ageLimitGate,
            devicePreconditions
        )
        coordinator = AppInstallStartCoordinator(
@@ -129,7 +129,7 @@ class AppInstallStartCoordinatorTest {
        val appInstall = createPwaInstall()

        coEvery { appManagerWrapper.addDownload(appInstall) } returns true
        coEvery { appInstallAgeLimitGate.allow(appInstall) } returns true
        coEvery { ageLimitGate.allow(appInstall) } returns true
        every { networkStatusChecker.isNetworkAvailable() } returns true
        every { storageSpaceChecker.spaceMissing(appInstall) } returns 0L

@@ -143,7 +143,7 @@ class AppInstallStartCoordinatorTest {
        val appInstall = createPwaInstall()

        coEvery { appManagerWrapper.addDownload(appInstall) } returns true
        coEvery { appInstallAgeLimitGate.allow(appInstall) } returns true
        coEvery { ageLimitGate.allow(appInstall) } returns true
        every { networkStatusChecker.isNetworkAvailable() } returns false
        every { storageSpaceChecker.spaceMissing(appInstall) } returns 0L

@@ -158,7 +158,7 @@ class AppInstallStartCoordinatorTest {
        val appInstall = createPwaInstall()

        coEvery { appManagerWrapper.addDownload(appInstall) } returns true
        coEvery { appInstallAgeLimitGate.allow(appInstall) } returns true
        coEvery { ageLimitGate.allow(appInstall) } returns true
        every { networkStatusChecker.isNetworkAvailable() } returns true
        every { storageSpaceChecker.spaceMissing(appInstall) } returns 100L

@@ -178,7 +178,7 @@ class AppInstallStartCoordinatorTest {
        val result = coordinator.canEnqueue(appInstall)

        assertFalse(result)
        coVerify(exactly = 0) { appInstallAgeLimitGate.allow(any()) }
        coVerify(exactly = 0) { ageLimitGate.allow(any()) }
    }

    @Test
@@ -192,7 +192,7 @@ class AppInstallStartCoordinatorTest {
                playStoreAuthStore.awaitAuthData()
            } returns AuthData(email = "anon@example.com", isAnonymous = true)
            coEvery { appManagerWrapper.addDownload(appInstall) } returns true
            coEvery { appInstallAgeLimitGate.allow(appInstall) } returns true
            coEvery { ageLimitGate.allow(appInstall) } returns true
            every { networkStatusChecker.isNetworkAvailable() } returns true
            every { storageSpaceChecker.spaceMissing(appInstall) } returns 0L
            justRun { InstallWorkManager.enqueueWork(any(), any(), any()) }