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

Commit

Permalink
Merge branch 'release/2.2.x' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
d4rken committed May 12, 2021
2 parents e7e4dc3 + 595ab63 commit 9ec222a
Show file tree
Hide file tree
Showing 250 changed files with 8,547 additions and 3,219 deletions.
41 changes: 0 additions & 41 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -493,47 +493,6 @@ jobs:
- store_artifacts:
path: /tmp/instrumentation_tests_device.zip
destination: zips/instrumentation_tests_device.zip
# Keep it until Firebase Test Lab proves reliability
device_screenshots:
macos:
xcode: "12.3.0"
resource_class: large
steps:
- checkout
- restore_cache:
key: gem-cache-v1-{{ arch }}-{{ checksum "Gemfile.lock" }}
- run: bundle check || bundle install --path vendor/bundle
- save_cache:
key: gem-cache-v1-{{ arch }}-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- setup-android-macos
- restore-gradle-cache
- restore-android-build-cache-macos
- run-gradle-cmd:
desc: Build APKs for screenshots
cmd: >
:Corona-Warn-App:assembleDebug
:Corona-Warn-App:assembleAndroidTest
- save-gradle-cache
- save-android-build-cache-macos
- run-emulator-for-api:
apilevel: 29
- run:
name: Run fastlane screengrab
command: |
for i in {1..5}; do bundle exec fastlane screengrab && break || sleep 15; done
no_output_timeout: 30m
- kill-all-emulators
- store_artifacts:
path: fastlane/metadata/android
destination: screenshots
- compress-path:
input: ./fastlane/metadata/android
output: /tmp/device_screenshots.zip
- store_artifacts:
path: /tmp/device_screenshots.zip
destination: zips/device_screenshots.zip

firebase_screenshots:
resource_class: xlarge
Expand Down
4 changes: 4 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ License: Apache-2.0

Files: Corona-Warn-App/src/main/res/font/roboto.ttf
Copyright: 2011 Google Inc.
License: Apache-2.0

Files: Corona-Warn-App/src/test/java/testhelpers/extensions/LiveDataTestUtil.kt
Copyright: 2019 The Android Open Source Project
License: Apache-2.0
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
* @corona-warn-app/cwa-app-android-maintainers

# Code Onwer of all german texts
/Corona-Warn-App/src/main/res/values-de/ @corona-warn-app/cwa-app-android-ua
/Corona-Warn-App/src/main/res/values-de/ @corona-warn-app/cwa-app-user-assistance
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package de.rki.coronawarnapp.bugreporting

import android.content.ContentResolver
import androidx.lifecycle.MutableLiveData
import androidx.test.ext.junit.runners.AndroidJUnit4
import dagger.Module
import dagger.android.ContributesAndroidInjector
import de.rki.coronawarnapp.bugreporting.debuglog.DebugLogger
import de.rki.coronawarnapp.bugreporting.debuglog.export.SAFLogExport
import de.rki.coronawarnapp.bugreporting.debuglog.internal.LogSnapshotter
import de.rki.coronawarnapp.bugreporting.debuglog.ui.DebugLogFragment
import de.rki.coronawarnapp.bugreporting.debuglog.ui.DebugLogViewModel
Expand Down Expand Up @@ -36,8 +34,6 @@ class DebugLogFragmentTest : BaseUITest() {
@MockK lateinit var enfClient: ENFClient
@MockK lateinit var bugReportingSettings: BugReportingSettings
@MockK lateinit var logSnapshotter: LogSnapshotter
@MockK lateinit var safLogExport: SAFLogExport
@MockK lateinit var contentResolver: ContentResolver

private lateinit var inactiveViewModel: DebugLogViewModel
private lateinit var activeViewModel: DebugLogViewModel
Expand Down Expand Up @@ -103,9 +99,7 @@ class DebugLogFragmentTest : BaseUITest() {
TestDispatcherProvider(),
enfClient,
bugReportingSettings,
logSnapshotter,
safLogExport,
contentResolver
logSnapshotter
)
)
with(vm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package de.rki.coronawarnapp.ui.main.home

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.test.espresso.Espresso
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.runners.AndroidJUnit4
import dagger.Module
Expand All @@ -30,6 +28,7 @@ import de.rki.coronawarnapp.ui.main.home.items.HomeItem
import de.rki.coronawarnapp.ui.presencetracing.organizer.TraceLocationOrganizerSettings
import de.rki.coronawarnapp.ui.statistics.Statistics
import de.rki.coronawarnapp.util.TimeStamper
import de.rki.coronawarnapp.util.bluetooth.BluetoothSupport
import de.rki.coronawarnapp.util.encryptionmigration.EncryptionErrorResetTool
import de.rki.coronawarnapp.util.shortcuts.AppShortcutsHelper
import de.rki.coronawarnapp.util.ui.SingleLiveEvent
Expand Down Expand Up @@ -71,6 +70,7 @@ class HomeFragmentTest : BaseUITest() {
@MockK lateinit var tracingSettings: TracingSettings
@MockK lateinit var traceLocationOrganizerSettings: TraceLocationOrganizerSettings
@MockK lateinit var timeStamper: TimeStamper
@MockK lateinit var bluetoothSupport: BluetoothSupport

private lateinit var homeFragmentViewModel: HomeFragmentViewModel

Expand All @@ -96,6 +96,9 @@ class HomeFragmentTest : BaseUITest() {
override fun create(): HomeFragmentViewModel = homeFragmentViewModel
}
)

every { bluetoothSupport.isScanningSupported } returns true
every { bluetoothSupport.isAdvertisingSupported } returns true
}

@Screenshot
Expand All @@ -107,7 +110,7 @@ class HomeFragmentTest : BaseUITest() {
captureHomeFragment("low_risk_no_encounters")

// also scroll down and capture a screenshot of the faq card
Espresso.onView(ViewMatchers.withId(R.id.recycler_view)).perform(recyclerScrollTo())
onView(withId(R.id.recycler_view)).perform(recyclerScrollTo())
takeScreenshot<HomeFragment>("faq_card")
}

Expand Down Expand Up @@ -241,6 +244,30 @@ class HomeFragmentTest : BaseUITest() {
}
}

@Screenshot
@Test
fun captureHomeFragmentCompatibilityBleBroadcastNotSupported() {
every { homeFragmentViewModel.homeItems } returns
homeFragmentItemsLiveData(HomeData.Tracing.TRACING_FAILED_ITEM)
every { bluetoothSupport.isScanningSupported } returns true
every { bluetoothSupport.isAdvertisingSupported } returns false
launchInMainActivity<HomeFragment>()
onView(withId(R.id.recycler_view)).perform(recyclerScrollTo(2))
captureHomeFragment("compatibility_ble_broadcast_not_supported")
}

@Screenshot
@Test
fun captureHomeFragmentCompatibilityBleScanNotSupported() {
every { homeFragmentViewModel.homeItems } returns
homeFragmentItemsLiveData(HomeData.Tracing.TRACING_FAILED_ITEM)
every { bluetoothSupport.isScanningSupported } returns false
every { bluetoothSupport.isAdvertisingSupported } returns true
launchInMainActivity<HomeFragment>()
onView(withId(R.id.recycler_view)).perform(recyclerScrollTo(2))
captureHomeFragment("compatibility_ble_scan_not_supported")
}

@After
fun teardown() {
clearAllViewModels()
Expand Down Expand Up @@ -272,7 +299,8 @@ class HomeFragmentTest : BaseUITest() {
appShortcutsHelper = appShortcutsHelper,
tracingSettings = tracingSettings,
traceLocationOrganizerSettings = traceLocationOrganizerSettings,
timeStamper = timeStamper
timeStamper = timeStamper,
bluetoothSupport = bluetoothSupport
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ import androidx.test.internal.runner.junit4.statement.UiThreadStatement.runOnUiT
import dagger.Module
import dagger.android.ContributesAndroidInjector
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.coronatest.antigen.profile.RATProfileSettings
import de.rki.coronawarnapp.ui.submission.fragment.SubmissionDispatcherFragment
import de.rki.coronawarnapp.ui.submission.viewmodel.SubmissionDispatcherViewModel
import io.mockk.MockKAnnotations
import io.mockk.every
import io.mockk.impl.annotations.MockK
import org.junit.After
import org.junit.Before
import org.junit.Rule
Expand All @@ -23,9 +26,11 @@ import org.junit.runner.RunWith
import testhelpers.BaseUITest
import testhelpers.Screenshot
import testhelpers.SystemUIDemoModeRule
import testhelpers.TestDispatcherProvider
import testhelpers.captureScreenshot
import testhelpers.launchFragment2
import testhelpers.launchFragmentInContainer2
import testhelpers.preferences.mockFlowPreference
import testhelpers.takeScreenshot
import tools.fastlane.screengrab.locale.LocaleTestRule

Expand All @@ -39,7 +44,12 @@ class SubmissionDispatcherFragmentTest : BaseUITest() {
@get:Rule
val systemUIDemoModeRule = SystemUIDemoModeRule()

private fun createViewModel() = SubmissionDispatcherViewModel()
@MockK lateinit var ratProfileSettings: RATProfileSettings

private fun createViewModel() = SubmissionDispatcherViewModel(
ratProfileSettings,
TestDispatcherProvider()
)

private val navController = TestNavHostController(
ApplicationProvider.getApplicationContext()
Expand All @@ -50,6 +60,7 @@ class SubmissionDispatcherFragmentTest : BaseUITest() {
@Before
fun setup() {
MockKAnnotations.init(this, relaxed = true)
every { ratProfileSettings.profile } returns mockFlowPreference(null)
setupMockViewModel(
object : SubmissionDispatcherViewModel.Factory {
override fun create(): SubmissionDispatcherViewModel = createViewModel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package de.rki.coronawarnapp.test.contactdiary.ui
import android.annotation.SuppressLint
import android.os.Bundle
import android.view.View
import androidx.core.widget.TextViewCompat
import androidx.fragment.app.Fragment
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.databinding.FragmentTestContactDiaryBinding
Expand Down Expand Up @@ -84,10 +85,10 @@ class ContactDiaryTestFragment :
text = duration.toContactDiaryFormat()
if (duration.millis == 0L) {
setBackgroundResource(R.drawable.contact_diary_duration_background_default)
setTextAppearance(R.style.bodyNeutral)
TextViewCompat.setTextAppearance(this, R.style.bodyNeutral)
} else {
setBackgroundResource(R.drawable.contact_diary_duration_background_selected)
setTextAppearance(R.style.body1)
TextViewCompat.setTextAppearance(this, R.style.body1)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class DebugOptionsFragment : Fragment(R.layout.fragment_test_debugoptions), Auto
environmentPubkeyAppconfig.text = "AppConfigPubKey:\n${state.pubKeyAppConfig}"
}
}
vm.environmentChangeEvent.observe2(this) {
vm.environmentStateChange.observe2(this) {
showSnackBar("Environment changed to: $it\nForce stop & restart the app!")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
package de.rki.coronawarnapp.test.debugoptions.ui

import androidx.lifecycle.asLiveData
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import de.rki.coronawarnapp.environment.EnvironmentSetup
import de.rki.coronawarnapp.environment.EnvironmentSetup.Type.Companion.toEnvironmentType
import de.rki.coronawarnapp.test.debugoptions.ui.EnvironmentState.Companion.toEnvironmentState
import de.rki.coronawarnapp.util.coroutine.DispatcherProvider
import de.rki.coronawarnapp.util.ui.SingleLiveEvent
import de.rki.coronawarnapp.util.ui.smartLiveData
import de.rki.coronawarnapp.util.viewmodel.CWAViewModel
import de.rki.coronawarnapp.util.viewmodel.SimpleCWAViewModelFactory
import kotlinx.coroutines.flow.MutableStateFlow

class DebugOptionsFragmentViewModel @AssistedInject constructor(
private val envSetup: EnvironmentSetup,
dispatcherProvider: DispatcherProvider
) : CWAViewModel(dispatcherProvider = dispatcherProvider) {

val environmentState by smartLiveData {
envSetup.toEnvironmentState()
}
val environmentChangeEvent = SingleLiveEvent<EnvironmentSetup.Type>()
private val environmentStateFlow = MutableStateFlow(envSetup.toEnvironmentState())
val environmentState = environmentStateFlow.asLiveData(context = dispatcherProvider.Default)
val environmentStateChange = SingleLiveEvent<EnvironmentState>()

fun selectEnvironmentTytpe(type: String) {
environmentState.update {
envSetup.currentEnvironment = type.toEnvironmentType()
environmentChangeEvent.postValue(envSetup.currentEnvironment)
envSetup.toEnvironmentState()
envSetup.currentEnvironment = type.toEnvironmentType()
envSetup.toEnvironmentState().let {
environmentStateFlow.value = it
environmentStateChange.postValue(it)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Corona-Warn-App/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package="de.rki.coronawarnapp"
tools:ignore="LockedOrientationActivity">

<uses-sdk tools:overrideLibrary="com.google.zxing.client.android" />
<uses-sdk tools:overrideLibrary="com.google.zxing.client.android,androidx.security" />

<uses-feature
android:name="android.hardware.bluetooth_le"
Expand Down
Loading

0 comments on commit 9ec222a

Please sign in to comment.