Skip to content

Commit a125c88

Browse files
committed
Merge branch 'release/5.24.0'
2 parents 8a8f0ae + 65f8290 commit a125c88

File tree

64 files changed

+1049
-442
lines changed

Some content is hidden

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

64 files changed

+1049
-442
lines changed

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ ext {
8484
androidKtx = "1.0.1"
8585
fragmentKtx = "1.0.0"
8686
constraintLayout = "2.0.0-alpha3"
87-
lifecycle = "2.0.0"
87+
lifecycle = "2.1.0-alpha04"
8888
room = "2.1.0-alpha05"
8989
workManager = "2.0.0"
9090
legacySupport = "1.0.0"
@@ -113,8 +113,6 @@ ext {
113113

114114
dependencies {
115115
implementation "androidx.legacy:legacy-support-v4:$legacySupport"
116-
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-beta01'
117-
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.0.0'
118116
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanary"
119117
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanary"
120118

@@ -147,6 +145,8 @@ dependencies {
147145

148146
// ViewModel and LiveData
149147
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle"
148+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle"
149+
150150
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle"
151151
testImplementation "androidx.arch.core:core-testing:$coreTesting"
152152
androidTestImplementation "androidx.arch.core:core-testing:$coreTesting"

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
@file:Suppress("RemoveExplicitTypeArguments")
18+
1719
package com.duckduckgo.app.browser
1820

1921
import android.content.Context

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
@file:Suppress("RemoveExplicitTypeArguments")
18+
1719
package com.duckduckgo.app.browser
1820

1921
import android.view.MenuItem
@@ -36,11 +38,11 @@ import com.duckduckgo.app.browser.LongPressHandler.RequiredAction.DownloadFile
3638
import com.duckduckgo.app.browser.LongPressHandler.RequiredAction.OpenInNewTab
3739
import com.duckduckgo.app.browser.addtohome.AddToHomeCapabilityDetector
3840
import com.duckduckgo.app.browser.favicon.FaviconDownloader
41+
import com.duckduckgo.app.browser.model.BasicAuthenticationCredentials
42+
import com.duckduckgo.app.browser.model.BasicAuthenticationRequest
3943
import com.duckduckgo.app.browser.model.LongPressTarget
4044
import com.duckduckgo.app.browser.omnibar.OmnibarEntryConverter
4145
import com.duckduckgo.app.browser.session.WebViewSessionStorage
42-
import com.duckduckgo.app.browser.model.BasicAuthenticationCredentials
43-
import com.duckduckgo.app.browser.model.BasicAuthenticationRequest
4446
import com.duckduckgo.app.cta.db.DismissedCtaDao
4547
import com.duckduckgo.app.cta.ui.CtaViewModel
4648
import com.duckduckgo.app.global.db.AppConfigurationDao
@@ -64,6 +66,7 @@ import com.duckduckgo.app.trackerdetection.model.TrackingEvent
6466
import com.duckduckgo.app.usage.search.SearchCountDao
6567
import com.duckduckgo.app.widget.ui.WidgetCapabilities
6668
import com.nhaarman.mockitokotlin2.*
69+
import kotlinx.coroutines.runBlocking
6770
import org.junit.After
6871
import org.junit.Assert.*
6972
import org.junit.Before
@@ -178,9 +181,11 @@ class BrowserTabViewModelTest {
178181
)
179182

180183
val siteFactory = SiteFactory(mockPrivacyPractices, mockTrackerNetworks, prevalenceStore = mockPrevalenceStore)
181-
whenever(mockTabsRepository.retrieveSiteData(any())).thenReturn(MutableLiveData())
182-
whenever(mockPrivacyPractices.privacyPracticesFor(any())).thenReturn(PrivacyPractices.UNKNOWN)
183-
whenever(mockAppInstallStore.installTimestamp).thenReturn(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1))
184+
runBlocking<Unit> {
185+
whenever(mockTabsRepository.retrieveSiteData(any())).thenReturn(MutableLiveData())
186+
whenever(mockPrivacyPractices.privacyPracticesFor(any())).thenReturn(PrivacyPractices.UNKNOWN)
187+
whenever(mockAppInstallStore.installTimestamp).thenReturn(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1))
188+
}
184189

185190
testee = BrowserTabViewModel(
186191
statisticsUpdater = mockStatisticsUpdater,
@@ -237,7 +242,7 @@ class BrowserTabViewModelTest {
237242
}
238243

239244
@Test
240-
fun whenOpenInNewBackgroundRequestedThenTabRepositoryUpdatedAndCommandIssued() {
245+
fun whenOpenInNewBackgroundRequestedThenTabRepositoryUpdatedAndCommandIssued() = runBlocking<Unit> {
241246
val url = "http://www.example.com"
242247
testee.openInNewBackgroundTab(url)
243248

@@ -553,13 +558,13 @@ class BrowserTabViewModelTest {
553558
}
554559

555560
@Test
556-
fun whenLoadingStartedThenPrivacyGradeIsCleared() {
561+
fun whenLoadingStartedThenPrivacyGradeIsCleared() = runBlocking<Unit> {
557562
testee.loadingStarted("http://example.com")
558563
assertNull(testee.privacyGrade.value)
559564
}
560565

561566
@Test
562-
fun whenUrlChangedThenPrivacyGradeIsReset() {
567+
fun whenUrlChangedThenPrivacyGradeIsReset() = runBlocking<Unit> {
563568
val grade = testee.privacyGrade.value
564569
changeUrl("https://example.com")
565570
assertNotEquals(grade, testee.privacyGrade.value)
@@ -984,7 +989,7 @@ class BrowserTabViewModelTest {
984989
}
985990

986991
@Test
987-
fun whenOnSiteAndBrokenSiteSelectedThenBrokenSiteFeedbackCommandSentWithUrl() {
992+
fun whenOnSiteAndBrokenSiteSelectedThenBrokenSiteFeedbackCommandSentWithUrl() = runBlocking<Unit> {
988993
isBrowsing(true)
989994
changeUrl("foo.com")
990995
testee.onBrokenSiteSelected()

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import com.duckduckgo.app.privacy.ui.PrivacyDashboardActivity
3131
import com.duckduckgo.app.tabs.model.TabEntity
3232
import com.duckduckgo.app.tabs.model.TabRepository
3333
import com.nhaarman.mockitokotlin2.*
34+
import kotlinx.coroutines.runBlocking
3435
import org.junit.After
3536
import org.junit.Assert.assertEquals
3637
import org.junit.Assert.assertTrue
@@ -50,10 +51,10 @@ class BrowserViewModelTest {
5051
var instantTaskExecutorRule = InstantTaskExecutorRule()
5152

5253
@Mock
53-
private lateinit var mockCommandObserver: Observer<BrowserViewModel.Command>
54+
private lateinit var mockCommandObserver: Observer<Command>
5455

5556
@Captor
56-
private lateinit var commandCaptor: ArgumentCaptor<BrowserViewModel.Command>
57+
private lateinit var commandCaptor: ArgumentCaptor<Command>
5758

5859
@Mock
5960
private lateinit var mockTabRepository: TabRepository
@@ -86,8 +87,11 @@ class BrowserViewModelTest {
8687
appEnjoymentUserEventRecorder = mockAppEnjoymentUserEventRecorder
8788
)
8889
testee.command.observeForever(mockCommandObserver)
89-
whenever(mockTabRepository.add()).thenReturn(TAB_ID)
90-
whenever(mockOmnibarEntryConverter.convertQueryToUrl(any())).then { it.arguments.first() }
90+
91+
runBlocking<Unit> {
92+
whenever(mockTabRepository.add()).thenReturn(TAB_ID)
93+
whenever(mockOmnibarEntryConverter.convertQueryToUrl(any())).then { it.arguments.first() }
94+
}
9195
}
9296

9397
@After
@@ -96,26 +100,26 @@ class BrowserViewModelTest {
96100
}
97101

98102
@Test
99-
fun whenNewTabRequestedThenTabAddedToRepository() {
103+
fun whenNewTabRequestedThenTabAddedToRepository() = runBlocking<Unit> {
100104
testee.onNewTabRequested()
101105
verify(mockTabRepository).add()
102106
}
103107

104108
@Test
105-
fun whenOpenInNewTabRequestedThenTabAddedToRepository() {
109+
fun whenOpenInNewTabRequestedThenTabAddedToRepository() = runBlocking<Unit> {
106110
val url = "http://example.com"
107111
testee.onOpenInNewTabRequested(url)
108112
verify(mockTabRepository).add(url)
109113
}
110114

111115
@Test
112-
fun whenTabsUpdatedAndNoTabsThenNewTabAddedToRepository() {
116+
fun whenTabsUpdatedAndNoTabsThenNewTabAddedToRepository() = runBlocking<Unit> {
113117
testee.onTabsUpdated(ArrayList())
114118
verify(mockTabRepository).add(null, false, true)
115119
}
116120

117121
@Test
118-
fun whenTabsUpdatedWithTabsThenNewTabNotLaunched() {
122+
fun whenTabsUpdatedWithTabsThenNewTabNotLaunched() = runBlocking {
119123
testee.onTabsUpdated(asList(TabEntity(TAB_ID, "", "", false, true, 0)))
120124
verify(mockCommandObserver, never()).onChanged(any())
121125
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import com.duckduckgo.app.statistics.store.StatisticsDataStore
2828
import com.nhaarman.mockitokotlin2.any
2929
import com.nhaarman.mockitokotlin2.mock
3030
import com.nhaarman.mockitokotlin2.verify
31+
import kotlinx.coroutines.runBlocking
3132
import org.junit.Before
3233
import org.junit.Test
3334

@@ -68,7 +69,7 @@ class BrowserWebViewClientTest {
6869

6970
@UiThreadTest
7071
@Test
71-
fun whenOnPageFinishedCalledThenListenerNotified() {
72+
fun whenOnPageFinishedCalledThenListenerNotified() = runBlocking {
7273
testee.onPageFinished(webView, EXAMPLE_URL)
7374
verify(listener).loadingFinished(EXAMPLE_URL)
7475
}

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

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
@file:Suppress("RemoveExplicitTypeArguments")
18+
1719
package com.duckduckgo.app.browser
1820

1921
import android.net.Uri
@@ -29,6 +31,7 @@ import com.duckduckgo.app.surrogates.SurrogateResponse
2931
import com.duckduckgo.app.trackerdetection.TrackerDetector
3032
import com.duckduckgo.app.trackerdetection.model.TrackingEvent
3133
import com.nhaarman.mockitokotlin2.*
34+
import kotlinx.coroutines.runBlocking
3235
import org.junit.Assert.*
3336
import org.junit.Before
3437
import org.junit.Test
@@ -65,7 +68,7 @@ class WebViewRequestInterceptorTest {
6568
}
6669

6770
@Test
68-
fun whenUrlShouldBeUpgradedThenUpgraderInvoked() {
71+
fun whenUrlShouldBeUpgradedThenUpgraderInvoked() = runBlocking<Unit> {
6972
configureShouldUpgrade()
7073
testee.shouldIntercept(
7174
request = mockRequest,
@@ -78,7 +81,7 @@ class WebViewRequestInterceptorTest {
7881
}
7982

8083
@Test
81-
fun whenUrlShouldBeUpgradedThenCancelledResponseReturned() {
84+
fun whenUrlShouldBeUpgradedThenCancelledResponseReturned() = runBlocking<Unit> {
8285
configureShouldUpgrade()
8386
val response = testee.shouldIntercept(
8487
request = mockRequest,
@@ -91,7 +94,7 @@ class WebViewRequestInterceptorTest {
9194
}
9295

9396
@Test
94-
fun whenUrlShouldBeUpgradedButNotOnMainFrameThenNotUpgraded() {
97+
fun whenUrlShouldBeUpgradedButNotOnMainFrameThenNotUpgraded() = runBlocking<Unit> {
9598
configureShouldUpgrade()
9699
whenever(mockRequest.isForMainFrame).thenReturn(false)
97100
testee.shouldIntercept(
@@ -105,7 +108,7 @@ class WebViewRequestInterceptorTest {
105108
}
106109

107110
@Test
108-
fun whenUrlShouldBeUpgradedButUrlIsNullThenNotUpgraded() {
111+
fun whenUrlShouldBeUpgradedButUrlIsNullThenNotUpgraded() = runBlocking<Unit> {
109112
configureShouldUpgrade()
110113
whenever(mockRequest.url).thenReturn(null)
111114
testee.shouldIntercept(
@@ -119,7 +122,7 @@ class WebViewRequestInterceptorTest {
119122
}
120123

121124
@Test
122-
fun whenUrlShouldNotBeUpgradedThenUpgraderNotInvoked() {
125+
fun whenUrlShouldNotBeUpgradedThenUpgraderNotInvoked() = runBlocking<Unit> {
123126
whenever(mockHttpsUpgrader.shouldUpgrade(any())).thenReturn(false)
124127
testee.shouldIntercept(
125128
request = mockRequest,
@@ -132,7 +135,7 @@ class WebViewRequestInterceptorTest {
132135
}
133136

134137
@Test
135-
fun whenCurrentUrlIsNullThenShouldContinueToLoad() {
138+
fun whenCurrentUrlIsNullThenShouldContinueToLoad() = runBlocking<Unit> {
136139
configureShouldNotUpgrade()
137140
val response = testee.shouldIntercept(
138141
request = mockRequest,
@@ -144,7 +147,7 @@ class WebViewRequestInterceptorTest {
144147
}
145148

146149
@Test
147-
fun whenIsTrustedSite_DuckDuckGo_ThenShouldContinueToLoad() {
150+
fun whenIsTrustedSite_DuckDuckGo_ThenShouldContinueToLoad() = runBlocking<Unit> {
148151
configureShouldNotUpgrade()
149152
val response = testee.shouldIntercept(
150153
request = mockRequest,
@@ -157,7 +160,7 @@ class WebViewRequestInterceptorTest {
157160
}
158161

159162
@Test
160-
fun whenIsTrustedSite_DontTrack_ThenShouldContinueToLoad() {
163+
fun whenIsTrustedSite_DontTrack_ThenShouldContinueToLoad() = runBlocking<Unit> {
161164
configureShouldNotUpgrade()
162165
val response = testee.shouldIntercept(
163166
request = mockRequest,
@@ -170,7 +173,7 @@ class WebViewRequestInterceptorTest {
170173
}
171174

172175
@Test
173-
fun whenIsTrustedSite_SpreadPrivacy_ThenShouldContinueToLoad() {
176+
fun whenIsTrustedSite_SpreadPrivacy_ThenShouldContinueToLoad() = runBlocking<Unit> {
174177
configureShouldNotUpgrade()
175178
val response = testee.shouldIntercept(
176179
request = mockRequest,
@@ -183,7 +186,7 @@ class WebViewRequestInterceptorTest {
183186
}
184187

185188
@Test
186-
fun whenIsTrustedSite_DuckDuckHack_ThenShouldContinueToLoad() {
189+
fun whenIsTrustedSite_DuckDuckHack_ThenShouldContinueToLoad() = runBlocking<Unit> {
187190
configureShouldNotUpgrade()
188191
val response = testee.shouldIntercept(
189192
request = mockRequest,
@@ -196,7 +199,7 @@ class WebViewRequestInterceptorTest {
196199
}
197200

198201
@Test
199-
fun whenIsTrustedSite_PrivateBrowsingMyths_ThenShouldContinueToLoad() {
202+
fun whenIsTrustedSite_PrivateBrowsingMyths_ThenShouldContinueToLoad() = runBlocking<Unit> {
200203
configureShouldNotUpgrade()
201204
val response = testee.shouldIntercept(
202205
request = mockRequest,
@@ -209,7 +212,7 @@ class WebViewRequestInterceptorTest {
209212
}
210213

211214
@Test
212-
fun whenIsTrustedSite_DuckDotCo_ThenShouldContinueToLoad() {
215+
fun whenIsTrustedSite_DuckDotCo_ThenShouldContinueToLoad() = runBlocking<Unit> {
213216
configureShouldNotUpgrade()
214217
val response = testee.shouldIntercept(
215218
request = mockRequest,
@@ -222,7 +225,7 @@ class WebViewRequestInterceptorTest {
222225
}
223226

224227
@Test
225-
fun whenIsHttpRequestThenHttpRequestListenerCalled() {
228+
fun whenIsHttpRequestThenHttpRequestListenerCalled() = runBlocking<Unit> {
226229
configureShouldNotUpgrade()
227230
whenever(mockRequest.url).thenReturn(Uri.parse("http://example.com"))
228231
val mockListener = mock<WebViewClientListener>()
@@ -239,7 +242,7 @@ class WebViewRequestInterceptorTest {
239242
}
240243

241244
@Test
242-
fun whenIsHttpsRequestThenHttpRequestListenerNotCalled() {
245+
fun whenIsHttpsRequestThenHttpRequestListenerNotCalled() = runBlocking<Unit> {
243246
configureShouldNotUpgrade()
244247
whenever(mockRequest.url).thenReturn(Uri.parse("https://example.com"))
245248
val mockListener = mock<WebViewClientListener>()
@@ -257,7 +260,7 @@ class WebViewRequestInterceptorTest {
257260

258261

259262
@Test
260-
fun whenRequestShouldBlockAndNoSurrogateThenCancellingResponseReturned() {
263+
fun whenRequestShouldBlockAndNoSurrogateThenCancellingResponseReturned() = runBlocking<Unit> {
261264
whenever(mockResourceSurrogates.get(any())).thenReturn(SurrogateResponse(responseAvailable = false))
262265

263266
configureShouldNotUpgrade()
@@ -273,7 +276,7 @@ class WebViewRequestInterceptorTest {
273276
}
274277

275278
@Test
276-
fun whenRequestShouldBlockButThereIsASurrogateThen() {
279+
fun whenRequestShouldBlockButThereIsASurrogateThen() = runBlocking<Unit> {
277280
val availableSurrogate = SurrogateResponse(
278281
responseAvailable = true,
279282
mimeType = "application/javascript",
@@ -308,13 +311,13 @@ class WebViewRequestInterceptorTest {
308311
whenever(mockTrackerDetector.evaluate(any(), any(), any())).thenReturn(blockTrackingEvent)
309312
}
310313

311-
private fun configureShouldUpgrade() {
314+
private fun configureShouldUpgrade() = runBlocking<Unit> {
312315
whenever(mockHttpsUpgrader.shouldUpgrade(any())).thenReturn(true)
313316
whenever(mockRequest.url).thenReturn(validUri())
314317
whenever(mockRequest.isForMainFrame).thenReturn(true)
315318
}
316319

317-
private fun configureShouldNotUpgrade() {
320+
private fun configureShouldNotUpgrade() = runBlocking<Unit> {
318321
whenever(mockHttpsUpgrader.shouldUpgrade(any())).thenReturn(false)
319322

320323
whenever(mockRequest.url).thenReturn(validUri())

0 commit comments

Comments
 (0)