Add test to verify PackageMonitorCallbackHelper for user removal

Bug: 29385425
Test: atest PackageMonitorCallbackHelperTest --iterations 100

Change-Id: I977cd1b7b425a6258bb7aa5f762b3ca9cc2619c0
This commit is contained in:
Joanne Chung
2023-07-07 10:21:56 +00:00
parent 9cd80779e1
commit 2b07c54afe

View File

@@ -221,6 +221,19 @@ public class PackageMonitorCallbackHelperTest {
assertThat(pkgNames[0]).isEqualTo(FAKE_PACKAGE_NAME);
}
@Test
public void testPackageMonitorCallback_onUserRemoved_callbackNotCalled() throws Exception {
IRemoteCallback callback = createMockPackageMonitorCallback();
mPackageMonitorCallbackHelper.registerPackageMonitorCallback(callback, 10 /* userId */);
mPackageMonitorCallbackHelper.onUserRemoved(10);
mPackageMonitorCallbackHelper.notifyPackageMonitor(Intent.ACTION_PACKAGE_ADDED,
FAKE_PACKAGE_NAME, createFakeBundle(), new int[]{10} /* userIds */,
null /* instantUserIds */);
verify(callback, after(WAIT_CALLBACK_CALLED_IN_MS).never()).sendResult(any());
}
private IRemoteCallback createMockPackageMonitorCallback() {
return spy(new IRemoteCallback.Stub() {
@Override