@@ -0,0 +1,2419 @@
+package org.odk.collect.android.utilities;%0A%0Aimport org.hamcrest.Description;%0Aimport org.hamcrest.StringDescription;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.odk.collect.android.BuildConfig;%0Aimport org.robolectric.RobolectricTestRunner;%0Aimport org.robolectric.annotation.Config;%0Aimport org.robolectric.manifest.AndroidManifest;%0Aimport org.robolectric.res.Fs;%0A%0Aimport java.util.List;%0A%0A/**%0A * Test for checking permissions in %7B@link AndroidManifest%7D%0A */%0A@RunWith(RobolectricTestRunner.class)%0A@Config(constants = BuildConfig.class)%0Apublic class PermissionsTest %7B%0A%0A    @Test%0A    public void permissionCheck() %7B%0A        AndroidManifest androidManifest = new AndroidManifest(Fs.fileFromPath(%22build/intermediates/manifests/full/debug/AndroidManifest.xml%22), null, null);%0A        List%3CString%3E permissions = androidManifest.getUsedPermissions();%0A%0A        //List of expected permissions to be present in AndroidManifest.xml%0A        String%5B%5D expectedPermissions = %7B%22android.permission.READ_PHONE_STATE%22,%0A                %22android.permission.ACCESS_WIFI_STATE%22,%0A                %22android.permission.INTERNET%22,%0A                %22android.permission.ACCESS_FINE_LOCATION%22,%0A                %22android.permission.ACCESS_COARSE_LOCATION%22,%0A                %22android.permission.READ_EXTERNAL_STORAGE%22,%0A                %22android.permission.WRITE_EXTERNAL_STORAGE%22,%0A                %22android.permission.GET_ACCOUNTS%22,%0A                %22android.permission.USE_CREDENTIALS%22,%0A                %22android.permission.ACCESS_NETWORK_STATE%22,%0A                %22android.permission.MANAGE_ACCOUNTS%22,%0A                %22android.permission.WAKE_LOCK%22,%0A                %22org.odk.collect.android.permission.MAPS_RECEIVE%22,%0A                %22com.google.android.providers.gsf.permission.READ_GSERVICES%22%0A        %7D;%0A%0A        //Checking expected permissions one by one%0A        for (String permission : expectedPermissions) %7B%0A            if (!permissions.contains(permission)) %7B%0A                showError(permission);%0A            %7D%0A        %7D%0A    %7D%0A%0A    /**%0A     * Method to display missing permission error.%0A     */%0A    private void showError(String permission) %7B%0A        Description description = new StringDescription();%0A        description.appendText(%22Expected permission %22)%0A                .appendText(permission)%0A                .appendText(%22 is missing from AndroidManifest.xml%22);%0A%0A        throw new AssertionError(description.toString());%0A    %7D%0A%7D%0A%0A

Add test for checking permissions in AndroidManifest.xml (#492)