@@ -64,21 +64,15 @@ import com.duckduckgo.app.cta.ui.CtaViewModel
6464import com.duckduckgo.app.cta.ui.DaxBubbleCta
6565import com.duckduckgo.app.cta.ui.DaxDialogCta
6666import com.duckduckgo.app.cta.ui.HomePanelCta
67- import com.duckduckgo.app.cta.ui.UseOurAppCta
6867import com.duckduckgo.app.email.EmailManager
6968import com.duckduckgo.app.fire.fireproofwebsite.data.FireproofWebsiteDao
7069import com.duckduckgo.app.fire.fireproofwebsite.data.FireproofWebsiteEntity
7170import com.duckduckgo.app.fire.fireproofwebsite.data.FireproofWebsiteRepository
7271import com.duckduckgo.app.global.db.AppDatabase
73- import com.duckduckgo.app.global.events.db.UserEventEntity
74- import com.duckduckgo.app.global.events.db.UserEventKey
7572import com.duckduckgo.app.global.events.db.UserEventsStore
7673import com.duckduckgo.app.global.install.AppInstallStore
7774import com.duckduckgo.app.global.model.Site
7875import com.duckduckgo.app.global.model.SiteFactory
79- import com.duckduckgo.app.global.useourapp.UseOurAppDetector
80- import com.duckduckgo.app.global.useourapp.UseOurAppDetector.Companion.USE_OUR_APP_DOMAIN
81- import com.duckduckgo.app.global.useourapp.UseOurAppDetector.Companion.USE_OUR_APP_SHORTCUT_URL
8276import com.duckduckgo.app.globalprivacycontrol.GlobalPrivacyControlManager
8377import com.duckduckgo.app.globalprivacycontrol.GlobalPrivacyControlManager.Companion.GPC_HEADER
8478import com.duckduckgo.app.globalprivacycontrol.GlobalPrivacyControlManager.Companion.GPC_HEADER_VALUE
@@ -88,7 +82,6 @@ import com.duckduckgo.app.location.data.LocationPermissionType
8882import com.duckduckgo.app.location.data.LocationPermissionsDao
8983import com.duckduckgo.app.location.data.LocationPermissionsRepository
9084import com.duckduckgo.app.notification.db.NotificationDao
91- import com.duckduckgo.app.notification.model.UseOurAppNotification
9285import com.duckduckgo.app.onboarding.store.AppStage
9386import com.duckduckgo.app.onboarding.store.OnboardingStore
9487import com.duckduckgo.app.onboarding.store.UserStageStore
@@ -317,12 +310,9 @@ class BrowserTabViewModelTest {
317310 mockWidgetCapabilities,
318311 mockDismissedCtaDao,
319312 mockUserWhitelistDao,
320- mockVariantManager,
321313 mockSettingsStore,
322314 mockOnboardingStore,
323315 mockUserStageStore,
324- mockUserEventsStore,
325- UseOurAppDetector (mockUserEventsStore),
326316 mockTabRepository,
327317 coroutineRule.testDispatcherProvider
328318 )
@@ -370,7 +360,6 @@ class BrowserTabViewModelTest {
370360 navigationAwareLoginDetector = mockNavigationAwareLoginDetector,
371361 userEventsStore = mockUserEventsStore,
372362 notificationDao = mockNotificationDao,
373- useOurAppDetector = UseOurAppDetector (mockUserEventsStore),
374363 variantManager = mockVariantManager,
375364 fileDownloader = mockFileDownloader,
376365 globalPrivacyControl = GlobalPrivacyControlManager (mockSettingsStore),
@@ -427,25 +416,14 @@ class BrowserTabViewModelTest {
427416 }
428417
429418 @Test
430- fun whenViewBecomesVisibleAndHomeShowingAndUserIsNotInUseOurAppOnboardingStageThenKeyboardShown () = coroutineRule.runBlocking {
431- whenever(mockUserStageStore.getUserAppStage()).thenReturn(AppStage .ESTABLISHED )
419+ fun whenViewBecomesVisibleAndHomeShowingThenKeyboardShown () = coroutineRule.runBlocking {
432420 setBrowserShowing(false )
433421
434422 testee.onViewVisible()
435423 verify(mockCommandObserver, atLeastOnce()).onChanged(commandCaptor.capture())
436424 assertTrue(commandCaptor.allValues.contains(Command .ShowKeyboard ))
437425 }
438426
439- @Test
440- fun whenViewBecomesVisibleAndHomeShowingAndUserIsInUseOurAppOnboardingStageThenKeyboardHidden () = coroutineRule.runBlocking {
441- whenever(mockUserStageStore.getUserAppStage()).thenReturn(AppStage .USE_OUR_APP_ONBOARDING )
442- setBrowserShowing(false )
443-
444- testee.onViewVisible()
445- verify(mockCommandObserver, atLeastOnce()).onChanged(commandCaptor.capture())
446- assertTrue(commandCaptor.allValues.contains(Command .HideKeyboard ))
447- }
448-
449427 @Test
450428 fun whenViewBecomesVisibleAndHomeCtaPresentThenKeyboardHidden () = coroutineRule.runBlocking {
451429 givenExpectedCtaAddWidgetInstructions()
@@ -1890,16 +1868,6 @@ class BrowserTabViewModelTest {
18901868 assertCommandIssued<Command .LaunchLegacyAddWidget >()
18911869 }
18921870
1893- @Test
1894- fun whenUserClickedUseOurAppCtaOkButtonThenLaunchAddHomeShortcutAndNavigateCommand () {
1895- whenever(mockOmnibarConverter.convertQueryToUrl(USE_OUR_APP_SHORTCUT_URL , null )).thenReturn(USE_OUR_APP_SHORTCUT_URL )
1896- val cta = UseOurAppCta ()
1897- setCta(cta)
1898- testee.onUserClickCtaOkButton()
1899- assertCommandIssued<Command .AddHomeShortcut >()
1900- assertCommandIssued<Navigate >()
1901- }
1902-
19031871 @Test
19041872 fun whenSurveyCtaDismissedAndNoOtherCtaPossibleCtaIsNull () = coroutineRule.runBlocking {
19051873 givenShownCtas(CtaId .DAX_INTRO , CtaId .DAX_END )
@@ -1977,14 +1945,6 @@ class BrowserTabViewModelTest {
19771945 verify(mockSurveyDao).cancelScheduledSurveys()
19781946 }
19791947
1980- @Test
1981- fun whenUserClickedSecondaryCtaButtonInUseOurAppCtaThenLaunchShowKeyboardCommand () {
1982- val cta = UseOurAppCta ()
1983- setCta(cta)
1984- testee.onUserClickCtaSecondaryButton()
1985- assertCommandIssued<Command .ShowKeyboard >()
1986- }
1987-
19881948 @Test
19891949 fun whenSurrogateDetectedThenSiteUpdated () {
19901950 givenOneActiveTabSelected()
@@ -2177,30 +2137,6 @@ class BrowserTabViewModelTest {
21772137 }
21782138 }
21792139
2180- @Test
2181- fun whenLoginDetectedAndUrlIsUseOurAppThenRegisterUserEvent () = coroutineRule.runBlocking {
2182- whenever(mockUserEventsStore.getUserEvent(UserEventKey .USE_OUR_APP_FIREPROOF_DIALOG_SEEN )).thenReturn(null )
2183- loginEventLiveData.value = givenLoginDetected(USE_OUR_APP_SHORTCUT_URL )
2184-
2185- verify(mockUserEventsStore).registerUserEvent(UserEventKey .USE_OUR_APP_FIREPROOF_DIALOG_SEEN )
2186- }
2187-
2188- @Test
2189- fun whenLoginDetectedAndUrlIsNotUseOurAppThenDoNotRegisterUserEvent () = coroutineRule.runBlocking {
2190- whenever(mockUserEventsStore.getUserEvent(UserEventKey .USE_OUR_APP_FIREPROOF_DIALOG_SEEN )).thenReturn(null )
2191- loginEventLiveData.value = givenLoginDetected(" example.com" )
2192-
2193- verify(mockUserEventsStore, never()).registerUserEvent(UserEventKey .USE_OUR_APP_FIREPROOF_DIALOG_SEEN )
2194- }
2195-
2196- @Test
2197- fun whenLoginDetectedAndDialogAlreadySeenThenDoNotRegisterUserEvent () = coroutineRule.runBlocking {
2198- whenever(mockUserEventsStore.getUserEvent(UserEventKey .USE_OUR_APP_FIREPROOF_DIALOG_SEEN )).thenReturn(UserEventEntity (UserEventKey .USE_OUR_APP_FIREPROOF_DIALOG_SEEN ))
2199- loginEventLiveData.value = givenLoginDetected(USE_OUR_APP_SHORTCUT_URL )
2200-
2201- verify(mockUserEventsStore, never()).registerUserEvent(UserEventKey .USE_OUR_APP_FIREPROOF_DIALOG_SEEN )
2202- }
2203-
22042140 @Test
22052141 fun whenUserBrowsingPressesBackThenCannotAddBookmark () {
22062142 setupNavigation(skipHome = false , isBrowsing = true , canGoBack = false )
@@ -2333,163 +2269,6 @@ class BrowserTabViewModelTest {
23332269 testee.onUserSubmittedQuery(" about:blank" )
23342270 }
23352271
2336- @Test
2337- fun whenViewReadyIfDomainSameAsUseOurAppAfterNotificationSeenThenPixelSent () = coroutineRule.runBlocking {
2338- givenUseOurAppSiteSelected()
2339- whenever(mockNotificationDao.exists(UseOurAppNotification .ID )).thenReturn(true )
2340-
2341- testee.onViewReady()
2342-
2343- verify(mockPixel).fire(AppPixelName .UOA_VISITED_AFTER_NOTIFICATION )
2344- }
2345-
2346- @Test
2347- fun whenViewReadyIfDomainSameAsUseOurAppAfterShortcutAddedThenPixelSent () = coroutineRule.runBlocking {
2348- givenUseOurAppSiteSelected()
2349- whenever(mockUserEventsStore.getUserEvent(UserEventKey .USE_OUR_APP_SHORTCUT_ADDED )).thenReturn(UserEventEntity (UserEventKey .USE_OUR_APP_SHORTCUT_ADDED ))
2350-
2351- testee.onViewReady()
2352-
2353- verify(mockPixel).fire(AppPixelName .UOA_VISITED_AFTER_SHORTCUT )
2354- }
2355-
2356- @Test
2357- fun whenViewReadyIfDomainSameAsUseOurAppAfterDeleteCtaShownThenPixelSent () = coroutineRule.runBlocking {
2358- givenUseOurAppSiteSelected()
2359- whenever(mockDismissedCtaDao.exists(CtaId .USE_OUR_APP_DELETION )).thenReturn(true )
2360-
2361- testee.onViewReady()
2362-
2363- verify(mockPixel).fire(AppPixelName .UOA_VISITED_AFTER_DELETE_CTA )
2364- }
2365-
2366- @Test
2367- fun whenViewReadyIfDomainSameAsUseOurAppThenPixelSent () = coroutineRule.runBlocking {
2368- givenUseOurAppSiteSelected()
2369-
2370- testee.onViewReady()
2371-
2372- verify(mockPixel).fire(AppPixelName .UOA_VISITED )
2373- }
2374-
2375- @Test
2376- fun whenViewReadyIfDomainIsNotTheSameAsUseOurAppAfterNotificationSeenThenPixelNotSent () = coroutineRule.runBlocking {
2377- givenUseOurAppSiteIsNotSelected()
2378- whenever(mockNotificationDao.exists(UseOurAppNotification .ID )).thenReturn(true )
2379-
2380- testee.onViewReady()
2381-
2382- verify(mockPixel, never()).fire(AppPixelName .UOA_VISITED_AFTER_NOTIFICATION )
2383- }
2384-
2385- @Test
2386- fun whenViewReadyIfDomainIsNotTheSameAsUseOurAppAfterShortcutAddedThenPixelNotSent () = coroutineRule.runBlocking {
2387- givenUseOurAppSiteIsNotSelected()
2388- whenever(mockUserEventsStore.getUserEvent(UserEventKey .USE_OUR_APP_SHORTCUT_ADDED )).thenReturn(UserEventEntity (UserEventKey .USE_OUR_APP_SHORTCUT_ADDED ))
2389-
2390- testee.onViewReady()
2391-
2392- verify(mockPixel, never()).fire(AppPixelName .UOA_VISITED_AFTER_SHORTCUT )
2393- }
2394-
2395- @Test
2396- fun whenViewReadyIfDomainIsNotTheSameAsUseOurAppAfterDeleteCtaShownThenPixelNotSent () = coroutineRule.runBlocking {
2397- givenUseOurAppSiteIsNotSelected()
2398- whenever(mockDismissedCtaDao.exists(CtaId .USE_OUR_APP_DELETION )).thenReturn(true )
2399-
2400- testee.onViewReady()
2401-
2402- verify(mockPixel, never()).fire(AppPixelName .UOA_VISITED_AFTER_DELETE_CTA )
2403- }
2404-
2405- @Test
2406- fun whenViewReadyIfDomainIsNotTheSameAsUseOurAppAThenPixelNotSent () = coroutineRule.runBlocking {
2407- givenUseOurAppSiteIsNotSelected()
2408-
2409- testee.onViewReady()
2410-
2411- verify(mockPixel, never()).fire(AppPixelName .UOA_VISITED )
2412- }
2413-
2414- @Test
2415- fun whenPageChangedIfPreviousOneWasNotUseOurAppSiteAfterNotificationSeenThenPixelSent () = coroutineRule.runBlocking {
2416- givenUseOurAppSiteIsNotSelected()
2417- whenever(mockNotificationDao.exists(UseOurAppNotification .ID )).thenReturn(true )
2418-
2419- loadUrl(USE_OUR_APP_DOMAIN , isBrowserShowing = true )
2420-
2421- verify(mockPixel).fire(AppPixelName .UOA_VISITED_AFTER_NOTIFICATION )
2422- }
2423-
2424- @Test
2425- fun whenPageChangedIfPreviousOneWasNotUseOurAppSiteAfterShortcutAddedThenPixelSent () = coroutineRule.runBlocking {
2426- givenUseOurAppSiteIsNotSelected()
2427- whenever(mockUserEventsStore.getUserEvent(UserEventKey .USE_OUR_APP_SHORTCUT_ADDED )).thenReturn(UserEventEntity (UserEventKey .USE_OUR_APP_SHORTCUT_ADDED ))
2428-
2429- loadUrl(USE_OUR_APP_DOMAIN , isBrowserShowing = true )
2430-
2431- verify(mockPixel).fire(AppPixelName .UOA_VISITED_AFTER_SHORTCUT )
2432- }
2433-
2434- @Test
2435- fun whenPageChangedIfPreviousOneWasNotUseOurAppSiteAfterDeleteCtaShownThenPixelSent () = coroutineRule.runBlocking {
2436- givenUseOurAppSiteIsNotSelected()
2437- whenever(mockDismissedCtaDao.exists(CtaId .USE_OUR_APP_DELETION )).thenReturn(true )
2438-
2439- loadUrl(USE_OUR_APP_DOMAIN , isBrowserShowing = true )
2440-
2441- verify(mockPixel).fire(AppPixelName .UOA_VISITED_AFTER_DELETE_CTA )
2442- }
2443-
2444- @Test
2445- fun whenPageChangedIfPreviousOneWasNotUseOurAppSiteThenPixelSent () = coroutineRule.runBlocking {
2446- givenUseOurAppSiteIsNotSelected()
2447-
2448- loadUrl(USE_OUR_APP_DOMAIN , isBrowserShowing = true )
2449-
2450- verify(mockPixel).fire(AppPixelName .UOA_VISITED )
2451- }
2452-
2453- @Test
2454- fun whenPageChangedIfPreviousOneWasUseOurAppSiteAfterNotificationSeenThenPixelNotSent () = coroutineRule.runBlocking {
2455- givenUseOurAppSiteSelected()
2456- whenever(mockNotificationDao.exists(UseOurAppNotification .ID )).thenReturn(true )
2457-
2458- loadUrl(USE_OUR_APP_DOMAIN , isBrowserShowing = true )
2459-
2460- verify(mockPixel, never()).fire(AppPixelName .UOA_VISITED_AFTER_NOTIFICATION )
2461- }
2462-
2463- @Test
2464- fun whenPageChangedIfPreviousOneWasUseOurAppSiteAfterShortcutAddedThenPixelNotSent () = coroutineRule.runBlocking {
2465- givenUseOurAppSiteSelected()
2466- val timestampEntity = UserEventEntity (UserEventKey .USE_OUR_APP_SHORTCUT_ADDED )
2467- whenever(mockUserEventsStore.getUserEvent(UserEventKey .USE_OUR_APP_SHORTCUT_ADDED )).thenReturn(timestampEntity)
2468-
2469- loadUrl(USE_OUR_APP_DOMAIN , isBrowserShowing = true )
2470-
2471- verify(mockPixel, never()).fire(AppPixelName .UOA_VISITED_AFTER_SHORTCUT )
2472- }
2473-
2474- @Test
2475- fun whenPageChangedIfPreviousOneWasUseOurAppSiteThenAfterDeleteCtaShownPixelNotSent () = coroutineRule.runBlocking {
2476- givenUseOurAppSiteSelected()
2477- whenever(mockDismissedCtaDao.exists(CtaId .USE_OUR_APP_DELETION )).thenReturn(true )
2478-
2479- loadUrl(USE_OUR_APP_DOMAIN , isBrowserShowing = true )
2480-
2481- verify(mockPixel, never()).fire(AppPixelName .UOA_VISITED_AFTER_DELETE_CTA )
2482- }
2483-
2484- @Test
2485- fun whenPageChangedIfPreviousOneWasUseOurAppSiteThenNotSent () = coroutineRule.runBlocking {
2486- givenUseOurAppSiteSelected()
2487-
2488- loadUrl(USE_OUR_APP_DOMAIN , isBrowserShowing = true )
2489-
2490- verify(mockPixel, never()).fire(AppPixelName .UOA_VISITED )
2491- }
2492-
24932272 @Test
24942273 fun whenDosAttackDetectedThenErrorIsShown () {
24952274 testee.dosAttackDetected()
@@ -3365,26 +3144,6 @@ class BrowserTabViewModelTest {
33653144 testee.loadData(" TAB_ID" , " https://example.com" , false )
33663145 }
33673146
3368- private fun givenUseOurAppSiteSelected () {
3369- whenever(mockOmnibarConverter.convertQueryToUrl(USE_OUR_APP_DOMAIN , null )).thenReturn(USE_OUR_APP_DOMAIN )
3370- val site: Site = mock()
3371- whenever(site.url).thenReturn(USE_OUR_APP_DOMAIN )
3372- val siteLiveData = MutableLiveData <Site >()
3373- siteLiveData.value = site
3374- whenever(mockTabRepository.retrieveSiteData(" TAB_ID" )).thenReturn(siteLiveData)
3375- testee.loadData(" TAB_ID" , USE_OUR_APP_DOMAIN , false )
3376- }
3377-
3378- private fun givenUseOurAppSiteIsNotSelected () {
3379- whenever(mockOmnibarConverter.convertQueryToUrl(" example.com" , null )).thenReturn(" example.com" )
3380- val site: Site = mock()
3381- whenever(site.url).thenReturn(" example.com" )
3382- val siteLiveData = MutableLiveData <Site >()
3383- siteLiveData.value = site
3384- whenever(mockTabRepository.retrieveSiteData(" TAB_ID" )).thenReturn(siteLiveData)
3385- testee.loadData(" TAB_ID" , " example.com" , false )
3386- }
3387-
33883147 private fun givenFireproofWebsiteDomain (vararg fireproofWebsitesDomain : String ) {
33893148 fireproofWebsitesDomain.forEach {
33903149 fireproofWebsiteDao.insert(FireproofWebsiteEntity (domain = it))
0 commit comments