use of io.github.hidroh.materialistic.test.TestItem in project materialistic by hidroh.
the class WebFragmentLocalTest method testStory.
@Test
public void testStory() {
TestWebItem item = new TestWebItem() {
@NonNull
@Override
public String getType() {
return STORY_TYPE;
}
@Override
public String getId() {
return "1";
}
@Override
public String getUrl() {
return String.format(HackerNewsClient.WEB_ITEM_PATH, "1");
}
@Override
public String getDisplayedTitle() {
return "Ask HN";
}
};
Intent intent = new Intent();
intent.putExtra(WebActivity.EXTRA_ITEM, item);
controller.withIntent(intent).create().start().resume().visible();
verify(itemManager).getItem(eq("1"), eq(ItemManager.MODE_DEFAULT), listener.capture());
listener.getValue().onResponse(new TestItem() {
@Override
public String getText() {
return "text";
}
});
WebView webView = (WebView) activity.findViewById(R.id.web_view);
ShadowWebView shadowWebView = shadowOf(webView);
shadowWebView.getWebViewClient().onPageFinished(webView, "about:blank");
assertThat(shadowWebView.getLastLoadDataWithBaseURL().data).contains("text");
}
use of io.github.hidroh.materialistic.test.TestItem in project materialistic by hidroh.
the class HackerNewsItemTest method testKidCountNull.
@Test
public void testKidCountNull() {
item.populate(new TestItem() {
@Override
public long[] getKids() {
return null;
}
});
assertEquals(0, item.getKidCount());
}
use of io.github.hidroh.materialistic.test.TestItem in project materialistic by hidroh.
the class HackerNewsItemTest method testGetUrlNonStory.
@Test
public void testGetUrlNonStory() {
item.populate(new TestItem() {
@Override
public String getRawType() {
return "comment";
}
});
assertEquals(String.format(HackerNewsClient.WEB_ITEM_PATH, "1"), item.getUrl());
}
use of io.github.hidroh.materialistic.test.TestItem in project materialistic by hidroh.
the class HackerNewsItemTest method testGetDisplayedTime.
@Test
public void testGetDisplayedTime() {
item.populate(new TestItem() {
@Override
public long getTime() {
// Apr 15 2015
return 1429027200l;
}
@Override
public String getBy() {
return "author";
}
});
assertThat(item.getDisplayedAuthor(RuntimeEnvironment.application, true, 0)).contains(" - author");
assertThat(item.getDisplayedAuthor(RuntimeEnvironment.application, false, 0)).contains(" - author");
item.populate(new TestItem() {
@Override
public String getBy() {
return "author";
}
@Override
public boolean isDead() {
return true;
}
});
assertThat(item.getDisplayedTime(RuntimeEnvironment.application)).contains(RuntimeEnvironment.application.getString(R.string.dead_prefix));
}
use of io.github.hidroh.materialistic.test.TestItem in project materialistic by hidroh.
the class HackerNewsItemTest method testGetUrlStoryNoUrl.
@Test
public void testGetUrlStoryNoUrl() {
item.populate(new TestItem() {
@Override
public String getRawType() {
return "story";
}
});
assertEquals(String.format(HackerNewsClient.WEB_ITEM_PATH, "1"), item.getUrl());
}
Aggregations