Search in sources :

Example 6 with CardPlayerContext

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

the class CardPlayerStateTest method testPlayNextQuestionNoRepeatWithCardAtEndShouldStop.

@SmallTest
@Test
public void testPlayNextQuestionNoRepeatWithCardAtEndShouldStop() {
    cardPlayerContext = new CardPlayerContext(mockEventHandler, mockCardTTSUtil, mockAmTTSServiceHandler, helper, delayBeteenQAInSec, delayBeteenCardsInSec, false, // No repeat
    false);
    cardPlayerContext.setCurrentCard(helper.getCardDao().queryForId(TEST_LAST_CARD_ID));
    verifyStateTransition(CardPlayerState.PLAYING_QUESTION, CardPlayerMessage.GO_TO_NEXT, 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 7 with CardPlayerContext

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

the class CardPlayerStateTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    mockEventHandler = mock(CardPlayerEventHandler.class);
    mockCardTTSUtil = mock(CardTTSUtil.class);
    mockAmTTSServiceHandler = mock(Handler.class);
    cardPlayerContext = new CardPlayerContext(mockEventHandler, mockCardTTSUtil, mockAmTTSServiceHandler, helper, delayBeteenQAInSec, delayBeteenCardsInSec, false, true);
    cardPlayerContext.setCurrentCard(helper.getCardDao().queryForId(TEST_CARD_ID));
}
Also used : CardPlayerEventHandler(org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerEventHandler) CardPlayerContext(org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerContext) CardPlayerEventHandler(org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerEventHandler) Handler(android.os.Handler) CardTTSUtil(org.liberty.android.fantastischmemo.utils.CardTTSUtil)

Example 8 with CardPlayerContext

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

the class CardPlayerStateTest method testPlayNextQuestionNoRepeatWithCardInMiddle.

// With repeat option disabled
@SmallTest
@Test
public void testPlayNextQuestionNoRepeatWithCardInMiddle() {
    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_NEXT, 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 9 with CardPlayerContext

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

the class CardPlayerService method reset.

/*
     * Stop playing and reset the context
     */
public void reset() {
    // When we reset, we want to know the current card
    // to set so the newly created context will have the
    // current card previously set
    // If it is null, we will leave it undertermined.
    Card currentCard = null;
    if (cardPlayerContext != null) {
        stopPlaying();
        currentCard = cardPlayerContext.getCurrentCard();
    }
    cardPlayerContext = new CardPlayerContext(cardPlayerEventHandler, cardTTSUtil, handler, dbOpenHelper, option.getCardPlayerIntervalBetweenQA(), option.getCardPlayerIntervalBetweenCards(), option.getCardPlayerShuffleEnabled(), option.getCardPlayerRepeatEnabled());
    if (currentCard != null) {
        cardPlayerContext.setCurrentCard(currentCard);
    }
}
Also used : CardPlayerContext(org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerContext) Card(org.liberty.android.fantastischmemo.entity.Card)

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