Search in sources :

Example 86 with SmallTest

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

the class CardProviderTest method testGetRandomCards.

@SmallTest
@Test
public void testGetRandomCards() {
    ContentResolver cr = getContext().getContentResolver();
    Cursor cursor = cr.query(Uri.parse("content://" + AUTHORITY + "/" + TestHelper.SAMPLE_DB_NAME + "/random/10"), null, null, null, null);
    assertEquals(10, cursor.getCount());
}
Also used : Cursor(android.database.Cursor) ContentResolver(android.content.ContentResolver) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 87 with SmallTest

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

the class LearnQueuingManagerTest method testGetNewCardQueuingWithoutCategory.

@SmallTest
@Test
public void testGetNewCardQueuingWithoutCategory() throws Exception {
    QueueManager queueManager = new LearnQueueManager.Builder(getContext(), TestHelper.SAMPLE_DB_PATH).setLearnQueueSize(10).setFilterCategory(null).setCacheSize(50).build();
    Card cqueue = queueManager.dequeue();
    assertEquals(1, (int) cqueue.getId());
    queueManager.release();
}
Also used : LearnQueueManager(org.liberty.android.fantastischmemo.queue.LearnQueueManager) QueueManager(org.liberty.android.fantastischmemo.queue.QueueManager) 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 88 with SmallTest

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

the class QuizQueuingManagerTest method testUpdateCard.

@SmallTest
@Test
public void testUpdateCard() throws Exception {
    Scheduler mockScheduler = mock(Scheduler.class);
    // Create a quiz start the quiz size 3 from card 5
    QueueManager queueManager = new QuizQueueManager.Builder().setDbOpenHelper(helper).setQuizSize(3).setStartCardOrd(5).setScheduler(mockScheduler).build();
    Card card5 = queueManager.dequeue();
    queueManager.remove(card5);
    assertEquals(5, (int) card5.getOrdinal());
    when(mockScheduler.isCardLearned(card5.getLearningData())).thenReturn(true);
    queueManager.update(card5);
    Card card6 = queueManager.dequeue();
    queueManager.remove(card6);
    assertEquals(6, (int) card6.getOrdinal());
    when(mockScheduler.isCardLearned(card6.getLearningData())).thenReturn(false);
    queueManager.update(card6);
    Card card7 = queueManager.dequeue();
    queueManager.remove(card7);
    assertEquals(7, (int) card7.getOrdinal());
    when(mockScheduler.isCardLearned(card7.getLearningData())).thenReturn(true);
    queueManager.update(card7);
    // Now cards in the queue is the card we failed
    // and we succeed this time
    Card card6Again = queueManager.dequeue();
    queueManager.remove(card6Again);
    assertEquals(6, (int) card6Again.getOrdinal());
    when(mockScheduler.isCardLearned(card6.getLearningData())).thenReturn(true);
    queueManager.update(card6Again);
    // No cards in the queue
    Card nullCard = queueManager.dequeue();
    assertNull(nullCard);
}
Also used : Scheduler(org.liberty.android.fantastischmemo.scheduler.Scheduler) QuizQueueManager(org.liberty.android.fantastischmemo.queue.QuizQueueManager) QuizQueueManager(org.liberty.android.fantastischmemo.queue.QuizQueueManager) QueueManager(org.liberty.android.fantastischmemo.queue.QueueManager) 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 89 with SmallTest

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

the class QuizQueuingManagerTest method testFilterByGroup.

@SmallTest
@Test
public void testFilterByGroup() throws Exception {
    // Create a quiz start the quiz size 3 from card 5
    QueueManager queueManager = new QuizQueueManager.Builder().setDbOpenHelper(helper).setQuizSize(3).setStartCardOrd(5).build();
    Card card5 = queueManager.dequeue();
    queueManager.remove(card5);
    assertEquals(5, (int) card5.getOrdinal());
    Card card6 = queueManager.dequeue();
    queueManager.remove(card6);
    assertEquals(6, (int) card6.getOrdinal());
    Card card7 = queueManager.dequeue();
    queueManager.remove(card7);
    assertEquals(7, (int) card7.getOrdinal());
    // No cards in the queue
    Card nullCard = queueManager.dequeue();
    assertNull(nullCard);
}
Also used : QuizQueueManager(org.liberty.android.fantastischmemo.queue.QuizQueueManager) QueueManager(org.liberty.android.fantastischmemo.queue.QueueManager) 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 90 with SmallTest

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

the class DefaultSchedulerTest method testScheduleForReviewardSuccess.

@SmallTest
@Test
public void testScheduleForReviewardSuccess() {
    LearningData newLd = defaultScheduler.schedule(forReviewCardLearningData, 5, false);
    assertFalse(defaultScheduler.isCardForReview(newLd));
    assertFalse(defaultScheduler.isCardNew(newLd));
    assertTrue(defaultScheduler.isCardLearned(newLd));
}
Also used : LearningData(org.liberty.android.fantastischmemo.entity.LearningData) SmallTest(android.support.test.filters.SmallTest) AbstractPreferencesTest(org.liberty.android.fantastischmemo.test.AbstractPreferencesTest) 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