Search in sources :

Example 66 with SmallTest

use of android.support.test.filters.SmallTest in project AnyMemo by helloworld1.

the class CardDaoTest method testCreateCards.

@SmallTest
@Test
public void testCreateCards() throws Exception {
    CardDao cardDao = helper.getCardDao();
    Card c = new Card();
    c.setOrdinal(29);
    c.setCategory(new Category());
    c.setLearningData(new LearningData());
    Card c2 = new Card();
    c2.setOrdinal(30);
    c2.setCategory(new Category());
    c2.setLearningData(new LearningData());
    List<Card> cards = new ArrayList<Card>();
    cards.add(c);
    cards.add(c2);
    cardDao.createCards(cards);
    // Should create two new card
    assertEquals(30, cardDao.countOf());
    // The new card's id and ordinal should be correct
    assertEquals(29, (int) c.getId());
    assertEquals(29, (int) c.getOrdinal());
    assertEquals(30, (int) c2.getId());
    assertEquals(30, (int) c2.getOrdinal());
}
Also used : Category(org.liberty.android.fantastischmemo.entity.Category) ArrayList(java.util.ArrayList) LearningData(org.liberty.android.fantastischmemo.entity.LearningData) CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Card(org.liberty.android.fantastischmemo.entity.Card) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 67 with SmallTest

use of android.support.test.filters.SmallTest in project AnyMemo by helloworld1.

the class CardDaoTest method testSearchFirstOrdinalWithcategoryIfExists.

@SmallTest
@Test
public void testSearchFirstOrdinalWithcategoryIfExists() throws Exception {
    setupThreeCategories();
    CardDao cardDao = helper.getCardDao();
    CategoryDao categoryDao = helper.getCategoryDao();
    List<Category> cts = categoryDao.queryForEq("name", "My category");
    Category ct = cts.get(0);
    Card c = cardDao.queryFirstOrdinal(ct);
    assertEquals(2, (int) c.getId());
}
Also used : Category(org.liberty.android.fantastischmemo.entity.Category) CategoryDao(org.liberty.android.fantastischmemo.dao.CategoryDao) CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Card(org.liberty.android.fantastischmemo.entity.Card) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 68 with SmallTest

use of android.support.test.filters.SmallTest in project AnyMemo by helloworld1.

the class CardDaoTest method testGetRandomCardsWithCategory.

@SmallTest
@Test
public void testGetRandomCardsWithCategory() throws Exception {
    CardDao cardDao = helper.getCardDao();
    CategoryDao categoryDao = helper.getCategoryDao();
    setupThreeCategories();
    Category filterCategory1 = categoryDao.createOrReturn("My category");
    // larger than limit
    List<Card> cards1 = cardDao.getRandomCards(filterCategory1, 50);
    assertEquals(3, cards1.size());
    // smaller than limit
    List<Card> cards2 = cardDao.getRandomCards(filterCategory1, 1);
    assertEquals(1, cards2.size());
}
Also used : Category(org.liberty.android.fantastischmemo.entity.Category) CategoryDao(org.liberty.android.fantastischmemo.dao.CategoryDao) CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Card(org.liberty.android.fantastischmemo.entity.Card) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 69 with SmallTest

use of android.support.test.filters.SmallTest in project AnyMemo by helloworld1.

the class CardDaoTest method testQueryNextCardWithCategory.

@SmallTest
@Test
public void testQueryNextCardWithCategory() throws Exception {
    setupThreeCategories();
    CardDao cardDao = helper.getCardDao();
    CategoryDao categoryDao = helper.getCategoryDao();
    List<Category> cts = categoryDao.queryForEq("name", "My category");
    Category ct = cts.get(0);
    Card c2 = cardDao.queryForId(2);
    Card c5 = cardDao.queryNextCard(c2, ct);
    assertEquals(5, (int) c5.getId());
    Card c8 = cardDao.queryForId(8);
    c2 = cardDao.queryNextCard(c8, ct);
    assertEquals(2, (int) c2.getId());
}
Also used : Category(org.liberty.android.fantastischmemo.entity.Category) CategoryDao(org.liberty.android.fantastischmemo.dao.CategoryDao) CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Card(org.liberty.android.fantastischmemo.entity.Card) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 70 with SmallTest

use of android.support.test.filters.SmallTest in project AnyMemo by helloworld1.

the class CategoryTest method testAddCategories.

@SmallTest
@Test
public void testAddCategories() throws Exception {
    CategoryDao categoryDao = helper.getCategoryDao();
    List<Category> categories = categoryDao.queryForAll();
    int initSize = categories.size();
    Category c1 = categoryDao.createOrReturn("c1");
    assertNotNull(c1);
    assertEquals(c1.getName(), "c1");
    categories = categoryDao.queryForAll();
    assertEquals(categories.size(), initSize + 1);
    Category c2 = categoryDao.createOrReturn("c1");
    assertEquals(c2.getName(), "c1");
    assertEquals(categories.size(), initSize + 1);
}
Also used : Category(org.liberty.android.fantastischmemo.entity.Category) CategoryDao(org.liberty.android.fantastischmemo.dao.CategoryDao) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Aggregations

SmallTest (android.support.test.filters.SmallTest)252 Test (org.junit.Test)137 AbstractExistingDBTest (org.liberty.android.fantastischmemo.test.AbstractExistingDBTest)86 Parcel (android.os.Parcel)48 TimeBase (com.android.internal.os.BatteryStatsImpl.TimeBase)45 Card (org.liberty.android.fantastischmemo.entity.Card)43 CardDao (org.liberty.android.fantastischmemo.dao.CardDao)37 Setting (org.liberty.android.fantastischmemo.entity.Setting)21 Binder (android.os.Binder)20 Category (org.liberty.android.fantastischmemo.entity.Category)17 AbstractPreferencesTest (org.liberty.android.fantastischmemo.test.AbstractPreferencesTest)17 LearningData (org.liberty.android.fantastischmemo.entity.LearningData)15 UiThreadTest (android.support.test.annotation.UiThreadTest)14 CategoryDao (org.liberty.android.fantastischmemo.dao.CategoryDao)13 LocaleList (android.os.LocaleList)10 Option (org.liberty.android.fantastischmemo.entity.Option)9 QueueManager (org.liberty.android.fantastischmemo.queue.QueueManager)9 ContentResolver (android.content.ContentResolver)8 Cursor (android.database.Cursor)8 OnTickListener (com.tmall.wireless.tangram.support.TimerSupport.OnTickListener)8