From 3c1e956fc4ea4a11284654cb15cb6ff35c32f0f2 Mon Sep 17 00:00:00 2001 From: Harry van Haaren Date: Tue, 17 Sep 2013 12:51:11 +0100 Subject: [PATCH] -Updated tests: gridlogic now passes all --- src/gridlogic.cxx | 21 ++++++++++------ src/looperclip.cxx | 13 ++++++++++ src/looperclip.hxx | 5 ++++ src/tests/gridlogictests.cxx | 47 +++++++++++++++++++++++++++++++++++- test.sh | 1 - 5 files changed, 78 insertions(+), 9 deletions(-) diff --git a/src/gridlogic.cxx b/src/gridlogic.cxx index 0f863f6..6b3e0d0 100644 --- a/src/gridlogic.cxx +++ b/src/gridlogic.cxx @@ -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 diff --git a/src/looperclip.cxx b/src/looperclip.cxx index 57b7748..3e5287c 100644 --- a/src/looperclip.cxx +++ b/src/looperclip.cxx @@ -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 diff --git a/src/looperclip.hxx b/src/looperclip.hxx index dc37134..f18be34 100644 --- a/src/looperclip.hxx +++ b/src/looperclip.hxx @@ -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; diff --git a/src/tests/gridlogictests.cxx b/src/tests/gridlogictests.cxx index 62688b3..b30b85f 100644 --- a/src/tests/gridlogictests.cxx +++ b/src/tests/gridlogictests.cxx @@ -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(); } diff --git a/test.sh b/test.sh index f82a0b8..641d40c 100755 --- a/test.sh +++ b/test.sh @@ -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