Bug 1019793 - Avoid UnsupportedOperationException in TestHealthReportPruneService. r=mcomella

========

ce21e7f19a
Author: Nick Alexander <nalexander@mozilla.com>
Date:   Wed Jun 4 14:15:09 2014 -0700

    Bug 1019793 - Always upload in TestHealthReportUploadService.

========

e4c7393c6f
Author: Nick Alexander <nalexander@mozilla.com>
Date:   Tue Jun 3 15:47:33 2014 -0700

    Bug 1019793 - Don't create storage in TestHealthReportPruneService.

    Creating real storage requires a valid Context, and in this test, we
    only have MockContext.
This commit is contained in:
Nick Alexander 2014-06-21 15:42:44 -07:00
parent 1cc245ea64
commit f718c2014c
2 changed files with 10 additions and 2 deletions

View File

@ -10,7 +10,6 @@ import org.mozilla.gecko.background.helpers.BackgroundServiceTestCase;
import android.content.Intent;
import android.content.SharedPreferences;
import android.test.mock.MockContext;
public class TestHealthReportPruneService
extends BackgroundServiceTestCase<TestHealthReportPruneService.MockHealthReportPruneService> {
@ -37,7 +36,10 @@ public class TestHealthReportPruneService
@Override
public PrunePolicy getPrunePolicy(final String profilePath) {
final PrunePolicyStorage storage = new PrunePolicyDatabaseStorage(new MockContext(), profilePath);
// We don't actually need any storage, so just make it null. Actually
// creating storage requires a valid context; here, we only have a
// MockContext.
final PrunePolicyStorage storage = null;
prunePolicy = new MockPrunePolicy(storage, getSharedPreferences());
return prunePolicy;
}

View File

@ -21,6 +21,12 @@ public class TestHealthReportUploadService
GlobalConstants.SHARED_PREFERENCES_MODE);
}
@Override
public boolean backgroundDataIsEnabled() {
// When testing, we always want to say we can upload.
return true;
}
@Override
public void onHandleIntent(Intent intent) {
super.onHandleIntent(intent);