FileDocCategorySizeDatePackage
DeviceOwnerTest.javaAPI DocAndroid 5.1 API3701Thu Mar 12 22:22:42 GMT 2015com.android.server.devicepolicy

DeviceOwnerTest

public 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
Constructors Summary
Methods Summary
public voidtestDeviceAndProfileOwners()

        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 voidtestDeviceOwnerOnly()


    
         
        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 voidtestProfileOwnerOnly()

        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));