FileDocCategorySizeDatePackage
ManifestDigestTest.javaAPI DocAndroid 5.1 API2713Thu Mar 12 22:22:12 GMT 2015android.content.pm

ManifestDigestTest

public class ManifestDigestTest extends android.test.AndroidTestCase

Fields Summary
private static final byte[]
MESSAGE_1
Constructors Summary
Methods Summary
public voidtestManifestDigest_Equals()

        InputStream is = new ByteArrayInputStream(MESSAGE_1);

        ManifestDigest expected =
                new ManifestDigest(MessageDigest.getInstance("SHA-256").digest(MESSAGE_1));

        ManifestDigest actual = ManifestDigest.fromInputStream(is);
        assertEquals(expected, actual);

        ManifestDigest unexpected = new ManifestDigest(new byte[0]);
        assertFalse(unexpected.equals(actual));
    
public voidtestManifestDigest_FromInputStream_Null()


       
        assertNull("Attributes were null, so ManifestDigest.fromAttributes should return null",
                ManifestDigest.fromInputStream(null));
    
public voidtestManifestDigest_FromInputStream_ThrowsIoException()

        InputStream is = new InputStream() {
            @Override
            public int read() throws IOException {
                throw new IOException();
            }
        };

        assertNull("InputStream threw exception, so ManifestDigest should be null",
                ManifestDigest.fromInputStream(is));
    
public voidtestManifestDigest_Parcel()

        InputStream is = new ByteArrayInputStream(MESSAGE_1);

        ManifestDigest digest = ManifestDigest.fromInputStream(is);

        Parcel p = Parcel.obtain();
        digest.writeToParcel(p, 0);
        p.setDataPosition(0);

        ManifestDigest fromParcel = ManifestDigest.CREATOR.createFromParcel(p);

        assertEquals("ManifestDigest going through parceling should be the same as before: "
                + digest.toString() + " and " + fromParcel.toString(), digest,
                fromParcel);