diff --git a/src/Tupfile b/src/Tupfile index c6b2864..b37d89a 100644 --- a/src/Tupfile +++ b/src/Tupfile @@ -11,16 +11,17 @@ INCLUDES += `pkg-config --cflags jack sndfile cairomm-1.0 ntk ntk_images` ifeq (@(LUPPP_BUILD_TESTS),y) CFLAGS += -fprofile-arcs -ftest-coverage -DBUILD_TESTS -DBUILD_COVERAGE_TEST -DDEBUG_KILL_ON_ERR OUTPUT += | %B.gcno +: foreach tests/*.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT) endif # COMPILE -#: foreach *.cxx observer/*.cxx state/*.cxx cjson/*.c dsp/*.cxx controller/*.cxx avtk/*.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT) - +: foreach *.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT) : foreach avtk/*.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT) : foreach controller/*.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT) : foreach dsp/*.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT) : foreach cjson/*.c |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT) : foreach state/*.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT) : foreach observer/*.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT) -: foreach *.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT) + + diff --git a/src/gridlogic.cxx b/src/gridlogic.cxx index 964018e..b6448d1 100644 --- a/src/gridlogic.cxx +++ b/src/gridlogic.cxx @@ -4,11 +4,6 @@ #include "jack.hxx" #include "audiobuffer.hxx" -#ifdef BUILD_TESTS -#define CATCH_CONFIG_RUNNER -#include "catch.hxx" -#endif - extern Jack* jack; const char* GridLogic::StateString[8] = { @@ -200,35 +195,3 @@ void GridLogic::beat() } - - -#ifdef BUILD_TESTS -int GridLogic::runTests() -{ - char* const tmp = "-s"; - return Catch::Session().run( 1, &tmp ); -} - -TEST_CASE( "Gridlogic press events", "[gridlogic]" ) -{ - for(int t = 0; t < NTRACKS; t++) - { - LooperClip* lc = jack->getLooper( t )->getClip( 0 ); - GridLogic::State s1 = lc->getState(); - lc->queuePlay(); - REQUIRE( lc->getQueuePlay() == true ); - lc->bar(); - REQUIRE( lc->getQueuePlay() == false ); - } - - int t = 0; - int s = 0; - - LooperClip* lc = jack->getLooper( t )->getClip( s ); - lc->init(); - jack->getGridLogic()->pressed( t, s ); - REQUIRE( lc->playing() == false ); - -} -#endif - diff --git a/src/looperclip.cxx b/src/looperclip.cxx index 26e6298..6d22274 100644 --- a/src/looperclip.cxx +++ b/src/looperclip.cxx @@ -297,6 +297,7 @@ void LooperClip::queuePlay(bool qP) { _queuePlay = true; _queueStop = false; + _queueRecord = false; } void LooperClip::queueStop() diff --git a/src/catch.hxx b/src/tests/catch.hxx similarity index 100% rename from src/catch.hxx rename to src/tests/catch.hxx diff --git a/src/tests/gridlogictests.cxx b/src/tests/gridlogictests.cxx new file mode 100644 index 0000000..055169a --- /dev/null +++ b/src/tests/gridlogictests.cxx @@ -0,0 +1,77 @@ + +#include "../gridlogic.hxx" + +#include "../jack.hxx" +#include "../looperclip.hxx" + +extern Jack* jack; + +#ifdef BUILD_TESTS +#define CATCH_CONFIG_RUNNER +#include "catch.hxx" +#endif + +#ifdef BUILD_TESTS +int GridLogic::runTests() +{ + char* const tmp = "-s"; + return Catch::Session().run( 1, &tmp ); +} + +TEST_CASE( "Gridlogic press events", "[gridlogic]" ) +{ + int t = 0; + int s = 0; + LooperClip* lc = jack->getLooper( t )->getClip( s ); + + for(int t = 0; t < NTRACKS; t++) + { + lc->init(); + GridLogic::State s1 = lc->getState(); + REQUIRE( lc->getState() == GridLogic::STATE_EMPTY ); + jack->getGridLogic()->launchScene( s ); + + REQUIRE( lc->getQueuePlay() == false ); + jack->getGridLogic()->bar(); + REQUIRE( lc->getQueuePlay() == true ); + + REQUIRE( jack->getGridLogic()->getLaunchedScene() == s ); + } + + + /// SCENE LAUNCH + lc->init(); + jack->getGridLogic()->launchScene( s ); + REQUIRE( jack->getGridLogic()->getLaunchedScene() == s ); + + /// PAD STATE CHECKS + // empty -> recording + lc->init(); + REQUIRE( lc->getState() == GridLogic::STATE_EMPTY ); + jack->getGridLogic()->pressed( t, s ); + jack->getGridLogic()->released( t, s ); + REQUIRE( lc->getState() == GridLogic::STATE_RECORD_QUEUED ); + jack->getGridLogic()->bar(); + REQUIRE( lc->getState() == GridLogic::STATE_RECORDING ); + // recording -> playing + jack->getGridLogic()->pressed( t, s ); + jack->getGridLogic()->released( t, s ); + REQUIRE( lc->getState() == GridLogic::STATE_PLAY_QUEUED ); + jack->getGridLogic()->bar(); + REQUIRE( lc->getState() == GridLogic::STATE_PLAYING ); + // playing -> stopped + jack->getGridLogic()->pressed( t, s ); + jack->getGridLogic()->released( t, s ); + REQUIRE( lc->getState() == GridLogic::STATE_STOP_QUEUED ); + jack->getGridLogic()->bar(); + REQUIRE( lc->getState() == GridLogic::STATE_STOPPED ); + // stopped -> playing + jack->getGridLogic()->pressed( t, s ); + jack->getGridLogic()->released( t, s ); + REQUIRE( lc->getState() == GridLogic::STATE_PLAY_QUEUED ); + jack->getGridLogic()->bar(); + REQUIRE( lc->getState() == GridLogic::STATE_PLAYING ); + +} +#endif + diff --git a/test.sh b/test.sh index ed5289f..ca75085 100755 --- a/test.sh +++ b/test.sh @@ -18,11 +18,26 @@ set -e rm -rf buildTest/src/ tup upd buildTest/ +if [ $? -eq 0 ]; then + notify-send -t 5 "Luppp: Compiled successfully..." + echo OK +else + notify-send -t 0 --urgency=critical "Luppp: Compilation FAILURE!" + echo FAIL +fi cd buildTest/ ./luppp +if [ $? -eq 0 ]; then + notify-send -t 5 "Luppp: Tests passed successfully..." + echo OK +else + notify-send -t 5 -u critical "Luppp: Test FAILURE!" + echo FAIL +fi + cd src gcov -r -b * @@ -30,4 +45,5 @@ cp -r ../../src/* ./ lcov --directory . --capture --output-file lcov.info genhtml lcov.info -firefox index.html +notify-send -t 5 "Luppp: Test data available..." +firefox src/index.html