DeviceOwnerTestpublic class DeviceOwnerTest extends android.test.AndroidTestCase Tests for the DeviceOwner object that saves & loads device and policy owner information.
run this test with:
make -j FrameworksServicesTests
runtest --path frameworks/base/services/tests/servicestests/ \
src/com/android/server/devicepolicy/DeviceOwnerTest.java |
Fields Summary |
---|
private ByteArrayInputStream | mInputStreamForTest | private ByteArrayOutputStream | mOutputStreamForTest |
Methods Summary |
---|
public void | testDeviceAndProfileOwners()
DeviceOwner out = new DeviceOwner(null, mOutputStreamForTest);
out.setDeviceOwner("some.device.owner.package", "owner");
out.setProfileOwner("some.profile.owner.package", "some-company", 1);
out.setProfileOwner("some.other.profile.owner", "some-other-company", 2);
out.writeOwnerFile();
mInputStreamForTest = new ByteArrayInputStream(mOutputStreamForTest.toByteArray());
DeviceOwner in = new DeviceOwner(mInputStreamForTest, null);
in.readOwnerFile();
assertEquals("some.device.owner.package", in.getDeviceOwnerPackageName());
assertEquals("owner", in.getDeviceOwnerName());
assertEquals("some.profile.owner.package", in.getProfileOwnerPackageName(1));
assertEquals("some-company", in.getProfileOwnerName(1));
assertEquals("some.other.profile.owner", in.getProfileOwnerPackageName(2));
assertEquals("some-other-company", in.getProfileOwnerName(2));
| public void | testDeviceOwnerOnly()
DeviceOwner out = new DeviceOwner(null, mOutputStreamForTest);
out.setDeviceOwner("some.device.owner.package", "owner");
out.writeOwnerFile();
mInputStreamForTest = new ByteArrayInputStream(mOutputStreamForTest.toByteArray());
DeviceOwner in = new DeviceOwner(mInputStreamForTest, null);
in.readOwnerFile();
assertEquals("some.device.owner.package", in.getDeviceOwnerPackageName());
assertEquals("owner", in.getDeviceOwnerName());
assertNull(in.getProfileOwnerPackageName(1));
| public void | testProfileOwnerOnly()
DeviceOwner out = new DeviceOwner(null, mOutputStreamForTest);
out.setProfileOwner("some.profile.owner.package", "some-company", 1);
out.writeOwnerFile();
mInputStreamForTest = new ByteArrayInputStream(mOutputStreamForTest.toByteArray());
DeviceOwner in = new DeviceOwner(mInputStreamForTest, null);
in.readOwnerFile();
assertNull(in.getDeviceOwnerPackageName());
assertNull(in.getDeviceOwnerName());
assertEquals("some.profile.owner.package", in.getProfileOwnerPackageName(1));
assertEquals("some-company", in.getProfileOwnerName(1));
|
|