Open Bug 2063540 Opened 3 months ago Updated 3 months ago

Add a WorkManager-driven integration test for PrivacyReportNotificationWorker that verifies the notification is actually shown

Categories

(Firefox for Android :: Experimentation and Telemetry, task)

All
Android
task

Tracking

()

People

(Reporter: towhite, Unassigned)

References

Details

(Whiteboard: [fxdroid] [android-activation-trust] [good-next-bug])

Follow-up from review of Bug 2060524 (weekly privacy report notification).

PrivacyReportNotificationWorkerTest currently unit-tests doWork() directly by constructing the worker with TestListenableWorkerBuilder and calling worker.doWork() in-process. This never exercises the actual WorkManager scheduling/execution path, and no test in the suite asserts on NotificationManager state as a result of the work actually running end-to-end.

The review comment on D317464 suggested adding a more integration-style test: schedule the work via PrivacyReportNotificationWorker.schedule(...), use the WorkManager testing library's TestDriver (via WorkManagerTestInitHelper.getTestDriver(context)) to satisfy the constraints/period-delay needed for the periodic work to actually run, and then ask the NotificationManager (e.g. shadowOf(notificationManager).activeNotifications) which notifications are showing, to confirm the notification was posted end-to-end rather than just asserting on Result.success() and mock call counts.

See https://developer.android.com/develop/background-work/background-tasks/testing/persistent/integration-testing for background on the TestDriver approach.

You need to log in before you can comment on or make changes to this bug.