Fix backup test permissions

pull/467/head
Alex Baker 9 years ago
parent 5cf24dd381
commit 67a2fd987e

@ -5,6 +5,8 @@ import android.content.Context;
import com.todoroo.astrid.dao.Database; import com.todoroo.astrid.dao.Database;
import org.tasks.analytics.Tracker; import org.tasks.analytics.Tracker;
import org.tasks.preferences.PermissionChecker;
import org.tasks.preferences.PermissivePermissionChecker;
import dagger.Module; import dagger.Module;
import dagger.Provides; import dagger.Provides;
@ -36,4 +38,9 @@ public class TestModule {
public Context getContext() { public Context getContext() {
return context; return context;
} }
@Provides
public PermissionChecker getPermissionChecker() {
return new PermissivePermissionChecker(context);
}
} }

@ -0,0 +1,41 @@
package org.tasks.preferences;
import android.content.Context;
import org.tasks.injection.ForApplication;
public class PermissivePermissionChecker extends PermissionChecker {
public PermissivePermissionChecker(@ForApplication Context context) {
super(context);
}
@Override
public boolean canAccessCalendars() {
return true;
}
@Override
public boolean canWriteToExternalStorage() {
return true;
}
@Override
public boolean canAccessAccounts() {
return true;
}
@Override
public boolean canAccessLocation() {
return true;
}
@Override
public boolean canAccessMic() {
return true;
}
@Override
public boolean canAccessMissedCallPermissions() {
return true;
}
}

@ -25,7 +25,7 @@ import java.io.IOException;
import javax.inject.Inject; import javax.inject.Inject;
import static android.support.test.InstrumentationRegistry.getContext; import static android.support.test.InstrumentationRegistry.getTargetContext;
import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.assertTrue;
@ -91,7 +91,7 @@ public class BackupServiceTests extends DatabaseTestCase {
// create a backup // create a backup
BackupIntentService service = new BackupIntentService(); BackupIntentService service = new BackupIntentService();
service.testBackup(xmlExporter, preferences, getContext()); service.testBackup(xmlExporter, preferences, getTargetContext());
AndroidUtilities.sleepDeep(BACKUP_WAIT_TIME); AndroidUtilities.sleepDeep(BACKUP_WAIT_TIME);
@ -129,7 +129,7 @@ public class BackupServiceTests extends DatabaseTestCase {
// backup // backup
BackupIntentService service = new BackupIntentService(); BackupIntentService service = new BackupIntentService();
service.testBackup(xmlExporter, preferences, getContext()); service.testBackup(xmlExporter, preferences, getTargetContext());
AndroidUtilities.sleepDeep(BACKUP_WAIT_TIME); AndroidUtilities.sleepDeep(BACKUP_WAIT_TIME);
@ -138,7 +138,7 @@ public class BackupServiceTests extends DatabaseTestCase {
assertFalse(files[4].exists()); assertFalse(files[4].exists());
// assert user file still exists // assert user file still exists
service.testBackup(xmlExporter, preferences, getContext()); service.testBackup(xmlExporter, preferences, getTargetContext());
assertTrue(myFile.exists()); assertTrue(myFile.exists());
} }
} }

Loading…
Cancel
Save