Search in sources :

Example 1 with CardPlayerContext

use of org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerContext in project AnyMemo by helloworld1.

the class CardPlayerStateTest method testPlayRandomNextCard.

@SmallTest
@Test
public void testPlayRandomNextCard() {
    cardPlayerContext = new CardPlayerContext(mockEventHandler, mockCardTTSUtil, mockAmTTSServiceHandler, helper, delayBeteenQAInSec, delayBeteenCardsInSec, // Shuffle enabled
    true, true);
    cardPlayerContext.setCurrentCard(helper.getCardDao().queryForId(TEST_CARD_ID));
    verifyStateTransition(CardPlayerState.PLAYING_QUESTION, CardPlayerMessage.GO_TO_NEXT, CardPlayerState.PLAYING_QUESTION);
}
Also used : CardPlayerContext(org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerContext) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 2 with CardPlayerContext

use of org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerContext in project AnyMemo by helloworld1.

the class CardPlayerStateTest method testPlayPrevQuestionNoRepeatWithFirstCardShouldStop.

@SmallTest
@Test
public void testPlayPrevQuestionNoRepeatWithFirstCardShouldStop() {
    cardPlayerContext = new CardPlayerContext(mockEventHandler, mockCardTTSUtil, mockAmTTSServiceHandler, helper, delayBeteenQAInSec, delayBeteenCardsInSec, false, // No repeat
    false);
    cardPlayerContext.setCurrentCard(helper.getCardDao().queryForId(TEST_FIRST_CARD_ID));
    verifyStateTransition(CardPlayerState.PLAYING_QUESTION, CardPlayerMessage.GO_TO_PREV, CardPlayerState.STOPPED);
}
Also used : CardPlayerContext(org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerContext) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 3 with CardPlayerContext

use of org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerContext in project AnyMemo by helloworld1.

the class CardPlayerStateTest method testPlayPrevQuestionNoRepeatWithCardInMiddle.

@SmallTest
@Test
public void testPlayPrevQuestionNoRepeatWithCardInMiddle() {
    cardPlayerContext = new CardPlayerContext(mockEventHandler, mockCardTTSUtil, mockAmTTSServiceHandler, helper, delayBeteenQAInSec, delayBeteenCardsInSec, false, // No repeat
    false);
    cardPlayerContext.setCurrentCard(helper.getCardDao().queryForId(TEST_CARD_ID));
    verifyStateTransition(CardPlayerState.PLAYING_QUESTION, CardPlayerMessage.GO_TO_PREV, CardPlayerState.PLAYING_QUESTION);
    assertEquals(TEST_CARD_ID - 1, (int) cardPlayerContext.getCurrentCard().getId());
}
Also used : CardPlayerContext(org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerContext) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 4 with CardPlayerContext

use of org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerContext in project AnyMemo by helloworld1.

the class CardPlayerStateTest method testPlayRandomPrevCard.

// Shuffle test
@SmallTest
@Test
public void testPlayRandomPrevCard() {
    cardPlayerContext = new CardPlayerContext(mockEventHandler, mockCardTTSUtil, mockAmTTSServiceHandler, helper, delayBeteenQAInSec, delayBeteenCardsInSec, // Shuffle enabled
    true, true);
    cardPlayerContext.setCurrentCard(helper.getCardDao().queryForId(TEST_CARD_ID));
    verifyStateTransition(CardPlayerState.PLAYING_QUESTION, CardPlayerMessage.GO_TO_PREV, CardPlayerState.PLAYING_QUESTION);
}
Also used : CardPlayerContext(org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerContext) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 5 with CardPlayerContext

use of org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerContext in project AnyMemo by helloworld1.

the class CardPlayerStateTest method testPlayRandomNextCardWithRepeat.

// Shuffle and repeat work together. Shuffle should take precedence
// so it alway repeat
@SmallTest
@Test
public void testPlayRandomNextCardWithRepeat() {
    cardPlayerContext = new CardPlayerContext(mockEventHandler, mockCardTTSUtil, mockAmTTSServiceHandler, helper, delayBeteenQAInSec, delayBeteenCardsInSec, // Shuffle enabled
    true, // No repeat
    false);
    // Use last card to test that repeat has no effect
    cardPlayerContext.setCurrentCard(helper.getCardDao().queryForId(TEST_LAST_CARD_ID));
    verifyStateTransition(CardPlayerState.PLAYING_QUESTION, CardPlayerMessage.GO_TO_NEXT, CardPlayerState.PLAYING_QUESTION);
}
Also used : CardPlayerContext(org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerContext) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Aggregations

CardPlayerContext (org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerContext)9 SmallTest (android.support.test.filters.SmallTest)7 Test (org.junit.Test)7 AbstractExistingDBTest (org.liberty.android.fantastischmemo.test.AbstractExistingDBTest)7 Handler (android.os.Handler)1 Card (org.liberty.android.fantastischmemo.entity.Card)1 CardPlayerEventHandler (org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerEventHandler)1 CardTTSUtil (org.liberty.android.fantastischmemo.utils.CardTTSUtil)1