diff options
author | 2023-08-16 18:26:48 +0000 | |
---|---|---|
committer | 2023-08-16 18:26:48 +0000 | |
commit | acb3af52911f30aa787d1147de294b9556bcf813 (patch) | |
tree | fe367703f8a968d85258681e5871f58f0daa4027 /tests/hostside | |
parent | ac37626249fc4bed0099f6414f9d463629f06568 (diff) | |
parent | 548c9b410afb55b6ce63cf61d9b785cde0ce4cd8 (diff) |
Merge "Fix ordering for event processing." into udc-mainline-prod
Diffstat (limited to 'tests/hostside')
2 files changed, 65 insertions, 0 deletions
diff --git a/tests/hostside/safetycenter/helper-app/src/android/safetycenter/hostside/device/SafetySourceStateCollectedLoggingHelperTests.kt b/tests/hostside/safetycenter/helper-app/src/android/safetycenter/hostside/device/SafetySourceStateCollectedLoggingHelperTests.kt index d020aac0a..4d945aad7 100644 --- a/tests/hostside/safetycenter/helper-app/src/android/safetycenter/hostside/device/SafetySourceStateCollectedLoggingHelperTests.kt +++ b/tests/hostside/safetycenter/helper-app/src/android/safetycenter/hostside/device/SafetySourceStateCollectedLoggingHelperTests.kt @@ -27,16 +27,21 @@ import com.android.safetycenter.testing.Coroutines.TIMEOUT_SHORT import com.android.safetycenter.testing.SafetyCenterApisWithShellPermissions.reportSafetySourceErrorWithPermission import com.android.safetycenter.testing.SafetyCenterFlags import com.android.safetycenter.testing.SafetyCenterTestConfigs +import com.android.safetycenter.testing.SafetyCenterTestConfigs.Companion.SINGLE_SOURCE_ID import com.android.safetycenter.testing.SafetyCenterTestConfigs.Companion.SOURCE_ID_1 import com.android.safetycenter.testing.SafetyCenterTestConfigs.Companion.SOURCE_ID_2 import com.android.safetycenter.testing.SafetyCenterTestConfigs.Companion.SOURCE_ID_3 +import com.android.safetycenter.testing.SafetyCenterTestData import com.android.safetycenter.testing.SafetyCenterTestHelper import com.android.safetycenter.testing.SafetyCenterTestRule import com.android.safetycenter.testing.SafetySourceIntentHandler.Request import com.android.safetycenter.testing.SafetySourceIntentHandler.Response import com.android.safetycenter.testing.SafetySourceReceiver +import com.android.safetycenter.testing.SafetySourceReceiver.Companion.executeSafetyCenterIssueActionWithPermissionAndWait import com.android.safetycenter.testing.SafetySourceReceiver.Companion.refreshSafetySourcesWithReceiverPermissionAndWait import com.android.safetycenter.testing.SafetySourceTestData +import com.android.safetycenter.testing.SafetySourceTestData.Companion.CRITICAL_ISSUE_ACTION_ID +import com.android.safetycenter.testing.SafetySourceTestData.Companion.CRITICAL_ISSUE_ID import org.junit.Before import org.junit.Rule import org.junit.Test @@ -139,6 +144,16 @@ class SafetySourceStateCollectedLoggingHelperTests { ) } + @Test + fun resolvingAction_success() { + simulateResolvingActionWith(Response.SetData(safetySourceTestData.information)) + } + + @Test + fun resolvingAction_error() { + simulateResolvingActionWith(Response.Error) + } + private fun simulateRefresh( source1Response: Response?, source2Response: Response?, @@ -167,4 +182,22 @@ class SafetySourceStateCollectedLoggingHelperTests { safetyCenterManager.refreshSafetySourcesWithReceiverPermissionAndWait(refreshReason) listener.waitForSafetyCenterRefresh() } + + private fun simulateResolvingActionWith(response: Response) { + safetyCenterTestHelper.setConfig(safetyCenterTestConfigs.singleSourceConfig) + safetyCenterTestHelper.setData( + SINGLE_SOURCE_ID, + safetySourceTestData.criticalWithResolvingGeneralIssue + ) + SafetySourceReceiver.setResponse(Request.ResolveAction(SINGLE_SOURCE_ID), response) + + safetyCenterManager.executeSafetyCenterIssueActionWithPermissionAndWait( + SafetyCenterTestData.issueId(SINGLE_SOURCE_ID, CRITICAL_ISSUE_ID), + SafetyCenterTestData.issueActionId( + SINGLE_SOURCE_ID, + CRITICAL_ISSUE_ID, + CRITICAL_ISSUE_ACTION_ID + ) + ) + } } diff --git a/tests/hostside/safetycenter/src/android/safetycenter/hostside/SafetyCenterSystemEventReportedLoggingHostTest.kt b/tests/hostside/safetycenter/src/android/safetycenter/hostside/SafetyCenterSystemEventReportedLoggingHostTest.kt index 0baf1f5d5..2589c7a47 100644 --- a/tests/hostside/safetycenter/src/android/safetycenter/hostside/SafetyCenterSystemEventReportedLoggingHostTest.kt +++ b/tests/hostside/safetycenter/src/android/safetycenter/hostside/SafetyCenterSystemEventReportedLoggingHostTest.kt @@ -194,6 +194,38 @@ class SafetyCenterSystemEventReportedLoggingHostTest : BaseHostJUnit4Test() { .isEqualTo(1) // Only source 1 } + @Test + fun resolveAction_success_resolvingActionSuccessEvent() { + helperAppRule.runTest( + ".SafetySourceStateCollectedLoggingHelperTests", + "resolvingAction_success" + ) + + val resolvingActionEvent = + ReportUtils.getEventMetricDataList(device) + .mapNotNull { it.atom.safetyCenterSystemEventReported } + .single { it.eventType == EventType.INLINE_ACTION } + + assertThat(resolvingActionEvent.result).isEqualTo(Result.SUCCESS) + assertThat(resolvingActionEvent.encodedIssueTypeId).isNotEqualTo(0) + } + + @Test + fun resolveAction_error_resolvingActionErrorEvent() { + helperAppRule.runTest( + ".SafetySourceStateCollectedLoggingHelperTests", + "resolvingAction_error" + ) + + val resolvingActionEvent = + ReportUtils.getEventMetricDataList(device) + .mapNotNull { it.atom.safetyCenterSystemEventReported } + .single { it.eventType == EventType.INLINE_ACTION } + + assertThat(resolvingActionEvent.result).isEqualTo(Result.ERROR) + assertThat(resolvingActionEvent.encodedIssueTypeId).isNotEqualTo(0) + } + companion object { private const val REFRESH_REASON_PAGE_OPEN = 100L private const val REFRESH_REASON_BUTTON_CLICK = 200L |