Move slow set/unset PO and DO tests out of CTS and into Nene Tests.
Fixes: 230218709
Test: atest android.devicepolicy.cts.DevicePolicyManagerTest
Test: atest com.android.bedstead.nene.devicepolicy.DeviceOwnerTest
Test: atest com.android.bedstead.nene.devicepolicy.ProfileOwnerTest
Change-Id: I42c17ae133bf7cd1608e678bab681cdfd60cb27d
Merged-In: I42c17ae133bf7cd1608e678bab681cdfd60cb27d
diff --git a/common/device-side/bedstead/nene/src/test/java/com/android/bedstead/nene/devicepolicy/DeviceOwnerTest.java b/common/device-side/bedstead/nene/src/test/java/com/android/bedstead/nene/devicepolicy/DeviceOwnerTest.java
index f19cc7a..067a743 100644
--- a/common/device-side/bedstead/nene/src/test/java/com/android/bedstead/nene/devicepolicy/DeviceOwnerTest.java
+++ b/common/device-side/bedstead/nene/src/test/java/com/android/bedstead/nene/devicepolicy/DeviceOwnerTest.java
@@ -94,4 +94,16 @@
assertThat(TestApis.devicePolicy().getDeviceOwner()).isNull();
}
}
+
+ @Test
+ @EnsureHasNoDpc
+ public void setAndRemoveDeviceOwnerRepeatedly_doesNotThrowError() {
+ try (TestAppInstance dpc = sNonTestOnlyDpc.install()) {
+ for (int i = 0; i < 100; i++) {
+ DeviceOwner deviceOwner = TestApis.devicePolicy()
+ .setDeviceOwner(NON_TEST_ONLY_DPC_COMPONENT_NAME);
+ deviceOwner.remove();
+ }
+ }
+ }
}
diff --git a/common/device-side/bedstead/nene/src/test/java/com/android/bedstead/nene/devicepolicy/ProfileOwnerTest.java b/common/device-side/bedstead/nene/src/test/java/com/android/bedstead/nene/devicepolicy/ProfileOwnerTest.java
index f2f460c..b69e2ee 100644
--- a/common/device-side/bedstead/nene/src/test/java/com/android/bedstead/nene/devicepolicy/ProfileOwnerTest.java
+++ b/common/device-side/bedstead/nene/src/test/java/com/android/bedstead/nene/devicepolicy/ProfileOwnerTest.java
@@ -27,8 +27,10 @@
import com.android.bedstead.harrier.BedsteadJUnit4;
import com.android.bedstead.harrier.DeviceState;
import com.android.bedstead.harrier.annotations.EnsureHasPermission;
+import com.android.bedstead.harrier.annotations.EnsureHasNoWorkProfile;
import com.android.bedstead.harrier.annotations.EnsureHasSecondaryUser;
import com.android.bedstead.harrier.annotations.RequireRunNotOnSecondaryUser;
+import com.android.bedstead.harrier.annotations.RequireRunOnPrimaryUser;
import com.android.bedstead.harrier.annotations.RequireRunOnWorkProfile;
import com.android.bedstead.harrier.annotations.RequireSdkVersion;
import com.android.bedstead.harrier.annotations.enterprise.EnsureHasNoDpc;
@@ -113,6 +115,22 @@
}
@Test
+ @EnsureHasNoDpc
+ @EnsureHasNoWorkProfile
+ @RequireRunOnPrimaryUser
+ public void setAndRemoveProfileOwnerRepeatedly_doesNotThrowError() {
+ try (UserReference profile = TestApis.users().createUser().createAndStart()) {
+ try (TestAppInstance dpc = sNonTestOnlyDpc.install()) {
+ for (int i = 0; i < 100; i++) {
+ ProfileOwner profileOwner = TestApis.devicePolicy().setProfileOwner(
+ TestApis.users().instrumented(), NON_TEST_ONLY_DPC_COMPONENT_NAME);
+ profileOwner.remove();
+ }
+ }
+ }
+ }
+
+ @Test
@EnsureHasSecondaryUser
@RequireRunNotOnSecondaryUser
public void remove_onOtherUser_removesProfileOwner() {
diff --git a/tests/devicepolicy/src/android/devicepolicy/cts/DevicePolicyManagerTest.java b/tests/devicepolicy/src/android/devicepolicy/cts/DevicePolicyManagerTest.java
index f0e7e83..ec95ddd 100644
--- a/tests/devicepolicy/src/android/devicepolicy/cts/DevicePolicyManagerTest.java
+++ b/tests/devicepolicy/src/android/devicepolicy/cts/DevicePolicyManagerTest.java
@@ -97,16 +97,12 @@
import com.android.bedstead.harrier.annotations.enterprise.EnsureHasNoProfileOwner;
import com.android.bedstead.harrier.annotations.enterprise.EnsureHasProfileOwner;
import com.android.bedstead.nene.TestApis;
-import com.android.bedstead.nene.devicepolicy.DeviceOwner;
-import com.android.bedstead.nene.devicepolicy.ProfileOwner;
import com.android.bedstead.nene.packages.Package;
import com.android.bedstead.nene.permissions.PermissionContext;
import com.android.bedstead.nene.users.UserReference;
import com.android.bedstead.nene.users.UserType;
import com.android.bedstead.remotedpc.RemoteDpc;
-import com.android.bedstead.testapp.TestApp;
import com.android.bedstead.testapp.TestAppInstance;
-import com.android.bedstead.testapp.TestAppProvider;
import com.android.compatibility.common.util.SystemUtil;
import com.android.eventlib.events.broadcastreceivers.BroadcastReceivedEvent;
@@ -200,12 +196,6 @@
private static final Bundle EXPECTED_BUNDLE_WITH_PACKAGE_NAME =
createExpectedBundleWithPackageName();
- private static final TestAppProvider sTestAppProvider = new TestAppProvider();
- private static final TestApp sDpcApp = sTestAppProvider.query()
- .whereIsDeviceAdmin().isTrue()
- .whereTestOnly().isFalse()
- .get();
-
private static final PersistableBundle ADMIN_EXTRAS_BUNDLE = createAdminExtrasBundle();
private static final PersistableBundle ROLE_HOLDER_EXTRAS_BUNDLE =
createRoleHolderExtrasBundle();
@@ -233,40 +223,6 @@
}
}
- @Test
- @EnsureHasNoDpc
- public void setAndRemoveDeviceOwnerRepeatedly_doesNotThrowError() {
- try (TestAppInstance dpcInstance = sDpcApp.install()) {
- ComponentName dpcComponentName = new ComponentName(sDpcApp.packageName(),
- sDpcApp.packageName() + ".DeviceAdminReceiver");
-
- for (int i = 0; i < 100; i++) {
- DeviceOwner deviceOwner = TestApis.devicePolicy().setDeviceOwner(dpcComponentName);
- deviceOwner.remove();
- }
- }
- }
-
- @Test
- @EnsureHasNoDpc
- @EnsureHasNoWorkProfile
- @RequireRunOnPrimaryUser
- public void setAndRemoveProfileOwnerRepeatedly_doesNotThrowError() {
- try (UserReference profile = TestApis.users().createUser().createAndStart()) {
- try (TestAppInstance dpcInstance = sDpcApp.install(profile)) {
- ComponentName dpcComponentName = new ComponentName(sDpcApp.packageName(),
- sDpcApp.packageName() + ".DeviceAdminReceiver");
-
- for (int i = 0; i < 100; i++) {
- ProfileOwner profileOwner = TestApis.devicePolicy().setProfileOwner(
- profile, dpcComponentName);
-
- profileOwner.remove();
- }
- }
- }
- }
-
@RequireRunOnPrimaryUser
@EnsureHasNoDpc
@RequireFeature(FEATURE_DEVICE_ADMIN)