Mark otherwise unused method as @VisibleForTesting
Also fix spelling cancellAllInterrupt -> cancelAllInterrupt
b/13082964
Change-Id: I2fef949bb351a536fdd0d7058b3df2b03eecb39e
diff --git a/emailcommon/src/com/android/emailcommon/utility/EmailAsyncTask.java b/emailcommon/src/com/android/emailcommon/utility/EmailAsyncTask.java
index 3d2e69c..e0db427 100644
--- a/emailcommon/src/com/android/emailcommon/utility/EmailAsyncTask.java
+++ b/emailcommon/src/com/android/emailcommon/utility/EmailAsyncTask.java
@@ -18,6 +18,8 @@
import android.os.AsyncTask;
+import com.google.common.annotations.VisibleForTesting;
+
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.concurrent.ExecutionException;
@@ -31,7 +33,7 @@
* in onDestroy() or similar places.
* - Instead of {@link AsyncTask#onPostExecute}, it has {@link #onSuccess(Object)}, as the
* regular {@link AsyncTask#onPostExecute} is a bit hard to predict when it'll be called and
- * whel it won't.
+ * when it won't.
*
* Note this class is missing some of the {@link AsyncTask} features, e.g. it lacks
* {@link AsyncTask#onProgressUpdate}. Add these when necessary.
@@ -43,7 +45,7 @@
/**
* Tracks {@link EmailAsyncTask}.
*
- * Call {@link #cancellAllInterrupt()} to cancel all tasks registered.
+ * Call {@link #cancelAllInterrupt()} to cancel all tasks registered.
*/
public static class Tracker {
private final LinkedList<EmailAsyncTask<?, ?, ?>> mTasks =
@@ -64,7 +66,8 @@
/**
* Cancel all registered tasks.
*/
- public void cancellAllInterrupt() {
+ @VisibleForTesting
+ public void cancelAllInterrupt() {
synchronized (mTasks) {
for (EmailAsyncTask<?, ?, ?> task : mTasks) {
task.cancel(true);
@@ -212,7 +215,7 @@
return executeInternal(SERIAL_EXECUTOR, true, params);
}
- private final EmailAsyncTask<Params, Progress, Result> executeInternal(Executor executor,
+ private EmailAsyncTask<Params, Progress, Result> executeInternal(Executor executor,
boolean cancelPrevious, Params... params) {
if (cancelPrevious) {
if (mTracker == null) {
diff --git a/tests/src/com/android/emailcommon/utility/EmailAsyncTaskTests.java b/tests/src/com/android/emailcommon/utility/EmailAsyncTaskTests.java
index 1413e9f..41064aa 100644
--- a/tests/src/com/android/emailcommon/utility/EmailAsyncTaskTests.java
+++ b/tests/src/com/android/emailcommon/utility/EmailAsyncTaskTests.java
@@ -16,8 +16,6 @@
package com.android.emailcommon.utility;
-import com.android.emailcommon.utility.EmailAsyncTask.Tracker;
-
import android.test.AndroidTestCase;
import android.test.MoreAsserts;
@@ -70,7 +68,7 @@
// Task 2 and 4 are still registered.
// Cancel all left
- tracker.cancellAllInterrupt();
+ tracker.cancelAllInterrupt();
// Check if they're canceled
assertEquals(0, tracker.getTaskCountForTest());