From b52ab62cafa0f79bde5fcd1ca142ff98ce041b31 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 13 Jan 2017 08:01:37 +0100 Subject: [PATCH] SessionCommand: define function test for message based invocation the intention is to cover more of the full invocation path, without running all of the application infrastructure. So this second test cases simulates how messages are handled in CoreService, where the CommandHandler (visitor) actually invokes the SessionCommand facade --- src/gui/ctrl/mutation-message.hpp | 2 +- src/gui/interact/invocation-trail.hpp | 3 +- .../control/session-command-function-test.cpp | 34 +++++++++++++++---- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/gui/ctrl/mutation-message.hpp b/src/gui/ctrl/mutation-message.hpp index e83b14a9c..6680acc7f 100644 --- a/src/gui/ctrl/mutation-message.hpp +++ b/src/gui/ctrl/mutation-message.hpp @@ -109,7 +109,7 @@ namespace ctrl{ * @note this is a pragmatic guess, based on the actual usage pattern within Lumiera. * This determines the size of the inline buffer within MutationMessage. * You'll get an static assertion failure when creating a MutationMessage - * from a concrete diff representation requiring more size... + * from a concrete diff representation requires more storage space... */ enum { SIZE_OF_DIFF_REPRESENTATION = sizeof(std::vector) + sizeof(size_t) diff --git a/src/gui/interact/invocation-trail.hpp b/src/gui/interact/invocation-trail.hpp index f9fef5730..e7a4b9f7f 100644 --- a/src/gui/interact/invocation-trail.hpp +++ b/src/gui/interact/invocation-trail.hpp @@ -33,7 +33,7 @@ ** actual values is tracked by an [InvocationTrail] handle. When ** ready, finally this handle can be issued on any [BusTerm]. ** - ** @todo as of 11/2015 this is complete WIP-WIP-WIP + ** @todo as of 11/2015 this is more of a concept draft ** ** @see ////TODO_test usage example ** @@ -86,6 +86,7 @@ namespace interact { * exist somewhere in the system and IDs to be sent over the bus, without the certainty * of a real invocation site and a matching command operation to exist somewhere else * within the system. + * @todo do we need an alternative ctor based on plain command-ID? ///////////////////////////TICKET #1060 : create a dedicated command-ID type? */ InvocationTrail(proc::control::Command prototype) : cmdID_(prototype.getID()) diff --git a/tests/core/proc/control/session-command-function-test.cpp b/tests/core/proc/control/session-command-function-test.cpp index e7f56f8ef..1c76555ad 100644 --- a/tests/core/proc/control/session-command-function-test.cpp +++ b/tests/core/proc/control/session-command-function-test.cpp @@ -30,9 +30,7 @@ extern "C" { #include "proc/control/proc-dispatcher.hpp" #include "proc/control/command-def.hpp" #include "gui/ctrl/command-handler.hpp" -#include "proc/asset/meta/time-grid.hpp" -#include "lib/time/timequant.hpp" -#include "lib/time/timecode.hpp" +#include "gui/interact/invocation-trail.hpp" #include "lib/format-obj.hpp" #include "lib/format-cout.hpp" //////////TODO #include "lib/symbol.hpp" @@ -50,7 +48,9 @@ namespace test { // using std::function; // using std::rand; using lib::test::randTime; + using gui::interact::InvocationTrail; using gui::ctrl::CommandHandler; + using lib::diff::GenNode; using lib::diff::Rec; using lib::time::Time; using lib::time::TimeVar; @@ -86,7 +86,7 @@ namespace test { void undoIt (Duration, Offset, int, Time oldState) { -// dummyState = oldState; + testCommandState = oldState; } @@ -200,7 +200,7 @@ namespace test { SessionCommand::facade().invoke(cmdID); __DELAY__ - CHECK (testCommandState - prevState == Time(0, 1)); + CHECK (testCommandState - prevState == Time(0, 1)); // execution added 1500ms -1*500ms == 1sec } @@ -214,7 +214,29 @@ namespace test { void perform_messageInvocation() { - UNIMPLEMENTED ("invoke via message"); + // this happens "somewhere" in the UI interaction control framework + InvocationTrail invoTrail{Command(COMMAND_ID)}; + + // this happens within some tangible UI element (widget / controller) + GenNode argumentBindingMessage = invoTrail.bindMsg (Rec{Duration(25,10), Time(500,0), -2}); + GenNode commandTriggerMessage = invoTrail.bangMsg (); + CHECK (argumentBindingMessage.idi == commandTriggerMessage.idi); + + // this happens, when CoreService receives command messages from UI-Bus + CommandHandler handler1{argumentBindingMessage}; + argumentBindingMessage.data.accept(handler1); // handler is a visitor for the message payload + + CHECK (Command::canExec(COMMAND_ID)); + CHECK (not Command::canUndo(COMMAND_ID)); + Time prevState = testCommandState; + + // now handling the message to trigger execution + CommandHandler handler2{commandTriggerMessage}; + commandTriggerMessage.data.accept(handler2); + + __DELAY__ + CHECK (Command::canUndo(COMMAND_ID)); + CHECK (testCommandState - prevState == Time(500, 1)); // execution added 2500ms -2*500ms == 1.5sec }