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);
}
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));
}
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());
}
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);
}
}
Aggregations