-Updated tests: gridlogic now passes all

main
Harry van Haaren 2013-09-17 12:51:11 +01:00
parent 827b4a1f14
commit 3c1e956fc4
5 changed files with 78 additions and 9 deletions

View File

@ -7,13 +7,13 @@
extern Jack* jack;
const char* GridLogic::StateString[8] = {
"empty",
"playing",
"play queued",
"stopped",
"stop queued",
"recording",
"record queued"
"Empty",
"Playing",
"Play queued",
"Stopped",
"Stop queued",
"Recording",
"Record queued"
};
GridLogic::GridLogic()
@ -96,6 +96,13 @@ void GridLogic::pressed( int track, int scene )
if ( s == STATE_STOP_QUEUED )
lc->queuePlay();
// don't re-trigger if already playing!
if ( s == STATE_STOP_QUEUED && lc->playing() )
lc->neutralize();
if ( s == STATE_RECORD_QUEUED )
lc->neutralize();
}
// check state of new clip, if getQueuePlay() == true, queueStop() all other scenes

View File

@ -406,3 +406,16 @@ float LooperClip::getProgress()
}
return 0.f;
}
#ifdef BUILD_TESTS
void LooperClip::setState( bool load, bool play, bool rec, bool qPlay, bool qStop, bool qRec )
{
_loaded = load;
_playing = play;
_recording = rec;
_queuePlay = qPlay;
_queueStop = qStop;
_queueRecord = qRec;
}
#endif

View File

@ -87,6 +87,11 @@ class LooperClip : public Stately
/// used for saving the contents of this buffer to disk
void recieveSaveBuffer( AudioBuffer* ab );
#ifdef BUILD_TESTS
// used only in test cases
void setState( bool load, bool play, bool rec, bool qPlay, bool qStop, bool qRec );
#endif
private:
int track, scene;

View File

@ -20,13 +20,16 @@ int GridLogic::runTests()
int s = 0;
LooperClip* lc = jack->getLooper( t )->getClip( s );
// "pretty" prints the state of the clip
//LUPPP_NOTE("%s", GridLogic::StateString[ lc->getState() ] );
/// SCENE LAUNCH
lc->init();
jack->getGridLogic()->launchScene( s );
QUNIT_IS_TRUE( jack->getGridLogic()->getLaunchedScene() == s );
/// PAD STATE CHECKS
/// PRESS PAD
// empty -> recording
lc->init();
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_EMPTY );
@ -59,6 +62,48 @@ int GridLogic::runTests()
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_PLAYING );
/// DOUBLE PRESS PAD
// empty -> recordQ -> empty
lc->init();
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_EMPTY );
jack->getGridLogic()->pressed( t, s );
jack->getGridLogic()->released( t, s );
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_RECORD_QUEUED );
jack->getGridLogic()->pressed( t, s );
jack->getGridLogic()->released( t, s );
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_EMPTY );
lc->bar();
// recording -> playing -> stopped
lc->setState( true, false, true, false, false, false );
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_RECORDING );
jack->getGridLogic()->pressed( t, s );
jack->getGridLogic()->released( t, s );
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_PLAY_QUEUED );
jack->getGridLogic()->pressed( t, s );
jack->getGridLogic()->released( t, s );
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_STOP_QUEUED );
lc->bar();
// stopped -> playing -> stopped
lc->setState( true, false, false, false, false, false );
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_STOPPED );
jack->getGridLogic()->pressed( t, s );
jack->getGridLogic()->released( t, s );
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_PLAY_QUEUED );
jack->getGridLogic()->pressed( t, s );
jack->getGridLogic()->released( t, s );
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_STOP_QUEUED );
// stopped -> playing
lc->setState( true, true, false, false, false, false );
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_PLAYING );
jack->getGridLogic()->pressed( t, s );
jack->getGridLogic()->released( t, s );
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_STOP_QUEUED );
jack->getGridLogic()->pressed( t, s );
jack->getGridLogic()->released( t, s );
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_PLAYING );
return qunit.errors();
}

View File

@ -18,7 +18,6 @@
make && ./bin/luppp -test -stopAfterTest
if [ $? -eq 0 ]; then
notify-send -t 5 "Luppp: Tests passed..."
echo OK
else
notify-send -t 10 -u critical "Luppp: Build / Test Failed!"
fi