MangahereTest.java 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package eu.kanade.mangafeed;
  2. import android.os.Build;
  3. import junit.framework.Assert;
  4. import org.junit.Before;
  5. import org.junit.Test;
  6. import org.junit.runner.RunWith;
  7. import org.robolectric.RobolectricGradleTestRunner;
  8. import org.robolectric.RuntimeEnvironment;
  9. import org.robolectric.annotation.Config;
  10. import java.util.List;
  11. import eu.kanade.mangafeed.data.caches.CacheManager;
  12. import eu.kanade.mangafeed.data.helpers.NetworkHelper;
  13. import eu.kanade.mangafeed.data.models.Chapter;
  14. import eu.kanade.mangafeed.data.models.Manga;
  15. import eu.kanade.mangafeed.sources.MangaHere;
  16. import eu.kanade.mangafeed.sources.base.Source;
  17. @Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
  18. @RunWith(RobolectricGradleTestRunner.class)
  19. public class MangahereTest {
  20. NetworkHelper net;
  21. CacheManager cache;
  22. Source b;
  23. final String chapterUrl ="http://www.mangahere.co/manga/kimi_ni_todoke/v15/c099/";
  24. final String mangaUrl = "http://www.mangahere.co/manga/kimi_ni_todoke/";
  25. @Before
  26. public void setUp() {
  27. net = new NetworkHelper();
  28. cache = new CacheManager(RuntimeEnvironment.application.getApplicationContext());
  29. b = new MangaHere(net, cache);
  30. }
  31. @Test
  32. public void testImageList() {
  33. List<String> imageUrls = b.getRemainingImageUrlsFromPageList(chapterUrl)
  34. .toList().toBlocking().single();
  35. Assert.assertTrue(imageUrls.size() > 5);
  36. }
  37. @Test
  38. public void testMangaList() {
  39. List<Manga> mangaList = b.pullPopularMangasFromNetwork(1)
  40. .toBlocking().first();
  41. Manga m = mangaList.get(0);
  42. Assert.assertNotNull(m.title);
  43. Assert.assertNotNull(m.url);
  44. Assert.assertTrue(mangaList.size() > 25);
  45. }
  46. @Test
  47. public void testChapterList() {
  48. List<Chapter> mangaList = b.pullChaptersFromNetwork(mangaUrl)
  49. .toBlocking().first();
  50. Assert.assertTrue(mangaList.size() > 5);
  51. }
  52. @Test
  53. public void testMangaDetails() {
  54. Manga manga = b.pullMangaFromNetwork(mangaUrl)
  55. .toBlocking().single();
  56. Assert.assertEquals("Shiina Karuho", manga.author);
  57. Assert.assertEquals("Shiina Karuho", manga.artist);
  58. Assert.assertEquals("http://www.mangahere.co/manga/kimi_ni_todoke/", manga.url);
  59. Assert.assertEquals("http://a.mhcdn.net/store/manga/4999/cover.jpg?v=1433950383", manga.thumbnail_url);
  60. Assert.assertTrue(manga.description.length() > 20);
  61. Assert.assertTrue(manga.genre.length() > 20);
  62. }
  63. }