Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import com.duckduckgo.app.notification.model.UseOurAppNotification
import com.duckduckgo.app.onboarding.store.AppStage
import com.duckduckgo.app.onboarding.store.OnboardingStore
import com.duckduckgo.app.onboarding.store.UserStageStore
import com.duckduckgo.app.pixels.AppPixelName
import com.duckduckgo.app.privacy.db.NetworkLeaderboardDao
import com.duckduckgo.app.privacy.db.UserWhitelistDao
import com.duckduckgo.app.privacy.model.PrivacyGrade
Expand Down Expand Up @@ -1095,15 +1096,15 @@ class BrowserTabViewModelTest {
loadUrl("http://example.com")
testee.onDesktopSiteModeToggled(true)
verify(mockCommandObserver, atLeastOnce()).onChanged(commandCaptor.capture())
verify(mockPixel).fire(Pixel.PixelName.MENU_ACTION_DESKTOP_SITE_ENABLE_PRESSED)
verify(mockPixel).fire(AppPixelName.MENU_ACTION_DESKTOP_SITE_ENABLE_PRESSED)
assertTrue(browserViewState().isDesktopBrowsingMode)
}

@Test
fun whenUserSelectsMobileSiteThenMobileModeStateUpdated() {
loadUrl("http://example.com")
testee.onDesktopSiteModeToggled(false)
verify(mockPixel).fire(Pixel.PixelName.MENU_ACTION_DESKTOP_SITE_DISABLE_PRESSED)
verify(mockPixel).fire(AppPixelName.MENU_ACTION_DESKTOP_SITE_DISABLE_PRESSED)
assertFalse(browserViewState().isDesktopBrowsingMode)
}

Expand Down Expand Up @@ -1385,7 +1386,7 @@ class BrowserTabViewModelTest {
loadUrl("http://www.example.com/home.html")
testee.onWhitelistSelected()
verify(mockUserWhitelistDao).insert(UserWhitelistedDomain("www.example.com"))
verify(mockPixel).fire(Pixel.PixelName.BROWSER_MENU_WHITELIST_ADD)
verify(mockPixel).fire(AppPixelName.BROWSER_MENU_WHITELIST_ADD)
verify(mockCommandObserver).onChanged(Command.Refresh)
}

Expand All @@ -1395,7 +1396,7 @@ class BrowserTabViewModelTest {
loadUrl("http://www.example.com/home.html")
testee.onWhitelistSelected()
verify(mockUserWhitelistDao).delete(UserWhitelistedDomain("www.example.com"))
verify(mockPixel).fire(Pixel.PixelName.BROWSER_MENU_WHITELIST_REMOVE)
verify(mockPixel).fire(AppPixelName.BROWSER_MENU_WHITELIST_REMOVE)
verify(mockCommandObserver).onChanged(Command.Refresh)
}

Expand Down Expand Up @@ -1635,7 +1636,7 @@ class BrowserTabViewModelTest {
val suggestion = AutoCompleteBookmarkSuggestion("example", "Example", "https://example.com")
testee.autoCompleteViewState.value = autoCompleteViewState().copy(searchResults = AutoCompleteResult("", listOf(suggestion)))
testee.fireAutocompletePixel(suggestion)
verify(mockPixel).fire(Pixel.PixelName.AUTOCOMPLETE_BOOKMARK_SELECTION, pixelParams(showedBookmarks = true, bookmarkCapable = true))
verify(mockPixel).fire(AppPixelName.AUTOCOMPLETE_BOOKMARK_SELECTION, pixelParams(showedBookmarks = true, bookmarkCapable = true))
}

@Test
Expand All @@ -1645,7 +1646,7 @@ class BrowserTabViewModelTest {
testee.autoCompleteViewState.value = autoCompleteViewState().copy(searchResults = AutoCompleteResult("", suggestions))
testee.fireAutocompletePixel(AutoCompleteSearchSuggestion("example", false))

verify(mockPixel).fire(Pixel.PixelName.AUTOCOMPLETE_SEARCH_SELECTION, pixelParams(showedBookmarks = true, bookmarkCapable = true))
verify(mockPixel).fire(AppPixelName.AUTOCOMPLETE_SEARCH_SELECTION, pixelParams(showedBookmarks = true, bookmarkCapable = true))
}

@Test
Expand All @@ -1654,7 +1655,7 @@ class BrowserTabViewModelTest {
testee.autoCompleteViewState.value = autoCompleteViewState().copy(searchResults = AutoCompleteResult("", emptyList()))
testee.fireAutocompletePixel(AutoCompleteSearchSuggestion("example", false))

verify(mockPixel).fire(Pixel.PixelName.AUTOCOMPLETE_SEARCH_SELECTION, pixelParams(showedBookmarks = false, bookmarkCapable = false))
verify(mockPixel).fire(AppPixelName.AUTOCOMPLETE_SEARCH_SELECTION, pixelParams(showedBookmarks = false, bookmarkCapable = false))
}

@Test
Expand Down Expand Up @@ -2061,7 +2062,7 @@ class BrowserTabViewModelTest {
fun whenFireproofWebsiteAddedThenPixelSent() {
loadUrl("http://example.com/", isBrowserShowing = true)
testee.onFireproofWebsiteMenuClicked()
verify(mockPixel).fire(Pixel.PixelName.FIREPROOF_WEBSITE_ADDED)
verify(mockPixel).fire(AppPixelName.FIREPROOF_WEBSITE_ADDED)
}

@Test
Expand All @@ -2077,7 +2078,7 @@ class BrowserTabViewModelTest {
givenFireproofWebsiteDomain("mobile.example.com")
loadUrl("http://mobile.example.com/", isBrowserShowing = true)
testee.onFireproofWebsiteMenuClicked()
verify(mockPixel).fire(Pixel.PixelName.FIREPROOF_WEBSITE_REMOVE)
verify(mockPixel).fire(AppPixelName.FIREPROOF_WEBSITE_REMOVE)
}

@Test
Expand All @@ -2098,7 +2099,7 @@ class BrowserTabViewModelTest {
assertCommandIssued<Command.ShowFireproofWebSiteConfirmation> {
testee.onFireproofWebsiteSnackbarUndoClicked(this.fireproofWebsiteEntity)
}
verify(mockPixel).fire(Pixel.PixelName.FIREPROOF_WEBSITE_UNDO)
verify(mockPixel).fire(AppPixelName.FIREPROOF_WEBSITE_UNDO)
}

@Test
Expand Down Expand Up @@ -2313,7 +2314,7 @@ class BrowserTabViewModelTest {

testee.onViewReady()

verify(mockPixel).fire(Pixel.PixelName.UOA_VISITED_AFTER_NOTIFICATION)
verify(mockPixel).fire(AppPixelName.UOA_VISITED_AFTER_NOTIFICATION)
}

@Test
Expand All @@ -2323,7 +2324,7 @@ class BrowserTabViewModelTest {

testee.onViewReady()

verify(mockPixel).fire(Pixel.PixelName.UOA_VISITED_AFTER_SHORTCUT)
verify(mockPixel).fire(AppPixelName.UOA_VISITED_AFTER_SHORTCUT)
}

@Test
Expand All @@ -2333,7 +2334,7 @@ class BrowserTabViewModelTest {

testee.onViewReady()

verify(mockPixel).fire(Pixel.PixelName.UOA_VISITED_AFTER_DELETE_CTA)
verify(mockPixel).fire(AppPixelName.UOA_VISITED_AFTER_DELETE_CTA)
}

@Test
Expand All @@ -2342,7 +2343,7 @@ class BrowserTabViewModelTest {

testee.onViewReady()

verify(mockPixel).fire(Pixel.PixelName.UOA_VISITED)
verify(mockPixel).fire(AppPixelName.UOA_VISITED)
}

@Test
Expand All @@ -2352,7 +2353,7 @@ class BrowserTabViewModelTest {

testee.onViewReady()

verify(mockPixel, never()).fire(Pixel.PixelName.UOA_VISITED_AFTER_NOTIFICATION)
verify(mockPixel, never()).fire(AppPixelName.UOA_VISITED_AFTER_NOTIFICATION)
}

@Test
Expand All @@ -2362,7 +2363,7 @@ class BrowserTabViewModelTest {

testee.onViewReady()

verify(mockPixel, never()).fire(Pixel.PixelName.UOA_VISITED_AFTER_SHORTCUT)
verify(mockPixel, never()).fire(AppPixelName.UOA_VISITED_AFTER_SHORTCUT)
}

@Test
Expand All @@ -2372,7 +2373,7 @@ class BrowserTabViewModelTest {

testee.onViewReady()

verify(mockPixel, never()).fire(Pixel.PixelName.UOA_VISITED_AFTER_DELETE_CTA)
verify(mockPixel, never()).fire(AppPixelName.UOA_VISITED_AFTER_DELETE_CTA)
}

@Test
Expand All @@ -2381,7 +2382,7 @@ class BrowserTabViewModelTest {

testee.onViewReady()

verify(mockPixel, never()).fire(Pixel.PixelName.UOA_VISITED)
verify(mockPixel, never()).fire(AppPixelName.UOA_VISITED)
}

@Test
Expand All @@ -2391,7 +2392,7 @@ class BrowserTabViewModelTest {

loadUrl(USE_OUR_APP_DOMAIN, isBrowserShowing = true)

verify(mockPixel).fire(Pixel.PixelName.UOA_VISITED_AFTER_NOTIFICATION)
verify(mockPixel).fire(AppPixelName.UOA_VISITED_AFTER_NOTIFICATION)
}

@Test
Expand All @@ -2401,7 +2402,7 @@ class BrowserTabViewModelTest {

loadUrl(USE_OUR_APP_DOMAIN, isBrowserShowing = true)

verify(mockPixel).fire(Pixel.PixelName.UOA_VISITED_AFTER_SHORTCUT)
verify(mockPixel).fire(AppPixelName.UOA_VISITED_AFTER_SHORTCUT)
}

@Test
Expand All @@ -2411,7 +2412,7 @@ class BrowserTabViewModelTest {

loadUrl(USE_OUR_APP_DOMAIN, isBrowserShowing = true)

verify(mockPixel).fire(Pixel.PixelName.UOA_VISITED_AFTER_DELETE_CTA)
verify(mockPixel).fire(AppPixelName.UOA_VISITED_AFTER_DELETE_CTA)
}

@Test
Expand All @@ -2420,7 +2421,7 @@ class BrowserTabViewModelTest {

loadUrl(USE_OUR_APP_DOMAIN, isBrowserShowing = true)

verify(mockPixel).fire(Pixel.PixelName.UOA_VISITED)
verify(mockPixel).fire(AppPixelName.UOA_VISITED)
}

@Test
Expand All @@ -2430,7 +2431,7 @@ class BrowserTabViewModelTest {

loadUrl(USE_OUR_APP_DOMAIN, isBrowserShowing = true)

verify(mockPixel, never()).fire(Pixel.PixelName.UOA_VISITED_AFTER_NOTIFICATION)
verify(mockPixel, never()).fire(AppPixelName.UOA_VISITED_AFTER_NOTIFICATION)
}

@Test
Expand All @@ -2441,7 +2442,7 @@ class BrowserTabViewModelTest {

loadUrl(USE_OUR_APP_DOMAIN, isBrowserShowing = true)

verify(mockPixel, never()).fire(Pixel.PixelName.UOA_VISITED_AFTER_SHORTCUT)
verify(mockPixel, never()).fire(AppPixelName.UOA_VISITED_AFTER_SHORTCUT)
}

@Test
Expand All @@ -2451,7 +2452,7 @@ class BrowserTabViewModelTest {

loadUrl(USE_OUR_APP_DOMAIN, isBrowserShowing = true)

verify(mockPixel, never()).fire(Pixel.PixelName.UOA_VISITED_AFTER_DELETE_CTA)
verify(mockPixel, never()).fire(AppPixelName.UOA_VISITED_AFTER_DELETE_CTA)
}

@Test
Expand All @@ -2460,7 +2461,7 @@ class BrowserTabViewModelTest {

loadUrl(USE_OUR_APP_DOMAIN, isBrowserShowing = true)

verify(mockPixel, never()).fire(Pixel.PixelName.UOA_VISITED)
verify(mockPixel, never()).fire(AppPixelName.UOA_VISITED)
}

@Test
Expand Down Expand Up @@ -2565,7 +2566,7 @@ class BrowserTabViewModelTest {

testee.onSystemLocationPermissionDeniedOneTime()

verify(mockPixel).fire(Pixel.PixelName.PRECISE_LOCATION_SETTINGS_LOCATION_PERMISSION_DISABLE)
verify(mockPixel).fire(AppPixelName.PRECISE_LOCATION_SETTINGS_LOCATION_PERMISSION_DISABLE)
verify(geoLocationPermissions).clear(domain)
}

Expand All @@ -2592,7 +2593,7 @@ class BrowserTabViewModelTest {

testee.onSystemLocationPermissionGranted()

verify(mockPixel).fire(Pixel.PixelName.PRECISE_LOCATION_SETTINGS_LOCATION_PERMISSION_ENABLE)
verify(mockPixel).fire(AppPixelName.PRECISE_LOCATION_SETTINGS_LOCATION_PERMISSION_ENABLE)
}

@Test
Expand Down Expand Up @@ -2674,7 +2675,7 @@ class BrowserTabViewModelTest {

testee.onSystemLocationPermissionNotAllowed()

verify(mockPixel).fire(Pixel.PixelName.PRECISE_LOCATION_SYSTEM_DIALOG_LATER)
verify(mockPixel).fire(AppPixelName.PRECISE_LOCATION_SYSTEM_DIALOG_LATER)
verify(geoLocationPermissions).clear(domain)
}

Expand All @@ -2688,7 +2689,7 @@ class BrowserTabViewModelTest {

testee.onSystemLocationPermissionNeverAllowed()

verify(mockPixel).fire(Pixel.PixelName.PRECISE_LOCATION_SYSTEM_DIALOG_NEVER)
verify(mockPixel).fire(AppPixelName.PRECISE_LOCATION_SYSTEM_DIALOG_NEVER)
verify(geoLocationPermissions).clear(domain)
assertEquals(locationPermissionsDao.getPermission(domain)!!.permission, LocationPermissionType.DENY_ALWAYS)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.duckduckgo.app.global.rating.AppEnjoymentUserEventRecorder
import com.duckduckgo.app.global.rating.PromptCount
import com.duckduckgo.app.global.useourapp.UseOurAppDetector
import com.duckduckgo.app.global.useourapp.UseOurAppDetector.Companion.USE_OUR_APP_DOMAIN
import com.duckduckgo.app.pixels.AppPixelName
import com.duckduckgo.app.privacy.ui.PrivacyDashboardActivity
import com.duckduckgo.app.runBlocking
import com.duckduckgo.app.statistics.pixels.Pixel
Expand Down Expand Up @@ -215,15 +216,15 @@ class BrowserViewModelTest {
val url = "http://m.$USE_OUR_APP_DOMAIN"
whenever(mockOmnibarEntryConverter.convertQueryToUrl(url)).thenReturn(url)
testee.onOpenShortcut(url)
verify(mockPixel).fire(Pixel.PixelName.USE_OUR_APP_SHORTCUT_OPENED)
verify(mockPixel).fire(AppPixelName.USE_OUR_APP_SHORTCUT_OPENED)
}

@Test
fun whenOpenShortcutIfUrlIsNotUSeOurAppUrlThenFirePixel() {
val url = "example.com"
whenever(mockOmnibarEntryConverter.convertQueryToUrl(url)).thenReturn(url)
testee.onOpenShortcut(url)
verify(mockPixel).fire(Pixel.PixelName.SHORTCUT_OPENED)
verify(mockPixel).fire(AppPixelName.SHORTCUT_OPENED)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.view.MenuItem
import android.webkit.WebView.HitTestResult
import androidx.test.platform.app.InstrumentationRegistry
import com.duckduckgo.app.browser.model.LongPressTarget
import com.duckduckgo.app.pixels.AppPixelName
import com.duckduckgo.app.statistics.pixels.Pixel
import com.nhaarman.mockitokotlin2.eq
import com.nhaarman.mockitokotlin2.never
Expand Down Expand Up @@ -62,19 +63,19 @@ class WebViewLongPressHandlerTest {
@Test
fun whenUserLongPressesWithImageTypeThenPixelFired() {
testee.handleLongPress(HitTestResult.IMAGE_TYPE, HTTPS_IMAGE_URL, mockMenu)
verify(mockPixel).fire(Pixel.PixelName.LONG_PRESS)
verify(mockPixel).fire(AppPixelName.LONG_PRESS)
}

@Test
fun whenUserLongPressesWithAnchorImageTypeThenPixelFired() {
testee.handleLongPress(HitTestResult.SRC_IMAGE_ANCHOR_TYPE, HTTPS_IMAGE_URL, mockMenu)
verify(mockPixel).fire(Pixel.PixelName.LONG_PRESS)
verify(mockPixel).fire(AppPixelName.LONG_PRESS)
}

@Test
fun whenUserLongPressesWithUnknownTypeThenPixelNotFired() {
testee.handleLongPress(HitTestResult.UNKNOWN_TYPE, HTTPS_IMAGE_URL, mockMenu)
verify(mockPixel, never()).fire(Pixel.PixelName.LONG_PRESS)
verify(mockPixel, never()).fire(AppPixelName.LONG_PRESS)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.duckduckgo.app.browser.defaultbrowsing

import com.duckduckgo.app.global.install.AppInstallStore
import com.duckduckgo.app.pixels.AppPixelName
import com.duckduckgo.app.statistics.pixels.Pixel
import com.nhaarman.mockitokotlin2.*
import org.junit.Before
Expand Down Expand Up @@ -53,7 +54,7 @@ class DefaultBrowserObserverTest {

testee.onApplicationResumed()

verify(mockPixel).fire(Pixel.PixelName.DEFAULT_BROWSER_SET, params)
verify(mockPixel).fire(AppPixelName.DEFAULT_BROWSER_SET, params)
}

@Test
Expand All @@ -63,7 +64,7 @@ class DefaultBrowserObserverTest {

testee.onApplicationResumed()

verify(mockPixel, never()).fire(eq(Pixel.PixelName.DEFAULT_BROWSER_SET), any(), any())
verify(mockPixel, never()).fire(eq(AppPixelName.DEFAULT_BROWSER_SET), any(), any())
}

@Test
Expand All @@ -73,7 +74,7 @@ class DefaultBrowserObserverTest {

testee.onApplicationResumed()

verify(mockPixel, never()).fire(eq(Pixel.PixelName.DEFAULT_BROWSER_SET), any(), any())
verify(mockPixel, never()).fire(eq(AppPixelName.DEFAULT_BROWSER_SET), any(), any())
}

@Test
Expand All @@ -83,6 +84,6 @@ class DefaultBrowserObserverTest {

testee.onApplicationResumed()

verify(mockPixel).fire(Pixel.PixelName.DEFAULT_BROWSER_UNSET)
verify(mockPixel).fire(AppPixelName.DEFAULT_BROWSER_UNSET)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.duckduckgo.app.browser.downloader

import com.duckduckgo.app.pixels.AppPixelName
import com.duckduckgo.app.statistics.pixels.Pixel
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.verify
Expand Down Expand Up @@ -159,7 +160,7 @@ class UriUtilsFilenameExtractorTest {
val mimeType: String? = null
val contentDisposition: String? = null
val extracted = testee.extract(buildPendingDownload(url, contentDisposition, mimeType))
verify(mockedPixel).fire(Pixel.PixelName.DOWNLOAD_FILE_DEFAULT_GUESSED_NAME)
verify(mockedPixel).fire(AppPixelName.DOWNLOAD_FILE_DEFAULT_GUESSED_NAME)
}

private fun buildPendingDownload(url: String, contentDisposition: String?, mimeType: String?): FileDownloader.PendingFileDownload {
Expand Down
Loading