// Path: android/Commons/src/triaina/commons/utils/AsyncTaskUtils.java
// public final class AsyncTaskUtils {
//     private AsyncTaskUtils() {}
// 
//     /** Returns whether the task specified as an argument is running or not.
//      * @param theTask {@link AsyncTask} to be checked.
//      * @return True if the task is running, false otherwise.
//      */
//     public static boolean isRunning(final AsyncTask<?, ?, ?> theTask) {
//         return (theTask != null && 
//                 theTask.getStatus().equals(AsyncTask.Status.RUNNING));
//     }
// 
//     /**
//      * Abort the running task.
//      *
//      * @param theTask
//      * @return True if the task has been successfully aborted. False otherwise.
//      */
//     public static boolean abort(AsyncTask<?, ?, ?> theTask) {
//         if (!AsyncTaskUtils.isRunning(theTask)) {
//             return false;
//         }
//         theTask.cancel(true);
//         theTask = null;
//         return true;
//     }
// }


import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import triaina.commons.utils.AsyncTaskUtils;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.test.AndroidTestCase;
        }
        public void checkPoint() {
            checkLatch.countDown();
        }
        public void waitForEnd() throws InterruptedException {
            endLatch.await(5000, TimeUnit.MILLISECONDS);
        }
        public boolean isEnded() {
            return endLatch.getCount() == 0;
        }
        private class TestTask extends AsyncTask<Void, Void, Void> {
            @Override
            protected Void doInBackground(Void... params) {
                startLatch.countDown();
                try {
                    checkLatch.await(5000, TimeUnit.MILLISECONDS);
                } catch (InterruptedException e) {
                    fail("interrupted");
                }
                return null;
            }
            @Override
            protected void onPostExecute(Void result) {
                super.onPostExecute(result);
                endLatch.countDown();
            }
        };
    }
    
    public void testIsRunning() {
// Path: android/Commons/src/triaina/commons/utils/AsyncTaskUtils.java
// public final class AsyncTaskUtils {
//     private AsyncTaskUtils() {}
// 
//     /** Returns whether the task specified as an argument is running or not.
//      * @param theTask {@link AsyncTask} to be checked.
//      * @return True if the task is running, false otherwise.
//      */
//     public static boolean isRunning(final AsyncTask<?, ?, ?> theTask) {
//         return (theTask != null && 
//                 theTask.getStatus().equals(AsyncTask.Status.RUNNING));
//     }
// 
//     /**
//      * Abort the running task.
//      *
//      * @param theTask
//      * @return True if the task has been successfully aborted. False otherwise.
//      */
//     public static boolean abort(AsyncTask<?, ?, ?> theTask) {
//         if (!AsyncTaskUtils.isRunning(theTask)) {
//             return false;
//         }
//         theTask.cancel(true);
//         theTask = null;
//         return true;
//     }
// }


// Path: android/Commons/tests/java/triaina/commons/test/utils/AsyncTaskUtilsTest.java
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import triaina.commons.utils.AsyncTaskUtils;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.test.AndroidTestCase;

        }
        public void checkPoint() {
            checkLatch.countDown();
        }
        public void waitForEnd() throws InterruptedException {
            endLatch.await(5000, TimeUnit.MILLISECONDS);
        }
        public boolean isEnded() {
            return endLatch.getCount() == 0;
        }
        private class TestTask extends AsyncTask<Void, Void, Void> {
            @Override
            protected Void doInBackground(Void... params) {
                startLatch.countDown();
                try {
                    checkLatch.await(5000, TimeUnit.MILLISECONDS);
                } catch (InterruptedException e) {
                    fail("interrupted");
                }
                return null;
            }
            @Override
            protected void onPostExecute(Void result) {
                super.onPostExecute(result);
                endLatch.countDown();
            }
        };
    }
    
    public void testIsRunning() {
        assertFalse("null is false", AsyncTaskUtils.isRunning(null));