-Updated tests: gridlogic now passes all
parent
827b4a1f14
commit
3c1e956fc4
|
@ -7,13 +7,13 @@
|
||||||
extern Jack* jack;
|
extern Jack* jack;
|
||||||
|
|
||||||
const char* GridLogic::StateString[8] = {
|
const char* GridLogic::StateString[8] = {
|
||||||
"empty",
|
"Empty",
|
||||||
"playing",
|
"Playing",
|
||||||
"play queued",
|
"Play queued",
|
||||||
"stopped",
|
"Stopped",
|
||||||
"stop queued",
|
"Stop queued",
|
||||||
"recording",
|
"Recording",
|
||||||
"record queued"
|
"Record queued"
|
||||||
};
|
};
|
||||||
|
|
||||||
GridLogic::GridLogic()
|
GridLogic::GridLogic()
|
||||||
|
@ -96,6 +96,13 @@ void GridLogic::pressed( int track, int scene )
|
||||||
|
|
||||||
if ( s == STATE_STOP_QUEUED )
|
if ( s == STATE_STOP_QUEUED )
|
||||||
lc->queuePlay();
|
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
|
// check state of new clip, if getQueuePlay() == true, queueStop() all other scenes
|
||||||
|
|
|
@ -406,3 +406,16 @@ float LooperClip::getProgress()
|
||||||
}
|
}
|
||||||
return 0.f;
|
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
|
||||||
|
|
|
@ -87,6 +87,11 @@ class LooperClip : public Stately
|
||||||
/// used for saving the contents of this buffer to disk
|
/// used for saving the contents of this buffer to disk
|
||||||
void recieveSaveBuffer( AudioBuffer* ab );
|
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:
|
private:
|
||||||
int track, scene;
|
int track, scene;
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,16 @@ int GridLogic::runTests()
|
||||||
int s = 0;
|
int s = 0;
|
||||||
LooperClip* lc = jack->getLooper( t )->getClip( s );
|
LooperClip* lc = jack->getLooper( t )->getClip( s );
|
||||||
|
|
||||||
|
// "pretty" prints the state of the clip
|
||||||
|
//LUPPP_NOTE("%s", GridLogic::StateString[ lc->getState() ] );
|
||||||
|
|
||||||
/// SCENE LAUNCH
|
/// SCENE LAUNCH
|
||||||
lc->init();
|
lc->init();
|
||||||
jack->getGridLogic()->launchScene( s );
|
jack->getGridLogic()->launchScene( s );
|
||||||
QUNIT_IS_TRUE( jack->getGridLogic()->getLaunchedScene() == s );
|
QUNIT_IS_TRUE( jack->getGridLogic()->getLaunchedScene() == s );
|
||||||
|
|
||||||
|
|
||||||
/// PAD STATE CHECKS
|
/// PRESS PAD
|
||||||
// empty -> recording
|
// empty -> recording
|
||||||
lc->init();
|
lc->init();
|
||||||
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_EMPTY );
|
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_EMPTY );
|
||||||
|
@ -59,6 +62,48 @@ int GridLogic::runTests()
|
||||||
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_PLAYING );
|
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();
|
return qunit.errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
test.sh
1
test.sh
|
@ -18,7 +18,6 @@
|
||||||
make && ./bin/luppp -test -stopAfterTest
|
make && ./bin/luppp -test -stopAfterTest
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
notify-send -t 5 "Luppp: Tests passed..."
|
notify-send -t 5 "Luppp: Tests passed..."
|
||||||
echo OK
|
|
||||||
else
|
else
|
||||||
notify-send -t 10 -u critical "Luppp: Build / Test Failed!"
|
notify-send -t 10 -u critical "Luppp: Build / Test Failed!"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue