Prevent user switching on driver display during CtsAppWidgetTestCases for visible background user
When testing CtsAppWidgetTestCases for the current user and
the visible background user, all tests pass.
However, when testing for the visible background user, some tests
result in the user being switched to the visible background user
on the driver display.
User switching occurs due to @RunWith(BedsteadJUnit4.class) and
DeviceState#apply() if the RequireRunOn annotation is not present
in AppWidgetManagerTest.
Not only in AppWidgetManagerTest but also in other tests (e.g.,
EventLibTest), modifications are needed to prevent user switching
when testing with the visible background user.
Test fixes include:
- Modify the system to prevent user switching on the driver display,
if the instrumented user is the visible background user.
Fixed test list:
android.appwidget.cts.AppWidgetManagerTest#testAppWidgetManagerNotNullFromContext
android.appwidget.cts.AppWidgetManagerTest#testAppWidgetManagerNotNull
Bug: 348864476
Test: atest CtsAppWidgetTestCases
Test: atest --user-type secondary_user_on_secondary_display CtsAppWidgetTestCases
(cherry picked from https://partner-android-review.googlesource.com/q/commit:c95b88ec90235aa317a2e9ae6b73000fc22dd308)
Change-Id: Ifb93c69bdafad0e24c6df6cf62b47701035cf669
2 files changed