Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Upgrade to AGP 7.2.1 (DEV) #5238

Merged
merged 5 commits into from
May 27, 2022
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
4 changes: 1 addition & 3 deletions Corona-Warn-App/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,9 @@ android {
}
}
test {
java.srcDirs += "$projectDir/src/testShared/java"
mtwalli marked this conversation as resolved.
Show resolved Hide resolved
resources.srcDirs += "src/main/assets"
}
androidTest {
java.srcDirs += "$projectDir/src/testShared/java"
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
}
Expand Down Expand Up @@ -373,7 +371,7 @@ dependencies {
implementation "androidx.recyclerview:recyclerview-selection:1.1.0"

// DAGGER
def dagger_version = "2.38.1"
def dagger_version = "2.41"
implementation "com.google.dagger:dagger:$dagger_version"
implementation "com.google.dagger:dagger-android:$dagger_version"
implementation "com.google.dagger:dagger-android-support:$dagger_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import android.content.ContentValues
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteException
import androidx.room.testing.MigrationTestHelper
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import de.rki.coronawarnapp.CoronaWarnApplication
import de.rki.coronawarnapp.contactdiary.storage.entity.ContactDiaryLocationEntity
import de.rki.coronawarnapp.contactdiary.storage.entity.ContactDiaryLocationVisitEntity
import de.rki.coronawarnapp.contactdiary.storage.entity.ContactDiaryLocationVisitWrapper
Expand All @@ -17,13 +17,19 @@ import de.rki.coronawarnapp.contactdiary.storage.entity.ContactDiaryPersonEntity
import de.rki.coronawarnapp.contactdiary.storage.internal.migrations.ContactDiaryDatabaseMigration1To2
import de.rki.coronawarnapp.contactdiary.storage.internal.migrations.ContactDiaryDatabaseMigration2To3
import de.rki.coronawarnapp.contactdiary.storage.internal.migrations.ContactDiaryDatabaseMigration3To4
import de.rki.coronawarnapp.util.di.AppInjector
import de.rki.coronawarnapp.util.di.ApplicationComponent
import io.kotest.assertions.throwables.shouldThrow
import io.kotest.matchers.shouldBe
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkObject
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import okio.ByteString.Companion.decodeBase64
import org.joda.time.Duration
import org.joda.time.LocalDate
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -37,10 +43,22 @@ class ContactDiaryDatabaseMigrationTest : BaseTestInstrumentation() {
@get:Rule
val helper: MigrationTestHelper = MigrationTestHelper(
InstrumentationRegistry.getInstrumentation(),
ContactDiaryDatabase::class.java.canonicalName,
FrameworkSQLiteOpenHelperFactory()
ContactDiaryDatabase::class.java
)

@Before
fun setup() {
mockkObject(CoronaWarnApplication)
mockkObject(AppInjector)
every { AppInjector.component } returns mockk<ApplicationComponent>(relaxed = true)
.apply {
every { bugReporter } returns mockk(
relaxed = true
)
}
every { CoronaWarnApplication.getAppContext() } returns ApplicationProvider.getApplicationContext()
}

/**
* Test migration to add new optional attributes
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@ package de.rki.coronawarnapp.risk.storage
import android.content.ContentValues
import android.database.sqlite.SQLiteDatabase
import androidx.room.testing.MigrationTestHelper
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import de.rki.coronawarnapp.CoronaWarnApplication
import de.rki.coronawarnapp.risk.EwRiskLevelResult
import de.rki.coronawarnapp.risk.storage.internal.RiskResultDatabase
import de.rki.coronawarnapp.risk.storage.internal.migrations.RiskResultDatabaseMigration1To2
import de.rki.coronawarnapp.risk.storage.internal.migrations.RiskResultDatabaseMigration2To3
import de.rki.coronawarnapp.risk.storage.internal.riskresults.PersistedRiskLevelResultDao
import de.rki.coronawarnapp.server.protocols.internal.v2.RiskCalculationParametersOuterClass
import de.rki.coronawarnapp.util.di.AppInjector
import de.rki.coronawarnapp.util.di.ApplicationComponent
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkObject
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import org.joda.time.Instant
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -32,10 +38,22 @@ class RiskResultDatabaseMigrationTest : BaseTestInstrumentation() {
@get:Rule
val helper: MigrationTestHelper = MigrationTestHelper(
InstrumentationRegistry.getInstrumentation(),
RiskResultDatabase::class.java.canonicalName,
FrameworkSQLiteOpenHelperFactory()
RiskResultDatabase::class.java
)

@Before
fun setup() {
mockkObject(CoronaWarnApplication)
mockkObject(AppInjector)
every { AppInjector.component } returns mockk<ApplicationComponent>(relaxed = true)
.apply {
every { bugReporter } returns mockk(
relaxed = true
)
}
every { CoronaWarnApplication.getAppContext() } returns ApplicationProvider.getApplicationContext()
}

/**
* Test migration to create new primary key "monotonicId" column
*/
Expand Down Expand Up @@ -280,7 +298,9 @@ class RiskResultDatabaseMigrationTest : BaseTestInstrumentation() {
riskLevel.id shouldBe riskLevelValues["id"]
riskLevel.calculatedAt shouldBe Instant.parse(riskLevelValues["calculatedAt"] as String)
riskLevel.aggregatedRiskResult shouldNotBe null
riskLevel.aggregatedRiskResult?.totalRiskLevel shouldBe RiskCalculationParametersOuterClass.NormalizedTimeToRiskLevelMapping.RiskLevel.forNumber(riskLevelValues["totalRiskLevel"] as Int)
riskLevel.aggregatedRiskResult?.totalRiskLevel shouldBe RiskCalculationParametersOuterClass.NormalizedTimeToRiskLevelMapping.RiskLevel.forNumber(
riskLevelValues["totalRiskLevel"] as Int
)
riskLevel.aggregatedRiskResult?.totalMinimumDistinctEncountersWithLowRisk shouldBe riskLevelValues["totalMinimumDistinctEncountersWithLowRisk"]
riskLevel.aggregatedRiskResult?.totalMinimumDistinctEncountersWithHighRisk shouldBe riskLevelValues["totalMinimumDistinctEncountersWithHighRisk"]
riskLevel.aggregatedRiskResult?.mostRecentDateWithLowRisk shouldBe Instant.parse(riskLevelValues["mostRecentDateWithLowRisk"] as String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import kotlinx.coroutines.runBlocking
import okhttp3.Cache
import org.joda.time.Instant
import retrofit2.converter.gson.GsonConverterFactory
import testhelpers.preferences.mockFlowPreference
import testhelpers.mockFlowPreference
import timber.log.Timber

object Statistics {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package testhelpers

import io.mockk.unmockkAll
import org.junit.AfterClass
import testhelpers.logging.JUnitTree
import timber.log.Timber

abstract class BaseTestInstrumentation {
Expand Down
22 changes: 22 additions & 0 deletions Corona-Warn-App/src/androidTest/java/testhelpers/JUnitTree.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package testhelpers

import android.util.Log

import timber.log.Timber

class JUnitTree(private val minLogLevel: Int = Log.VERBOSE) : Timber.DebugTree() {

private fun priorityToString(priority: Int): String = when (priority) {
Log.ERROR -> "E"
Log.WARN -> "W"
Log.INFO -> "I"
Log.DEBUG -> "D"
Log.VERBOSE -> "V"
else -> priority.toString()
}

override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
if (priority < minLogLevel) return
println("${System.currentTimeMillis()} ${priorityToString(priority)}/$tag: $message")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package testhelpers

import de.rki.coronawarnapp.util.preferences.FlowPreference
import io.mockk.every
import io.mockk.mockk
import kotlinx.coroutines.flow.MutableStateFlow

fun <T> mockFlowPreference(
defaultValue: T
): FlowPreference<T> {
val instance = mockk<FlowPreference<T>>()
val flow = MutableStateFlow(defaultValue)
every { instance.flow } answers { flow }
every { instance.value } answers { flow.value }
every { instance.update(any()) } answers {
val updateCall = arg<(T) -> T>(0)
flow.value = updateCall(flow.value)
}

return instance
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import io.kotest.matchers.shouldBe
import io.mockk.every
import io.mockk.mockk
import org.junit.jupiter.api.Test
import testhelpers.BaseTestInstrumentation

class DccGroupingExtensionsTest : BaseTestInstrumentation() {
class DccGroupingExtensionsTest : testhelpers.BaseTest() {

@Test
fun `first grouping check`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import io.mockk.every
import io.mockk.mockk
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ArgumentsSource
import testhelpers.BaseTestInstrumentation

class DccHolderComparisonTest : BaseTestInstrumentation() {
class DccHolderComparisonTest : testhelpers.BaseTest() {

@ParameterizedTest(name = "{index}: {0}")
@ArgumentsSource(DccHolderComparisonTestCaseProvider::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import de.rki.coronawarnapp.covidcertificate.common.certificate.CertificatePerso
import io.kotest.matchers.shouldBe
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ArgumentsSource
import testhelpers.BaseTestInstrumentation

class DccHolderNameComponentsTest : BaseTestInstrumentation() {
class DccHolderNameComponentsTest : testhelpers.BaseTest() {

@ParameterizedTest(name = "{index}: {0}")
@ArgumentsSource(DccHolderNameComponentsTestCaseProvider::class)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package testhelpers

import de.rki.coronawarnapp.util.coroutine.DispatcherProvider
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlin.coroutines.CoroutineContext

class TestDispatcherProvider(private val context: CoroutineContext? = null) : DispatcherProvider {
override val Default: CoroutineContext
get() = context ?: Dispatchers.Unconfined
override val Main: CoroutineContext
get() = context ?: Dispatchers.Unconfined
override val MainImmediate: CoroutineContext
get() = context ?: Dispatchers.Unconfined
override val Unconfined: CoroutineContext
get() = context ?: Dispatchers.Unconfined
override val IO: CoroutineContext
get() = context ?: Dispatchers.Unconfined
}

fun CoroutineScope.asDispatcherProvider() = this.coroutineContext.asDispatcherProvider()

fun CoroutineContext.asDispatcherProvider() = TestDispatcherProvider(context = this)
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ class MockSharedPreferences : SharedPreferences {
dataMap.putAll(newData)
}

override fun registerOnSharedPreferenceChangeListener(listener: SharedPreferences.OnSharedPreferenceChangeListener) {
override fun registerOnSharedPreferenceChangeListener(
listener: SharedPreferences.OnSharedPreferenceChangeListener
) {
listeners.add(listener)
}

override fun unregisterOnSharedPreferenceChangeListener(listener: SharedPreferences.OnSharedPreferenceChangeListener) {
override fun unregisterOnSharedPreferenceChangeListener(
listener: SharedPreferences.OnSharedPreferenceChangeListener
) {
listeners.remove(listener)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import io.mockk.coEvery
import io.mockk.impl.annotations.MockK
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import testhelpers.BaseTestInstrumentation
import testhelpers.gms.MockGMSTask

class ExposureWindowProviderTest : BaseTestInstrumentation() {
class ExposureWindowProviderTest : testhelpers.BaseTest() {
@MockK lateinit var googleENFClient: ExposureNotificationClient
@MockK lateinit var testSettings: TestSettings
@MockK lateinit var fakeExposureWindowProvider: FakeExposureWindowProvider
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import io.mockk.impl.annotations.MockK
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import testhelpers.BaseTestInstrumentation
import testhelpers.TestDispatcherProvider
import testhelpers.extensions.InstantExecutorExtension
import testhelpers.extensions.getOrAwaitValue

@ExtendWith(InstantExecutorExtension::class)
class DebugOptionsFragmentViewModelTest : BaseTestInstrumentation() {
class DebugOptionsFragmentViewModelTest : testhelpers.BaseTest() {

@MockK private lateinit var environmentSetup: EnvironmentSetup
@MockK private lateinit var dscRepository: DscRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ import kotlinx.coroutines.test.runTest
import org.joda.time.Instant
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import testhelpers.BaseTestInstrumentation

class DefaultRiskLevelStorageTest : BaseTestInstrumentation() {
class DefaultRiskLevelStorageTest : testhelpers.BaseTest() {

@MockK lateinit var databaseFactory: RiskResultDatabase.Factory
@MockK lateinit var database: RiskResultDatabase
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.3'
classpath 'com.android.tools.build:gradle:7.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.protobuf:protobuf-gradle-plugin:$protobufVersion"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip