Skip to content

Commit

Permalink
Fixed failing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
anikiki committed Jan 29, 2025
1 parent 73348ff commit b81b4c0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import com.duckduckgo.app.browser.WebViewErrorResponse.LOADING
import com.duckduckgo.app.browser.WebViewErrorResponse.OMITTED
import com.duckduckgo.app.browser.addtohome.AddToHomeCapabilityDetector
import com.duckduckgo.app.browser.applinks.AppLinksHandler
import com.duckduckgo.app.browser.apppersonality.AppPersonalityFeature
import com.duckduckgo.app.browser.camera.CameraHardwareChecker
import com.duckduckgo.app.browser.certificates.BypassedSSLCertificatesRepository
import com.duckduckgo.app.browser.certificates.remoteconfig.SSLCertificatesFeature
Expand Down Expand Up @@ -502,6 +503,7 @@ class BrowserTabViewModelTest {
private val mockBrokenSitePrompt: BrokenSitePrompt = mock()
private val mockTabStatsBucketing: TabStatsBucketing = mock()
private val mockDuckChatJSHelper: DuckChatJSHelper = mock()
private val fakeAppPersonalityFeature = FakeFeatureToggleFactory.create(AppPersonalityFeature::class.java)

@Before
fun before() = runTest {
Expand Down Expand Up @@ -671,6 +673,7 @@ class BrowserTabViewModelTest {
toggleReports = mockToggleReports,
brokenSitePrompt = mockBrokenSitePrompt,
tabStatsBucketing = mockTabStatsBucketing,
appPersonalityFeature = fakeAppPersonalityFeature,
)

testee.loadData("abc", null, false, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,27 @@ package com.duckduckgo.app.browser.omnibar.animations

import com.airbnb.lottie.LottieAnimationView
import com.duckduckgo.app.browser.R
import com.duckduckgo.app.browser.apppersonality.AppPersonalityFeature
import com.duckduckgo.app.global.model.PrivacyShield.PROTECTED
import com.duckduckgo.app.global.model.PrivacyShield.UNPROTECTED
import com.duckduckgo.app.global.model.PrivacyShield.WARNING
import com.duckduckgo.common.ui.store.AppTheme
import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory
import org.junit.Test
import org.mockito.kotlin.mock
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever

class LottiePrivacyShieldAnimationHelperTest {

private val feature = FakeFeatureToggleFactory.create(AppPersonalityFeature::class.java)

@Test
fun whenLightModeAndPrivacyShieldProtectedThenSetLightShieldAnimation() {
val holder: LottieAnimationView = mock()
val appTheme: AppTheme = mock()
whenever(appTheme.isLightModeEnabled()).thenReturn(true)
val testee = LottiePrivacyShieldAnimationHelper(appTheme)
val testee = LottiePrivacyShieldAnimationHelper(appTheme, feature)

testee.setAnimationView(holder, PROTECTED)

Expand All @@ -46,7 +50,7 @@ class LottiePrivacyShieldAnimationHelperTest {
val holder: LottieAnimationView = mock()
val appTheme: AppTheme = mock()
whenever(appTheme.isLightModeEnabled()).thenReturn(false)
val testee = LottiePrivacyShieldAnimationHelper(appTheme)
val testee = LottiePrivacyShieldAnimationHelper(appTheme, feature)

testee.setAnimationView(holder, PROTECTED)

Expand All @@ -58,7 +62,7 @@ class LottiePrivacyShieldAnimationHelperTest {
val holder: LottieAnimationView = mock()
val appTheme: AppTheme = mock()
whenever(appTheme.isLightModeEnabled()).thenReturn(true)
val testee = LottiePrivacyShieldAnimationHelper(appTheme)
val testee = LottiePrivacyShieldAnimationHelper(appTheme, feature)

testee.setAnimationView(holder, UNPROTECTED)

Expand All @@ -71,7 +75,7 @@ class LottiePrivacyShieldAnimationHelperTest {
val holder: LottieAnimationView = mock()
val appTheme: AppTheme = mock()
whenever(appTheme.isLightModeEnabled()).thenReturn(false)
val testee = LottiePrivacyShieldAnimationHelper(appTheme)
val testee = LottiePrivacyShieldAnimationHelper(appTheme, feature)

testee.setAnimationView(holder, UNPROTECTED)

Expand All @@ -84,7 +88,7 @@ class LottiePrivacyShieldAnimationHelperTest {
val holder: LottieAnimationView = mock()
val appTheme: AppTheme = mock()
whenever(appTheme.isLightModeEnabled()).thenReturn(true)
val testee = LottiePrivacyShieldAnimationHelper(appTheme)
val testee = LottiePrivacyShieldAnimationHelper(appTheme, feature)

testee.setAnimationView(holder, WARNING)

Expand All @@ -97,7 +101,7 @@ class LottiePrivacyShieldAnimationHelperTest {
val holder: LottieAnimationView = mock()
val appTheme: AppTheme = mock()
whenever(appTheme.isLightModeEnabled()).thenReturn(false)
val testee = LottiePrivacyShieldAnimationHelper(appTheme)
val testee = LottiePrivacyShieldAnimationHelper(appTheme, feature)

testee.setAnimationView(holder, WARNING)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.view.MotionEvent
import androidx.test.ext.junit.runners.AndroidJUnit4
import app.cash.turbine.test
import com.duckduckgo.app.browser.DuckDuckGoUrlDetectorImpl
import com.duckduckgo.app.browser.apppersonality.AppPersonalityFeature
import com.duckduckgo.app.browser.omnibar.Omnibar.ViewMode
import com.duckduckgo.app.browser.omnibar.OmnibarLayout.Decoration
import com.duckduckgo.app.browser.omnibar.OmnibarLayout.StateChange
Expand All @@ -27,6 +28,7 @@ import com.duckduckgo.app.trackerdetection.model.Entity
import com.duckduckgo.browser.api.UserBrowserProperties
import com.duckduckgo.common.test.CoroutineTestRule
import com.duckduckgo.duckplayer.api.DuckPlayer
import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory
import com.duckduckgo.privacy.dashboard.impl.pixels.PrivacyDashboardPixels
import com.duckduckgo.voice.api.VoiceSearchAvailability
import com.duckduckgo.voice.api.VoiceSearchAvailabilityPixelLogger
Expand Down Expand Up @@ -57,6 +59,7 @@ class OmnibarLayoutViewModelTest {
private val duckPlayer: DuckPlayer = mock()
private val pixel: Pixel = mock()
private val userBrowserProperties: UserBrowserProperties = mock()
private val fakeAppPersonalityFeature = FakeFeatureToggleFactory.create(AppPersonalityFeature::class.java)

private lateinit var testee: OmnibarLayoutViewModel

Expand All @@ -77,6 +80,7 @@ class OmnibarLayoutViewModelTest {
pixel = pixel,
userBrowserProperties = userBrowserProperties,
dispatcherProvider = coroutineTestRule.testDispatcherProvider,
appPersonalityFeature = fakeAppPersonalityFeature,
)

whenever(tabRepository.flowTabs).thenReturn(flowOf(emptyList()))
Expand Down

0 comments on commit b81b4c0

Please sign in to comment.