FileDocCategorySizeDatePackage
VerificationParamsTest.javaAPI DocAndroid 5.1 API10181Thu Mar 12 22:22:12 GMT 2015android.content.pm

VerificationParamsTest

public class VerificationParamsTest extends android.test.AndroidTestCase
Tests the android.content.pm.VerificationParams class To test run: ./development/testrunner/runtest.py frameworks-core -c android.content.pm.VerificationParamsTest

Fields Summary
private static final String
VERIFICATION_URI_STRING
private static final String
ORIGINATING_URI_STRING
private static final String
REFERRER_STRING
private static final byte[]
DIGEST_BYTES
private static final int
INSTALLER_UID
private static final android.net.Uri
VERIFICATION_URI
private static final android.net.Uri
ORIGINATING_URI
private static final android.net.Uri
REFERRER
private static final int
ORIGINATING_UID
private static final android.content.pm.ManifestDigest
MANIFEST_DIGEST
Constructors Summary
Methods Summary
public voidtestEquals_InstallerUid_Failure()

        VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
                REFERRER, ORIGINATING_UID, MANIFEST_DIGEST);

        VerificationParams params2 = new VerificationParams(
                Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING),
                Uri.parse(REFERRER_STRING), ORIGINATING_UID, new ManifestDigest(DIGEST_BYTES));
        params2.setInstallerUid(INSTALLER_UID);

        assertFalse(params1.equals(params2));
    
public voidtestEquals_ManifestDigest_Failure()

        VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
                REFERRER, ORIGINATING_UID, MANIFEST_DIGEST);

        VerificationParams params2 = new VerificationParams(
                Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING),
                Uri.parse(REFERRER_STRING), ORIGINATING_UID,
                new ManifestDigest("a different digest".getBytes()));

        assertFalse(params1.equals(params2));
    
public voidtestEquals_OriginatingUri_Failure()

        VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
                REFERRER, ORIGINATING_UID, MANIFEST_DIGEST);

        VerificationParams params2 = new VerificationParams(
                Uri.parse(VERIFICATION_URI_STRING), Uri.parse("http://a.different.uri/"),
                Uri.parse(REFERRER_STRING), ORIGINATING_UID, new ManifestDigest(DIGEST_BYTES));

        assertFalse(params1.equals(params2));
    
public voidtestEquals_Originating_Uid_Failure()

        VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
                REFERRER, ORIGINATING_UID, MANIFEST_DIGEST);

        VerificationParams params2 = new VerificationParams(
                Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING),
                Uri.parse(REFERRER_STRING), 12345, new ManifestDigest(DIGEST_BYTES));

        assertFalse(params1.equals(params2));
    
public voidtestEquals_Referrer_Failure()

        VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
                REFERRER, ORIGINATING_UID, MANIFEST_DIGEST);

        VerificationParams params2 = new VerificationParams(
                Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING),
                Uri.parse("http://a.different.uri/"), ORIGINATING_UID,
                new ManifestDigest(DIGEST_BYTES));

        assertFalse(params1.equals(params2));
    
public voidtestEquals_Success()

        VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
                REFERRER, ORIGINATING_UID, MANIFEST_DIGEST);

        VerificationParams params2 = new VerificationParams(
                Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING),
                Uri.parse(REFERRER_STRING), ORIGINATING_UID, new ManifestDigest(DIGEST_BYTES));

        assertEquals(params1, params2);
    
public voidtestEquals_VerificationUri_Failure()

        VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
                REFERRER, ORIGINATING_UID, MANIFEST_DIGEST);

        VerificationParams params2 = new VerificationParams(
                Uri.parse("http://a.different.uri/"), Uri.parse(ORIGINATING_URI_STRING),
                Uri.parse(REFERRER_STRING), ORIGINATING_UID, new ManifestDigest(DIGEST_BYTES));

        assertFalse(params1.equals(params2));
    
public voidtestHashCode_InstallerUid_Failure()

        VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
                REFERRER, ORIGINATING_UID, MANIFEST_DIGEST);

        VerificationParams params2 = new VerificationParams(
                Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING),
                Uri.parse(REFERRER_STRING), ORIGINATING_UID,
                new ManifestDigest("a different digest".getBytes()));
        params2.setInstallerUid(INSTALLER_UID);

        assertFalse(params1.hashCode() == params2.hashCode());
    
public voidtestHashCode_ManifestDigest_Failure()

        VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
                REFERRER, ORIGINATING_UID, MANIFEST_DIGEST);

        VerificationParams params2 = new VerificationParams(
                Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING),
                Uri.parse(REFERRER_STRING), ORIGINATING_UID,
                new ManifestDigest("a different digest".getBytes()));

        assertFalse(params1.hashCode() == params2.hashCode());
    
public voidtestHashCode_OriginatingUri_Failure()

        VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
                REFERRER, ORIGINATING_UID, MANIFEST_DIGEST);

        VerificationParams params2 = new VerificationParams(
                Uri.parse(VERIFICATION_URI_STRING), Uri.parse("http://a.different.uri/"),
                Uri.parse(REFERRER_STRING), ORIGINATING_UID, new ManifestDigest(DIGEST_BYTES));

        assertFalse(params1.hashCode() == params2.hashCode());
    
public voidtestHashCode_Originating_Uid_Failure()

        VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
                REFERRER, ORIGINATING_UID, MANIFEST_DIGEST);

        VerificationParams params2 = new VerificationParams(
                Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING),
                Uri.parse(REFERRER_STRING), 12345, new ManifestDigest(DIGEST_BYTES));

        assertFalse(params1.hashCode() == params2.hashCode());
    
public voidtestHashCode_Referrer_Failure()

        VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
                REFERRER, ORIGINATING_UID, MANIFEST_DIGEST);

        VerificationParams params2 = new VerificationParams(
                Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING), null,
                ORIGINATING_UID, new ManifestDigest(DIGEST_BYTES));

        assertFalse(params1.hashCode() == params2.hashCode());
    
public voidtestHashCode_Success()

        VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
                REFERRER, ORIGINATING_UID, MANIFEST_DIGEST);

        VerificationParams params2 = new VerificationParams(
                Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING),
                Uri.parse(REFERRER_STRING), ORIGINATING_UID, new ManifestDigest(DIGEST_BYTES));

        assertEquals(params1.hashCode(), params2.hashCode());
    
public voidtestHashCode_VerificationUri_Failure()

        VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
                REFERRER, ORIGINATING_UID, MANIFEST_DIGEST);

        VerificationParams params2 = new VerificationParams(null, Uri.parse(ORIGINATING_URI_STRING),
                Uri.parse(REFERRER_STRING), ORIGINATING_UID, new ManifestDigest(DIGEST_BYTES));

        assertFalse(params1.hashCode() == params2.hashCode());
    
public voidtestParcel()


         
        VerificationParams expected = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
                REFERRER, ORIGINATING_UID, MANIFEST_DIGEST);

        Parcel parcel = Parcel.obtain();
        expected.writeToParcel(parcel, 0);
        parcel.setDataPosition(0);

        VerificationParams actual = VerificationParams.CREATOR.createFromParcel(parcel);

        assertEquals(VERIFICATION_URI, actual.getVerificationURI());

        assertEquals(ORIGINATING_URI, actual.getOriginatingURI());

        assertEquals(REFERRER, actual.getReferrer());

        assertEquals(ORIGINATING_UID, actual.getOriginatingUid());

        assertEquals(MANIFEST_DIGEST, actual.getManifestDigest());