本文整理汇总了Java中rx.subjects.TestSubject.onError方法的典型用法代码示例。如果您正苦于以下问题:Java TestSubject.onError方法的具体用法?Java TestSubject.onError怎么用?Java TestSubject.onError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.subjects.TestSubject
的用法示例。
在下文中一共展示了TestSubject.onError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onErrorCallsCallback
import rx.subjects.TestSubject; //导入方法依赖的package包/类
@Test
public void onErrorCallsCallback() {
TestSubject<String> subject = TestSubject.create(scheduler);
Loader.Callbacks<Result<String>> callbacks = mock(Loader.Callbacks.class);
Exception error = new Exception();
RxLoader<String> loader = new RxLoader<>(subject);
loader.setCallbacks(callbacks);
loader.start();
subject.onError(error);
scheduler.triggerActions();
verify(callbacks).onLoaderStart();
verify(callbacks).onLoaderResult(Result.<String>error(error));
verify(callbacks).onLoaderComplete();
}
示例2: testLoaderStartRotationError
import rx.subjects.TestSubject; //导入方法依赖的package包/类
@SmallTest
public void testLoaderStartRotationError() throws InterruptedException {
TestSubject<String> subject = TestSubject.create(testScheduler);
createLoader(getActivity(), subject).start();
getActivity().waitForStarted();
subject.onError(new Exception("test"));
testScheduler.triggerActions();
getActivity().waitForError();
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
getActivity().recreate();
}
});
createLoader(getActivity(), subject);
getActivity().waitForError();
assertThat(getActivity().<String>getError()).hasMessage("test").as("onError() is called again after a configuration change");
}
示例3: onErrorCallsCallback
import rx.subjects.TestSubject; //导入方法依赖的package包/类
@Test
public void onErrorCallsCallback() {
TestSubject<String> subject = TestSubject.create(scheduler);
Loader.Callbacks<String> callbacks = mock(Loader.Callbacks.class);
Exception error = new Exception();
RxLoader<String> loader = new RxLoader<>(subject);
loader.setCallbacks(callbacks);
loader.start();
subject.onError(error);
scheduler.triggerActions();
verify(callbacks).onLoaderStart();
verify(callbacks).onLoaderError(error);
}
示例4: testLoaderStartError
import rx.subjects.TestSubject; //导入方法依赖的package包/类
@SmallTest
public void testLoaderStartError() throws InterruptedException {
TestSubject<String> subject = TestSubject.create(testScheduler);
createLoader(getActivity(), subject).start();
getActivity().waitForStarted();
subject.onError(new Exception("test"));
subject.onCompleted();
testScheduler.triggerActions();
getActivity().waitForError();
assertThat(getActivity().<String>getError()).hasMessage("test").as("onError() is called when sent by observable");
}