Skip to content

Commit

Permalink
Update libraries (#1299)
Browse files Browse the repository at this point in the history
* bump libraries

* Mockito fix: spy not supported for api < 24 (mockito/mockito#2075 (comment))

* Remove duplicated kotlin_version

* reference kotlin version from versions.properties file
  • Loading branch information
cmonfortep committed Jul 24, 2021
1 parent ebb22e0 commit dd633eb
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 11 deletions.
Expand Up @@ -18,6 +18,7 @@ package com.duckduckgo.app.browser.downloader

import android.webkit.WebView
import androidx.test.annotation.UiThreadTest
import androidx.test.filters.SdkSuppress
import androidx.test.platform.app.InstrumentationRegistry
import com.duckduckgo.app.browser.R
import com.nhaarman.mockitokotlin2.spy
Expand All @@ -37,6 +38,7 @@ class BlobConverterInjectorJsTest {

@UiThreadTest
@Test
@SdkSuppress(minSdkVersion = 24)
fun whenConvertBlobIntoDataUriAndDownloadThenInjectJsCode() {
val jsToEvaluate = getJsToEvaluate().replace("%blobUrl%", blobUrl).replace("%contentType%", contentType)
val webView = spy(WebView(InstrumentationRegistry.getInstrumentation().targetContext))
Expand Down
Expand Up @@ -20,6 +20,7 @@ import android.net.Uri
import android.webkit.WebResourceRequest
import android.webkit.WebView
import androidx.test.annotation.UiThreadTest
import androidx.test.filters.SdkSuppress
import androidx.test.platform.app.InstrumentationRegistry
import com.duckduckgo.app.CoroutineTestRule
import com.duckduckgo.app.browser.logindetection.LoginDetectionJavascriptInterface.Companion.JAVASCRIPT_INTERFACE_NAME
Expand All @@ -42,6 +43,7 @@ class JsLoginDetectorTest {

@UiThreadTest
@Test
@SdkSuppress(minSdkVersion = 24)
fun whenAddLoginDetectionThenJSInterfaceAdded() = coroutinesTestRule.runBlocking {
val webView = spy(WebView(InstrumentationRegistry.getInstrumentation().targetContext))
testee.addLoginDetection(webView) {}
Expand All @@ -50,6 +52,7 @@ class JsLoginDetectorTest {

@UiThreadTest
@Test
@SdkSuppress(minSdkVersion = 24)
fun whenLoginDetectionDisabledAndPageStartedEventThenNoWebViewInteractions() = coroutinesTestRule.runBlocking {
whenever(settingsDataStore.appLoginDetection).thenReturn(false)
val webView = spy(WebView(InstrumentationRegistry.getInstrumentation().targetContext))
Expand All @@ -59,6 +62,7 @@ class JsLoginDetectorTest {

@UiThreadTest
@Test
@SdkSuppress(minSdkVersion = 24)
fun whenLoginDetectionDisabledAndInterceptRequestEventThenNoWebViewInteractions() = coroutinesTestRule.runBlocking {
whenever(settingsDataStore.appLoginDetection).thenReturn(false)
val webView = spy(WebView(InstrumentationRegistry.getInstrumentation().targetContext))
Expand All @@ -69,6 +73,7 @@ class JsLoginDetectorTest {

@UiThreadTest
@Test
@SdkSuppress(minSdkVersion = 24)
fun whenLoginDetectionEnabledAndPageStartedEventThenJSLoginDetectionInjected() = coroutinesTestRule.runBlocking {
whenever(settingsDataStore.appLoginDetection).thenReturn(true)
val webView = spy(WebView(InstrumentationRegistry.getInstrumentation().targetContext))
Expand All @@ -78,6 +83,7 @@ class JsLoginDetectorTest {

@UiThreadTest
@Test
@SdkSuppress(minSdkVersion = 24)
fun whenLoginDetectionEnabledAndLoginPostRequestCapturedThenJSLoginDetectionInjected() = coroutinesTestRule.runBlocking {
whenever(settingsDataStore.appLoginDetection).thenReturn(true)
val webView = spy(WebView(InstrumentationRegistry.getInstrumentation().targetContext))
Expand All @@ -88,6 +94,7 @@ class JsLoginDetectorTest {

@UiThreadTest
@Test
@SdkSuppress(minSdkVersion = 24)
fun whenLoginDetectionEnabledAndNoLoginPostRequestCapturedThenNoWebViewInteractions() = coroutinesTestRule.runBlocking {
whenever(settingsDataStore.appLoginDetection).thenReturn(true)
val webView = spy(WebView(InstrumentationRegistry.getInstrumentation().targetContext))
Expand All @@ -98,6 +105,7 @@ class JsLoginDetectorTest {

@UiThreadTest
@Test
@SdkSuppress(minSdkVersion = 24)
fun whenLoginDetectionEnabledAndGetRequestCapturedThenNoWebViewInteractions() = coroutinesTestRule.runBlocking {
whenever(settingsDataStore.appLoginDetection).thenReturn(true)
val webView = spy(WebView(InstrumentationRegistry.getInstrumentation().targetContext))
Expand Down
Expand Up @@ -18,6 +18,7 @@ package com.duckduckgo.app.email

import android.webkit.WebView
import androidx.test.annotation.UiThreadTest
import androidx.test.filters.SdkSuppress
import androidx.test.platform.app.InstrumentationRegistry
import com.duckduckgo.app.browser.DuckDuckGoUrlDetector
import com.duckduckgo.app.browser.R
Expand All @@ -38,6 +39,7 @@ class EmailInjectorJsTest {

@UiThreadTest
@Test
@SdkSuppress(minSdkVersion = 24)
fun whenInjectEmailAutofillJsAndUrlIsFromDuckDuckGoDomainThenInjectJsCode() {
val jsToEvaluate = getJsToEvaluate()
val webView = spy(WebView(InstrumentationRegistry.getInstrumentation().targetContext))
Expand All @@ -49,6 +51,7 @@ class EmailInjectorJsTest {

@UiThreadTest
@Test
@SdkSuppress(minSdkVersion = 24)
fun whenInjectEmailAutofillJsAndUrlIsFromDuckDuckGoSubdomainThenInjectJsCode() {
val jsToEvaluate = getJsToEvaluate()
val webView = spy(WebView(InstrumentationRegistry.getInstrumentation().targetContext))
Expand All @@ -60,6 +63,7 @@ class EmailInjectorJsTest {

@UiThreadTest
@Test
@SdkSuppress(minSdkVersion = 24)
fun whenInjectEmailAutofillJsAndUrlIsNotFromDuckDuckGoAndEmailIsSignedInThenInjectJsCode() {
whenever(mockEmailManager.isSignedIn()).thenReturn(true)
val jsToEvaluate = getJsToEvaluate()
Expand All @@ -72,6 +76,7 @@ class EmailInjectorJsTest {

@UiThreadTest
@Test
@SdkSuppress(minSdkVersion = 24)
fun whenInjectEmailAutofillJsAndUrlIsNotFromDuckDuckGoAndEmailIsNotSignedInThenDoNotInjectJsCode() {
whenever(mockEmailManager.isSignedIn()).thenReturn(false)
val jsToEvaluate = getJsToEvaluate()
Expand All @@ -84,6 +89,7 @@ class EmailInjectorJsTest {

@UiThreadTest
@Test
@SdkSuppress(minSdkVersion = 24)
fun whenInjectAddressThenInjectJsCodeReplacingTheAlias() {
val address = "address"
val jsToEvaluate = getAliasJsToEvaluate().replace("%s", address)
Expand Down
Expand Up @@ -19,6 +19,7 @@ package com.duckduckgo.app.globalprivacycontrol
import android.webkit.WebView
import androidx.core.net.toUri
import androidx.test.annotation.UiThreadTest
import androidx.test.filters.SdkSuppress
import androidx.test.platform.app.InstrumentationRegistry
import com.duckduckgo.app.browser.R
import com.duckduckgo.app.globalprivacycontrol.GlobalPrivacyControlManager.Companion.GPC_HEADER
Expand Down Expand Up @@ -47,6 +48,7 @@ class GlobalPrivacyControlManagerTest {

@UiThreadTest
@Test
@SdkSuppress(minSdkVersion = 24)
fun whenInjectDoNotSellToDomAndGcpIsEnabledThenInjectToDom() {
val jsToEvaluate = getJsToEvaluate()
val webView = spy(WebView(InstrumentationRegistry.getInstrumentation().targetContext))
Expand All @@ -59,6 +61,7 @@ class GlobalPrivacyControlManagerTest {

@UiThreadTest
@Test
@SdkSuppress(minSdkVersion = 24)
fun whenInjectDoNotSellToDomAndGcpIsNotEnabledThenDoNotInjectToDom() {
val jsToEvaluate = getJsToEvaluate()
val webView = spy(WebView(InstrumentationRegistry.getInstrumentation().targetContext))
Expand Down
14 changes: 10 additions & 4 deletions build.gradle
@@ -1,9 +1,15 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.4.30'
ext.spotless = "5.7.0"
ext.anvil_version = "2.2.0"
def versionPropsFile = file('versions.properties')
Properties versionProps = new Properties()

if (versionPropsFile.canRead()) {
versionProps.load(new FileInputStream(versionPropsFile))
}

ext.kotlin_version = versionProps['version.kotlin']
ext.spotless = "5.14.0"
ext.anvil_version = "2.3.3"

ext.min_sdk = 21
ext.target_sdk = 29
Expand Down
14 changes: 7 additions & 7 deletions versions.properties
Expand Up @@ -20,21 +20,21 @@ version.androidx.recyclerview=1.2.1

version.androidx.core=1.6.0

version.androidx.fragment=1.2.5
version.androidx.fragment=1.3.5

version.androidx.legacy=1.0.0

version.androidx.lifecycle=2.4.0-alpha01

version.androidx.room=2.2.6
version.androidx.room=2.3.0

version.androidx.swiperefreshlayout=1.1.0

version.androidx.test=1.4.0-beta02

version.androidx.webkit=1.3.0
version.androidx.webkit=1.4.0

version.androidx.work=2.4.0
version.androidx.work=2.5.0

version.androidx.security=1.1.0-alpha03

Expand Down Expand Up @@ -64,17 +64,17 @@ version.io.reactivex.rxjava2..rxandroid=2.0.2

version.io.reactivex.rxjava2..rxjava=2.2.9

version.kotlin=1.4.10
version.kotlin=1.5.20

version.kotlinx.coroutines=1.5.0

version.leakcanary=2.7

version.okhttp3=4.9.0
version.okhttp3=4.9.1

version.org.apache.commons..commons-math3=3.6.1

version.mockito=3.4.6
version.mockito=3.10.0

version.retrofit2=2.9.0

Expand Down

0 comments on commit dd633eb

Please sign in to comment.