@Test
public void checkImageApiResponseFail() throws Exception {
MockWebServer mockWebServer = startMockWebServer();
//Success response for the info api
mockWebServer.enqueue(new MockResponse()
.setResponseCode(200)
.setBody(getStringFromFile(InstrumentationRegistry.getInstrumentation().getContext(),
com.kevalpatel2106.smartlens.test.R.raw.wiki_info_success_response)));
//Fail response for the image api.
mockWebServer.enqueue(new MockResponse().setResponseCode(500));
openActivity();
//Wait for mock api
Delay.startDelay(TestConfig.DELAY_FOR_MOCK_API);
onView(withId(R.id.root_view)).perform(ViewActions.closeSoftKeyboard());
//Check if there are text?
assertTrue(mWikiFragmentFragmentTestRule.getActivity().mViewFlipper.getDisplayedChild() ==
INFO_VIEW);
onView(withId(R.id.wiki_page_tv)).check(ViewAssertions.matches(CustomMatchers.hasText()));
onView(withId(R.id.wiki_page_iv)).check(ViewAssertions.matches(not(CustomMatchers.hasImage())));
Delay.stopDelay();
mockWebServer.shutdown();
}
InfoActivityTest.java 文件源码
java
阅读 20
收藏 0
点赞 0
评论 0
项目:smart-lens
作者:
评论列表
文章目录