зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1407046 - Migrate FileCleanupService to JobIntentService: Follow-up to for android-test. r=test-fix
This commit is contained in:
Родитель
6d59d60177
Коммит
86aa31b5f4
|
@ -6,6 +6,7 @@
|
|||
|
||||
package org.mozilla.gecko.cleanup;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.junit.Rule;
|
||||
|
@ -21,6 +22,7 @@ import java.util.List;
|
|||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests the methods of {@link FileCleanupService}.
|
||||
|
@ -43,8 +45,9 @@ public class TestFileCleanupService {
|
|||
}
|
||||
|
||||
private void onHandleIntent(final ArrayList<String> filePaths) {
|
||||
final Context context = mock(Context.class);
|
||||
final FileCleanupService service = new FileCleanupService();
|
||||
final Intent fileCleanupIntent = FileCleanupService.getFileCleanupIntent(filePaths);
|
||||
final Intent fileCleanupIntent = FileCleanupService.getFileCleanupIntent(context, filePaths);
|
||||
service.onHandleWork(fileCleanupIntent);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class FileCleanupController {
|
|||
recordCleanupScheduled(sharedPrefs);
|
||||
|
||||
final Intent fileCleanupIntent =
|
||||
FileCleanupService.getFileCleanupIntent(getFilesToCleanup(profilePath + "/"));
|
||||
FileCleanupService.getFileCleanupIntent(context, getFilesToCleanup(profilePath + "/"));
|
||||
FileCleanupService.enqueueWork(context, fileCleanupIntent);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ public class FileCleanupService extends JobIntentService {
|
|||
enqueueWork(context, FileCleanupService.class, JobIdsConstants.getIdForFileCleanupJob(), workIntent);
|
||||
}
|
||||
|
||||
public static Intent getFileCleanupIntent(ArrayList<String> filesToCleanup) {
|
||||
Intent intent = new Intent();
|
||||
public static Intent getFileCleanupIntent(Context context, ArrayList<String> filesToCleanup) {
|
||||
Intent intent = new Intent(context, FileCleanupService.class);
|
||||
intent.setAction(FileCleanupService.ACTION_DELETE_FILES);
|
||||
intent.putExtra(FileCleanupService.EXTRA_FILE_PATHS_TO_DELETE, filesToCleanup);
|
||||
return intent;
|
||||
|
|
Загрузка…
Ссылка в новой задаче