
org.robolectric.shadows.ShadowAsyncTaskBridge Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of framework Show documentation
Show all versions of framework Show documentation
An alternative Android testing framework.
The newest version!
package org.robolectric.shadows;
import android.os.AsyncTask;
import org.robolectric.annotation.internal.DoNotInstrument;
import org.robolectric.util.ReflectionHelpers;
import org.robolectric.util.ReflectionHelpers.ClassParameter;
/**
* Bridge between shadows and {@link android.os.AsyncTask}.
*/
@DoNotInstrument
public class ShadowAsyncTaskBridge {
private AsyncTask asyncTask;
public ShadowAsyncTaskBridge(AsyncTask asyncTask) {
this.asyncTask = asyncTask;
}
public Result doInBackground(Params... params) {
return ReflectionHelpers.callInstanceMethod(asyncTask, "doInBackground", ClassParameter.from(Object[].class, params));
}
public void onPreExecute() {
ReflectionHelpers.callInstanceMethod(asyncTask, "onPreExecute");
}
public void onPostExecute(Result result) {
ReflectionHelpers.callInstanceMethod(asyncTask, "onPostExecute", ClassParameter.from(Object.class, result));
}
public void onProgressUpdate(Progress... values) {
ReflectionHelpers.callInstanceMethod(asyncTask, "onProgressUpdate", ClassParameter.from(Object[].class, values));
}
public void onCancelled() {
ReflectionHelpers.callInstanceMethod(asyncTask, "onCancelled");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy