From 76678057add2dada822b233cf76ca9c53bf702f5 Mon Sep 17 00:00:00 2001 From: Olivia Mackintosh Date: Sat, 16 May 2020 17:19:37 +0100 Subject: [PATCH] Replace deprecated RuntimeEnvironment.application --- app/autodiscovery/build.gradle | 1 + .../providersxml/ProvidersXmlDiscoveryTest.kt | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/autodiscovery/build.gradle b/app/autodiscovery/build.gradle index b70b31f83..47cc248e2 100644 --- a/app/autodiscovery/build.gradle +++ b/app/autodiscovery/build.gradle @@ -15,6 +15,7 @@ dependencies { testImplementation project(':app:testing') testImplementation project(":backend:imap") testImplementation "org.robolectric:robolectric:${versions.robolectric}" + testImplementation "androidx.test:core:${versions.androidxCore}" testImplementation "junit:junit:${versions.junit}" testImplementation "com.google.truth:truth:${versions.truth}" testImplementation "org.mockito:mockito-core:${versions.mockito}" diff --git a/app/autodiscovery/src/test/java/com/fsck/k9/autodiscovery/providersxml/ProvidersXmlDiscoveryTest.kt b/app/autodiscovery/src/test/java/com/fsck/k9/autodiscovery/providersxml/ProvidersXmlDiscoveryTest.kt index 7f3379830..3de0f42ac 100644 --- a/app/autodiscovery/src/test/java/com/fsck/k9/autodiscovery/providersxml/ProvidersXmlDiscoveryTest.kt +++ b/app/autodiscovery/src/test/java/com/fsck/k9/autodiscovery/providersxml/ProvidersXmlDiscoveryTest.kt @@ -1,5 +1,6 @@ package com.fsck.k9.autodiscovery.providersxml +import androidx.test.core.app.ApplicationProvider import com.fsck.k9.RobolectricTest import com.fsck.k9.autodiscovery.DiscoveryTarget import com.fsck.k9.backend.BackendManager @@ -12,17 +13,16 @@ import com.nhaarman.mockitokotlin2.doAnswer import com.nhaarman.mockitokotlin2.mock import org.junit.Test import org.mockito.ArgumentMatchers.anyString -import org.robolectric.RuntimeEnvironment class ProvidersXmlDiscoveryTest : RobolectricTest() { - val backendManager = mock { + private val backendManager = mock { on { decodeStoreUri(anyString()) } doAnswer { mock -> ImapStoreUriDecoder.decode(mock.getArgument(0)) } on { decodeTransportUri(anyString()) } doAnswer { mock -> SmtpTransportUriDecoder.decodeSmtpUri(mock.getArgument(0)) } } - val xmlProvider = ProvidersXmlProvider(RuntimeEnvironment.application) - val providersXmlDiscovery = ProvidersXmlDiscovery(backendManager, xmlProvider) + private val xmlProvider = ProvidersXmlProvider(ApplicationProvider.getApplicationContext()) + private val providersXmlDiscovery = ProvidersXmlDiscovery(backendManager, xmlProvider) @Test fun discover_withGmailDomain_shouldReturnCorrectSettings() {