Skip to content

Commit

Permalink
fix fdroid build
Browse files Browse the repository at this point in the history
  • Loading branch information
lmac012 committed Aug 28, 2024
1 parent 3473f26 commit 027ec93
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ class BrowserTabViewModelTest {
dispatchers = coroutineRule.testDispatcherProvider,
duckDuckGoUrlDetector = DuckDuckGoUrlDetectorImpl(),
extendedOnboardingFeatureToggles = mockExtendedOnboardingFeatureToggles,
subscriptions = mock(),
)

val siteFactory = SiteFactoryImpl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import com.duckduckgo.app.widget.ui.WidgetCapabilities
import com.duckduckgo.common.test.CoroutineTestRule
import com.duckduckgo.common.test.InstantSchedulersRule
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.subscriptions.api.Subscriptions
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.drop
Expand Down Expand Up @@ -112,6 +113,9 @@ class CtaViewModelTest {
@Mock
private lateinit var mockExtendedOnboardingFeatureToggles: ExtendedOnboardingFeatureToggles

@Mock
private lateinit var mockSubscriptions: Subscriptions

private val requiredDaxOnboardingCtas: List<CtaId> = listOf(
CtaId.DAX_INTRO,
CtaId.DAX_DIALOG_SERP,
Expand Down Expand Up @@ -153,6 +157,7 @@ class CtaViewModelTest {
dispatchers = coroutineRule.testDispatcherProvider,
duckDuckGoUrlDetector = DuckDuckGoUrlDetectorImpl(),
extendedOnboardingFeatureToggles = mockExtendedOnboardingFeatureToggles,
subscriptions = mockSubscriptions,
)
}

Expand Down Expand Up @@ -715,6 +720,7 @@ class CtaViewModelTest {
@Test
fun givenPrivacyProSiteWhenRefreshCtaWhileBrowsingThenReturnNull() = runTest {
val privacyProUrl = "https://duckduckgo.com/pro"
whenever(mockSubscriptions.isPrivacyProUrl(privacyProUrl)).thenReturn(true)
givenDaxOnboardingActive()
val site = site(url = privacyProUrl)

Expand Down
13 changes: 3 additions & 10 deletions app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package com.duckduckgo.app.cta.ui

import androidx.annotation.VisibleForTesting
import androidx.annotation.WorkerThread
import androidx.core.net.toUri
import com.duckduckgo.app.browser.DuckDuckGoUrlDetector
import com.duckduckgo.app.cta.db.DismissedCtaDao
import com.duckduckgo.app.cta.model.CtaId
Expand All @@ -37,10 +36,8 @@ import com.duckduckgo.app.statistics.pixels.Pixel
import com.duckduckgo.app.tabs.model.TabRepository
import com.duckduckgo.app.widget.ui.WidgetCapabilities
import com.duckduckgo.common.utils.DispatcherProvider
import com.duckduckgo.common.utils.extensions.toTldPlusOne
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.subscriptions.impl.SubscriptionsConstants.PRIVACY_PRO_ETLD
import com.duckduckgo.subscriptions.impl.SubscriptionsConstants.PRIVACY_PRO_PATH
import com.duckduckgo.subscriptions.api.Subscriptions
import dagger.SingleInstanceIn
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
Expand All @@ -64,6 +61,7 @@ class CtaViewModel @Inject constructor(
private val dispatchers: DispatcherProvider,
private val duckDuckGoUrlDetector: DuckDuckGoUrlDetector,
private val extendedOnboardingFeatureToggles: ExtendedOnboardingFeatureToggles,
private val subscriptions: Subscriptions,
) {
@ExperimentalCoroutinesApi
@VisibleForTesting
Expand Down Expand Up @@ -291,12 +289,7 @@ class CtaViewModel @Inject constructor(
}

private fun isSiteNotAllowedForOnboarding(url: String?): Boolean {
val uri = url?.toUri() ?: return true
val eTld = uri.host?.toTldPlusOne() ?: return false
val size = uri.pathSegments.size
val path = uri.pathSegments.firstOrNull()
val isPrivacyProSite = eTld == PRIVACY_PRO_ETLD && size == 1 && path == PRIVACY_PRO_PATH
return isPrivacyProSite
return url == null || subscriptions.isPrivacyProUrl(url)
}

private fun daxDialogIntroShown(): Boolean = dismissedCtaDao.exists(CtaId.DAX_INTRO)
Expand Down

0 comments on commit 027ec93

Please sign in to comment.