use of com.android.example.devsummit.archdemo.util.LifecycleProvider in project dev-summit-architecture-demo by yigit.
the class AutoCancelAsyncTaskTest method unregisterAfterCompletion.
@Test
public void unregisterAfterCompletion() {
Executor mockExecutor = new Executor() {
@Override
public void execute(Runnable command) {
command.run();
}
};
LifecycleProvider provider = mock(LifecycleProvider.class);
doNothing().when(provider).addLifecycleListener(any(LifecycleListener.class));
AutoCancelAsyncTask<Void, Void> task = new AutoCancelAsyncTask<Void, Void>(provider) {
@Override
protected void onResult(Void aVoid) {
}
@Override
protected Void onDoInBackground(Void... params) {
return null;
}
};
task.executeOnExecutor(mockExecutor);
verify(provider).removeLifecycleListener(any(LifecycleListener.class));
}
use of com.android.example.devsummit.archdemo.util.LifecycleProvider in project dev-summit-architecture-demo by yigit.
the class AutoCancelAsyncTaskTest method unregisterOnCancel.
@Test
public void unregisterOnCancel() {
LifecycleProvider provider = mock(LifecycleProvider.class);
doNothing().when(provider).addLifecycleListener(any(LifecycleListener.class));
AutoCancelAsyncTask<Void, Void> task = new AutoCancelAsyncTask<Void, Void>(provider) {
@Override
protected void onResult(Void aVoid) {
}
@Override
protected Void onDoInBackground(Void... params) {
return null;
}
};
task.cancel(false);
verify(provider).removeLifecycleListener(any(LifecycleListener.class));
}
Aggregations