Skip to content

Commit dceb3d7

Browse files
committed
Merge branch 'release/5.52.0'
2 parents e9a7c06 + 4845bd2 commit dceb3d7

File tree

197 files changed

+1782
-790
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+1782
-790
lines changed

app/build.gradle

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -95,41 +95,39 @@ android {
9595
}
9696

9797
ext {
98-
androidX = "1.0.2"
99-
materialDesign = "1.1.0-alpha05"
98+
androidX = "1.2.0-beta01"
99+
materialDesign = "1.2.0-alpha05"
100100
architectureComponents = "1.1.1"
101101
architectureComponentsExtensions = "1.1.1"
102-
androidKtx = "1.0.2"
103-
fragmentKtx = "1.0.0"
104-
constraintLayout = "2.0.0-beta1"
105-
lifecycle = "2.1.0-alpha04"
106-
room = "2.1.0"
107-
workManager = "2.2.0"
102+
androidKtxCore = "1.2.0"
103+
fragmentKtx = "1.2.3"
104+
constraintLayout = "2.0.0-beta4"
105+
lifecycle = "2.2.0"
106+
room = "2.2.5"
107+
workManager = "2.3.4"
108108
legacySupport = "1.0.0"
109-
espressoCore = "3.1.1"
110-
coreTesting = "2.0.0"
111-
androidTestRunner = "1.0.2"
112-
testRunner = "1.1.1"
113-
coroutines = "1.3.1"
109+
coreTesting = "2.1.0"
110+
testRunner = "1.2.0"
111+
coroutines = "1.3.5"
114112
retrofitCoroutinesAdapter = "0.9.2"
115-
webkit = "1.1.0"
113+
webkit = "1.2.0"
114+
referrerLibrary = "1.1.2"
116115

117116
junit = "4.12"
118-
dagger = "2.18"
119-
retrofit = "2.3.0"
117+
dagger = "2.27"
118+
retrofit = "2.8.1"
120119
ankoVersion = "0.10.4"
121-
glide = "4.8.0"
120+
glide = "4.11.0"
122121
lottieVersion = "2.6.0-beta19"
123-
okHttp = "3.10.0"
122+
okHttp = "3.14.7"
124123
rxJava = "2.1.10"
125124
rxAndroid = "2.0.2"
126125
timber = "4.7.1"
127126
rxRelay = "2.0.0"
128-
leakCanary = "2.0-beta-4"
127+
leakCanary = "2.0"
129128
mockito = "2.18.3"
130129
mockitoKotlin = "2.0.0"
131130
commonsMath = "3.6.1"
132-
referrerLibrary = "1.0"
133131
}
134132

135133

@@ -139,10 +137,6 @@ dependencies {
139137

140138
implementation fileTree(dir: 'libs', include: ['*.jar'])
141139

142-
implementation("com.android.installreferrer:installreferrer:$referrerLibrary") {
143-
because "noinspection GradleDependency - 1.1 has a bug which causes a crash"
144-
}
145-
146140
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
147141
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines"
148142
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines"
@@ -171,14 +165,14 @@ dependencies {
171165
implementation "org.jetbrains.anko:anko-design:$ankoVersion"
172166

173167
// Android KTX
174-
implementation "androidx.core:core-ktx:$androidKtx"
168+
implementation "androidx.core:core-ktx:$androidKtxCore"
175169
implementation "androidx.fragment:fragment-ktx:$fragmentKtx"
176170

177171
// ViewModel and LiveData
178172
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle"
179173
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle"
180174

181-
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle"
175+
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle"
182176
testImplementation "androidx.arch.core:core-testing:$coreTesting"
183177
androidTestImplementation "androidx.arch.core:core-testing:$coreTesting"
184178

@@ -209,14 +203,17 @@ dependencies {
209203
// Apache commons
210204
implementation "org.apache.commons:commons-math3:$commonsMath"
211205

206+
// Play Store referrer library
207+
implementation("com.android.installreferrer:installreferrer:$referrerLibrary")
208+
209+
// Testing dependencies
212210
testImplementation "org.mockito:mockito-core:$mockito"
213211
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockitoKotlin"
214212
testImplementation "junit:junit:$junit"
215213

216214
androidTestImplementation "androidx.test:runner:$testRunner"
217215
androidTestImplementation "androidx.test:rules:$testRunner"
218216
androidTestUtil "androidx.test:orchestrator:$testRunner"
219-
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoCore"
220217
androidTestImplementation "org.mockito:mockito-android:$mockito"
221218
androidTestImplementation "com.squareup.okhttp3:mockwebserver:$okHttp"
222219
androidTestImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockitoKotlin"

app/src/androidTest/java/com/duckduckgo/app/browser/BrowserTabViewModelTest.kt

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,6 @@ class BrowserTabViewModelTest {
13371337

13381338
@Test
13391339
fun whenScheduledSurveyChangesAndInstalledDaysDontMatchThenCtaIsNull() {
1340-
setCovidCtaShown()
13411340
testee.onSurveyChanged(Survey("abc", "http://example.com", daysInstalled = 2, status = Survey.Status.SCHEDULED))
13421341
assertNull(testee.ctaViewState.value!!.cta)
13431342
}
@@ -1359,7 +1358,6 @@ class BrowserTabViewModelTest {
13591358

13601359
@Test
13611360
fun whenCtaRefreshedAndAutoAddSupportedAndWidgetAlreadyInstalledThenCtaIsNull() = coroutineRule.runBlocking {
1362-
setCovidCtaShown()
13631361
whenever(mockWidgetCapabilities.supportsStandardWidgetAdd).thenReturn(true)
13641362
whenever(mockWidgetCapabilities.supportsAutomaticWidgetAdd).thenReturn(true)
13651363
whenever(mockWidgetCapabilities.hasInstalledWidgets).thenReturn(true)
@@ -1376,7 +1374,6 @@ class BrowserTabViewModelTest {
13761374

13771375
@Test
13781376
fun whenCtaRefreshedAndOnlyStandardAddSupportedAndWidgetAlreadyInstalledThenCtaIsNull() = coroutineRule.runBlocking {
1379-
setCovidCtaShown()
13801377
whenever(mockWidgetCapabilities.supportsStandardWidgetAdd).thenReturn(true)
13811378
whenever(mockWidgetCapabilities.supportsAutomaticWidgetAdd).thenReturn(false)
13821379
whenever(mockWidgetCapabilities.hasInstalledWidgets).thenReturn(true)
@@ -1386,7 +1383,6 @@ class BrowserTabViewModelTest {
13861383

13871384
@Test
13881385
fun whenCtaRefreshedAndStandardAddNotSupportedAndWidgetNotInstalledThenCtaIsNull() = coroutineRule.runBlocking {
1389-
setCovidCtaShown()
13901386
whenever(mockWidgetCapabilities.supportsStandardWidgetAdd).thenReturn(false)
13911387
whenever(mockWidgetCapabilities.supportsAutomaticWidgetAdd).thenReturn(false)
13921388
whenever(mockWidgetCapabilities.hasInstalledWidgets).thenReturn(false)
@@ -1396,7 +1392,6 @@ class BrowserTabViewModelTest {
13961392

13971393
@Test
13981394
fun whenCtaRefreshedAndStandardAddNotSupportedAndWidgetAlreadyInstalledThenCtaIsNull() = coroutineRule.runBlocking {
1399-
setCovidCtaShown()
14001395
whenever(mockWidgetCapabilities.supportsStandardWidgetAdd).thenReturn(false)
14011396
whenever(mockWidgetCapabilities.supportsAutomaticWidgetAdd).thenReturn(false)
14021397
whenever(mockWidgetCapabilities.hasInstalledWidgets).thenReturn(true)
@@ -1443,45 +1438,41 @@ class BrowserTabViewModelTest {
14431438
@Test
14441439
fun whenUserClickedCtaButtonThenFirePixel() {
14451440
val cta = DaxBubbleCta.DaxIntroCta(mockOnboardingStore, mockAppInstallStore)
1446-
testee.onUserClickCtaOkButton(cta)
1441+
setCta(cta)
1442+
testee.onUserClickCtaOkButton()
14471443
verify(mockPixel).fire(cta.okPixel!!, cta.pixelOkParameters())
14481444
}
14491445

14501446
@Test
14511447
fun whenUserClickedSurveyCtaButtonThenLaunchSurveyCommand() {
14521448
val cta = HomePanelCta.Survey(Survey("abc", "http://example.com", daysInstalled = 1, status = Survey.Status.SCHEDULED))
1453-
testee.onUserClickCtaOkButton(cta)
1449+
setCta(cta)
1450+
testee.onUserClickCtaOkButton()
14541451
assertCommandIssued<Command.LaunchSurvey>()
14551452
}
14561453

14571454
@Test
14581455
fun whenUserClickedAddWidgetCtaButtonThenLaunchAddWidgetCommand() {
14591456
val cta = HomePanelCta.AddWidgetAuto
1460-
testee.onUserClickCtaOkButton(cta)
1457+
setCta(cta)
1458+
testee.onUserClickCtaOkButton()
14611459
assertCommandIssued<Command.LaunchAddWidget>()
14621460
}
14631461

14641462
@Test
14651463
fun whenUserClickedLegacyAddWidgetCtaButtonThenLaunchLegacyAddWidgetCommand() {
14661464
val cta = HomePanelCta.AddWidgetInstructions
1467-
testee.onUserClickCtaOkButton(cta)
1465+
setCta(cta)
1466+
testee.onUserClickCtaOkButton()
14681467
assertCommandIssued<Command.LaunchLegacyAddWidget>()
14691468
}
14701469

14711470
@Test
14721471
fun whenSurveyCtaDismissedAndNoOtherCtaPossibleCtaIsNull() = coroutineRule.runBlocking {
1473-
givenShownCtas(CtaId.DAX_INTRO, CtaId.DAX_END, CtaId.COVID)
1474-
testee.onSurveyChanged(Survey("abc", "http://example.com", daysInstalled = 1, status = Survey.Status.SCHEDULED))
1475-
testee.onUserDismissedCta(testee.ctaViewState.value!!.cta!!)
1476-
assertNull(testee.ctaViewState.value!!.cta)
1477-
}
1478-
1479-
@Test
1480-
fun whenSurveyCtaDismissedAndWidgetNotCompatibleAndCovidCtaNotShownThenCtaIsCovid() = coroutineRule.runBlocking {
14811472
givenShownCtas(CtaId.DAX_INTRO, CtaId.DAX_END)
14821473
testee.onSurveyChanged(Survey("abc", "http://example.com", daysInstalled = 1, status = Survey.Status.SCHEDULED))
1483-
testee.onUserDismissedCta(testee.ctaViewState.value!!.cta!!)
1484-
assertEquals(HomeTopPanelCta.CovidCta(), testee.ctaViewState.value!!.cta)
1474+
testee.onUserDismissedCta()
1475+
assertNull(testee.ctaViewState.value!!.cta)
14851476
}
14861477

14871478
@Test
@@ -1491,46 +1482,68 @@ class BrowserTabViewModelTest {
14911482
whenever(mockWidgetCapabilities.hasInstalledWidgets).thenReturn(false)
14921483

14931484
testee.onSurveyChanged(Survey("abc", "http://example.com", daysInstalled = 1, status = Survey.Status.SCHEDULED))
1494-
testee.onUserDismissedCta(testee.ctaViewState.value!!.cta!!)
1485+
testee.onUserDismissedCta()
14951486
assertEquals(HomePanelCta.AddWidgetAuto, testee.ctaViewState.value!!.cta)
14961487
}
14971488

14981489
@Test
14991490
fun whenUserDismissedCtaThenFirePixel() = coroutineRule.runBlocking {
15001491
val cta = HomePanelCta.Survey(Survey("abc", "http://example.com", daysInstalled = 1, status = Survey.Status.SCHEDULED))
1501-
testee.onUserDismissedCta(cta)
1492+
setCta(cta)
1493+
testee.onUserDismissedCta()
15021494
verify(mockPixel).fire(cta.cancelPixel!!, cta.pixelCancelParameters())
15031495
}
15041496

1497+
@Test
1498+
fun whenUserClickedHideDaxDialogThenHideDaxDialogCommandSent() {
1499+
val cta = DaxDialogCta.DaxSerpCta(mockOnboardingStore, mockAppInstallStore)
1500+
setCta(cta)
1501+
testee.onUserHideDaxDialog()
1502+
val command = captureCommands().lastValue
1503+
assertTrue(command is Command.DaxCommand.HideDaxDialog)
1504+
}
1505+
1506+
@Test
1507+
fun whenUserDismissDaxTrackersBlockedDialogThenFinishTrackerAnimationCommandSent() {
1508+
val cta = DaxDialogCta.DaxTrackersBlockedCta(mockOnboardingStore, mockAppInstallStore, emptyList(), "")
1509+
setCta(cta)
1510+
testee.onDaxDialogDismissed()
1511+
val command = captureCommands().lastValue
1512+
assertTrue(command is Command.DaxCommand.FinishTrackerAnimation)
1513+
}
1514+
1515+
@Test
1516+
fun whenUserDismissDifferentThanDaxTrackersBlockedDialogThenFinishTrackerAnimationCommandNotSent() {
1517+
val cta = DaxDialogCta.DaxSerpCta(mockOnboardingStore, mockAppInstallStore)
1518+
setCta(cta)
1519+
testee.onDaxDialogDismissed()
1520+
verify(mockCommandObserver, never()).onChanged(commandCaptor.capture())
1521+
}
1522+
15051523
@Test
15061524
fun whenUserDismissedCtaThenRegisterInDatabase() = coroutineRule.runBlocking {
15071525
val cta = HomePanelCta.AddWidgetAuto
1508-
testee.onUserDismissedCta(cta)
1526+
setCta(cta)
1527+
testee.onUserDismissedCta()
15091528
verify(mockDismissedCtaDao).insert(DismissedCta(cta.ctaId))
15101529
}
15111530

15121531
@Test
15131532
fun whenUserDismissedSurveyCtaThenDoNotRegisterInDatabase() = coroutineRule.runBlocking {
15141533
val cta = HomePanelCta.Survey(Survey("abc", "http://example.com", daysInstalled = 1, status = Survey.Status.SCHEDULED))
1515-
testee.onUserDismissedCta(cta)
1534+
setCta(cta)
1535+
testee.onUserDismissedCta()
15161536
verify(mockDismissedCtaDao, never()).insert(DismissedCta(cta.ctaId))
15171537
}
15181538

15191539
@Test
15201540
fun whenUserDismissedSurveyCtaThenCancelScheduledSurveys() = coroutineRule.runBlocking {
15211541
val cta = HomePanelCta.Survey(Survey("abc", "http://example.com", daysInstalled = 1, status = Survey.Status.SCHEDULED))
1522-
testee.onUserDismissedCta(cta)
1542+
setCta(cta)
1543+
testee.onUserDismissedCta()
15231544
verify(mockSurveyDao).cancelScheduledSurveys()
15241545
}
15251546

1526-
1527-
@Test
1528-
fun whenUserDismissedHomeTopPanelCtaThenReturnEmptyCta() {
1529-
val cta = HomeTopPanelCta.CovidCta()
1530-
testee.onUserDismissedCta(cta)
1531-
assertNull(testee.ctaViewState.value!!.cta)
1532-
}
1533-
15341547
@Test
15351548
fun whenSurrogateDetectedThenSiteUpdated() {
15361549
givenOneActiveTabSelected()
@@ -1665,13 +1678,6 @@ class BrowserTabViewModelTest {
16651678
assertEquals("surrogate.com", brokenSiteFeedback.surrogates)
16661679
}
16671680

1668-
@Test
1669-
fun whenUserClickedTopCtaButtonAndCtaIsCovidCtaThenSubmitQuery() {
1670-
val cta = HomeTopPanelCta.CovidCta()
1671-
testee.onUserClickTopCta(cta)
1672-
assertEquals(cta.searchTerm, omnibarViewState().omnibarText)
1673-
}
1674-
16751681
private inline fun <reified T : Command> assertCommandIssued(instanceAssertions: T.() -> Unit = {}) {
16761682
verify(mockCommandObserver, atLeastOnce()).onChanged(commandCaptor.capture())
16771683
val issuedCommand = commandCaptor.allValues.find { it is T }
@@ -1710,6 +1716,10 @@ class BrowserTabViewModelTest {
17101716
testee.browserViewState.value = browserViewState().copy(browserShowing = isBrowsing)
17111717
}
17121718

1719+
private fun setCta(cta: Cta) {
1720+
testee.ctaViewState.value = ctaViewState().copy(cta = cta)
1721+
}
1722+
17131723
private fun loadUrl(url: String?, title: String? = null, isBrowserShowing: Boolean = true) {
17141724
setBrowserShowing(isBrowserShowing)
17151725
testee.navigationStateChanged(buildWebNavigation(originalUrl = url, currentUrl = url, title = title))
@@ -1721,10 +1731,6 @@ class BrowserTabViewModelTest {
17211731
testee.navigationStateChanged(buildWebNavigation(originalUrl = originalUrl, currentUrl = currentUrl))
17221732
}
17231733

1724-
private fun setCovidCtaShown() {
1725-
whenever(mockDismissedCtaDao.exists(CtaId.COVID)).thenReturn(true)
1726-
}
1727-
17281734
private fun setupNavigation(
17291735
skipHome: Boolean = false,
17301736
isBrowsing: Boolean,
@@ -1761,6 +1767,7 @@ class BrowserTabViewModelTest {
17611767
return nav
17621768
}
17631769

1770+
private fun ctaViewState() = testee.ctaViewState.value!!
17641771
private fun browserViewState() = testee.browserViewState.value!!
17651772
private fun omnibarViewState() = testee.omnibarViewState.value!!
17661773
private fun loadingViewState() = testee.loadingViewState.value!!

0 commit comments

Comments
 (0)