Rename project

This commit is contained in:
inorichi
2016-01-15 15:18:19 +01:00
parent 1508bf42fb
commit 70f4c7fcc3
167 changed files with 647 additions and 654 deletions

View File

@@ -0,0 +1,116 @@
package eu.kanade.tachiyomi;
import android.app.Application;
import android.os.Build;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.util.List;
import eu.kanade.tachiyomi.data.database.DatabaseHelper;
import eu.kanade.tachiyomi.data.database.models.Category;
import eu.kanade.tachiyomi.data.database.models.Manga;
import eu.kanade.tachiyomi.data.database.models.MangaCategory;
import static org.assertj.core.api.Assertions.*;
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
@RunWith(RobolectricGradleTestRunner.class)
public class CategoryTest {
DatabaseHelper db;
@Before
public void setup() {
Application app = RuntimeEnvironment.application;
db = new DatabaseHelper(app);
// Create 5 mangas
createManga("a");
createManga("b");
createManga("c");
createManga("d");
createManga("e");
}
@Test
public void testHasCategories() {
// Create 2 categories
createCategory("Reading");
createCategory("Hold");
List<Category> categories = db.getCategories().executeAsBlocking();
assertThat(categories).hasSize(2);
}
@Test
public void testHasLibraryMangas() {
List<Manga> mangas = db.getLibraryMangas().executeAsBlocking();
assertThat(mangas).hasSize(5);
}
@Test
public void testHasCorrectFavorites() {
Manga m = new Manga();
m.title = "title";
m.author = "";
m.artist = "";
m.thumbnail_url = "";
m.genre = "a list of genres";
m.description = "long description";
m.url = "url to manga";
m.favorite = false;
db.insertManga(m).executeAsBlocking();
List<Manga> mangas = db.getLibraryMangas().executeAsBlocking();
assertThat(mangas).hasSize(5);
}
@Test
public void testMangaInCategory() {
// Create 2 categories
createCategory("Reading");
createCategory("Hold");
// It should not have 0 as id
Category c = db.getCategories().executeAsBlocking().get(0);
assertThat(c.id).isNotZero();
// Add a manga to a category
Manga m = db.getMangas().executeAsBlocking().get(0);
MangaCategory mc = MangaCategory.create(m, c);
db.insertMangaCategory(mc).executeAsBlocking();
// Get mangas from library and assert manga category is the same
List<Manga> mangas = db.getLibraryMangas().executeAsBlocking();
for (Manga manga : mangas) {
if (manga.id.equals(m.id)) {
assertThat(manga.category).isEqualTo(c.id);
}
}
}
private void createManga(String title) {
Manga m = new Manga();
m.title = title;
m.author = "";
m.artist = "";
m.thumbnail_url = "";
m.genre = "a list of genres";
m.description = "long description";
m.url = "url to manga";
m.favorite = true;
db.insertManga(m).executeAsBlocking();
}
private void createCategory(String name) {
Category c = new Category();
c.name = name;
db.insertCategory(c).executeAsBlocking();
}
}

View File

@@ -0,0 +1,138 @@
package eu.kanade.tachiyomi;
import org.junit.Before;
import org.junit.Test;
import eu.kanade.tachiyomi.data.database.models.Chapter;
import eu.kanade.tachiyomi.data.database.models.Manga;
import eu.kanade.tachiyomi.util.ChapterRecognition;
import static org.assertj.core.api.Assertions.assertThat;
public class ChapterRecognitionTest {
Manga randomManga;
private Chapter createChapter(String title) {
Chapter chapter = Chapter.create();
chapter.name = title;
return chapter;
}
@Before
public void setUp() {
randomManga = new Manga();
randomManga.title = "Something";
}
@Test
public void testWithOneDigit() {
Chapter c = createChapter("Ch.3: Self-proclaimed Genius");
ChapterRecognition.parseChapterNumber(c, randomManga);
assertThat(c.chapter_number).isEqualTo(3f);
}
@Test
public void testWithVolumeBefore() {
Chapter c = createChapter("Vol.1 Ch.4: Misrepresentation");
ChapterRecognition.parseChapterNumber(c, randomManga);
assertThat(c.chapter_number).isEqualTo(4f);
}
@Test
public void testWithVolumeAndVersionNumber() {
Chapter c = createChapter("Vol.1 Ch.3 (v2) Read Online");
ChapterRecognition.parseChapterNumber(c, randomManga);
assertThat(c.chapter_number).isEqualTo(3f);
}
@Test
public void testWithVolumeAndNumberInTitle() {
Chapter c = createChapter("Vol.15 Ch.90: Here Blooms the Daylily, Part 4");
ChapterRecognition.parseChapterNumber(c, randomManga);
assertThat(c.chapter_number).isEqualTo(90f);
}
@Test
public void testWithVolumeAndSpecialChapter() {
Chapter c = createChapter("Vol.10 Ch.42.5: Homecoming (Beginning)");
ChapterRecognition.parseChapterNumber(c, randomManga);
assertThat(c.chapter_number).isEqualTo(42.5f);
}
@Test
public void testWithJustANumber() {
Chapter c = createChapter("Homecoming (Beginning) 42");
ChapterRecognition.parseChapterNumber(c, randomManga);
assertThat(c.chapter_number).isEqualTo(42f);
}
@Test
public void testWithJustASpecialChapter() {
Chapter c = createChapter("Homecoming (Beginning) 42.5");
ChapterRecognition.parseChapterNumber(c, randomManga);
assertThat(c.chapter_number).isEqualTo(42.5f);
}
@Test
public void testWithNumberinMangaTitle() {
Chapter c = createChapter("3x3 Eyes 96");
Manga m = new Manga();
m.title = "3x3 Eyes";
ChapterRecognition.parseChapterNumber(c, m);
assertThat(c.chapter_number).isEqualTo(96f);
}
@Test
public void testWithColonAtTheEnd() {
Chapter c = createChapter("Chapter 5: 365 days");
ChapterRecognition.parseChapterNumber(c, randomManga);
assertThat(c.chapter_number).isEqualTo(5f);
}
@Test
public void testWithZeros() {
Chapter c = createChapter("Vol.001 Ch.003: Kaguya Doesn't Know Much");
ChapterRecognition.parseChapterNumber(c, randomManga);
assertThat(c.chapter_number).isEqualTo(3f);
}
@Test
public void testRange() {
Chapter c = createChapter("Ch.191-200 Read Online");
ChapterRecognition.parseChapterNumber(c, randomManga);
assertThat(c.chapter_number).isEqualTo(191f);
}
@Test
public void testWithKeywordChAtTheEndOfTheManga() {
// It should be 567, not 67 (ch is a keyword to get the chapter number)
Chapter c = createChapter("Bleach 567: Down With Snowwhite");
ChapterRecognition.parseChapterNumber(c, randomManga);
assertThat(c.chapter_number).isEqualTo(567f);
}
@Test
public void testWithVersionBefore() {
// It should be 84, not 2084
Chapter c = createChapter("Onepunch-Man Punch Ver002 084 : Creeping Darkness");
ChapterRecognition.parseChapterNumber(c, randomManga);
assertThat(c.chapter_number).isEqualTo(84f);
}
@Test
public void testWithVersionBeforeAndAnotherNumber() {
Chapter c = createChapter("Onepunch-Man Punch Ver002 086 : Creeping Darkness [3]");
ChapterRecognition.parseChapterNumber(c, randomManga);
assertThat(c.chapter_number).isEqualTo(86f);
}
@Test
public void testWithVolumeAfterChapter() {
Chapter c = createChapter("Solanin 028 Vol. 2");
ChapterRecognition.parseChapterNumber(c, randomManga);
assertThat(c.chapter_number).isEqualTo(28f);
}
}

View File

@@ -0,0 +1,40 @@
package eu.kanade.tachiyomi;
/**
* Created by len on 1/10/15.
*/
import android.os.Build;
import android.support.v7.widget.Toolbar;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import eu.kanade.tachiyomi.ui.main.MainActivity;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
@RunWith(RobolectricGradleTestRunner.class)
public class MainActivityTest {
private MainActivity activity;
// @Before => JUnit 4 annotation that specifies this method should run before each test is run
// Useful to do setup for objects that are needed in the test
@Before
public void setup() {
// Convenience method to run MainActivity through the Activity Lifecycle methods:
// onCreate(...) => onStart() => onPostCreate(...) => onResume()
activity = Robolectric.setupActivity(MainActivity.class);
}
@Test
public void validate() {
Toolbar toolbar = (Toolbar)activity.findViewById(R.id.toolbar);
assertNotNull(toolbar);
}
}

View File

@@ -0,0 +1,16 @@
package eu.kanade.tachiyomi;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Created by len on 1/10/15.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface UseModule {
Class value();
}

View File

@@ -0,0 +1,7 @@
package eu.kanade.tachiyomi.util;
public class DefaultConfig {
//The api level that Roboelectric will use to run the unit tests
public static final int EMULATE_SDK = 21;
public static final String MANIFEST = "./src/main/AndroidManifest.xml";
}