...and back to #975 : draft command invocation on UI elements

First part is to define the steps (the protocol) at the
model element level, which gets a command prepared and invoked.

Test fails still, because there is no actual argument binding
invoked in the TestNexus
This commit is contained in:
Fischlurch 2016-01-12 02:14:06 +01:00
parent 30362c59bc
commit a5ca8ed3b1
3 changed files with 119 additions and 4 deletions

View file

@ -36,6 +36,7 @@ namespace control {
namespace test {
using lib::P;
using lib::newP;
using lib::time::Time;
using lib::time::TimeVar;
using lib::time::TimeValue;
@ -93,7 +94,7 @@ namespace test {
int randVal ((rand() % 10) - 5);
Time five(TimeValue(5));
TimeValue randomTime(randVal);
P<TimeVar> obj (new TimeVar(five));
auto obj = newP<TimeVar>(five);
CommandDef ("test.command1")
.operation (operate)

View file

@ -51,15 +51,21 @@
#include "test/mock-elm.hpp"
#include "test/test-nexus.hpp"
#include "lib/idi/entry-id.hpp"
#include "proc/control/command-def.hpp"
#include "lib/format-cout.hpp"
#include "lib/symbol.hpp"
#include "lib/error.hpp"
//#include "lib/util.hpp"
using lib::Symbol;
using gui::test::MockElm;
using lib::test::EventLog;
using lib::idi::EntryID;
using proc::control::Command;
using proc::control::CommandDef;
using gui::interact::InvocationTrail;
@ -69,6 +75,29 @@ namespace test {
namespace { // test fixture...
// dummy operation to be invoked through the command system
int dummyState = 0;
void
operate (int val)
{
dummyState = val;
}
int
capture (int)
{
return dummyState;
}
void
undoIt (int, int oldState)
{
dummyState = oldState;
}
const Symbol DUMMY_CMD_ID{"test.AbstractTangibleTest_dummy_command"};
}//(End) test fixture
@ -224,10 +253,48 @@ namespace test {
}
void
invokeCommand ()
{
UNIMPLEMENTED ("invoke an action, pass arguments");
EventLog nexusLog = gui::test::Nexus::startNewLog();
// Setup test stage: define an command/action "in Proc"
CommandDef (DUMMY_CMD_ID)
.operation (operate)
.captureUndo (capture)
.undoOperation (undoIt);
// Usually it's the InvocationStateManager's job to
// prepare an "InvocationTrail", which is a prospective
// Command invocation about to happen soon.
InvocationTrail invTrail (Command::get (DUMMY_CMD_ID));
// the UI element relevant for this command invocation
MockElm mock("uiElm");
int prevState = dummyState;
int concreteParam = 1 +rand() % 100;
// now the ongoing interaction picks up parameter data
mock.prepareCommand (invTrail, lib::diff::Rec({concreteParam}));
CHECK (dummyState == prevState); // command was not yet invoked
// finally the command gets triggered
mock.issueCommand (invTrail);
CHECK (dummyState == concreteParam); // command was indeed invoked
// verify proper binding, including UNDO state capture
Command::get (DUMMY_CMD_ID).undo();
CHECK (dummyState == prevState);
cout << "____Nexus-Log_________________\n"
<< util::join(nexusLog, "\n")
<< "\n───╼━━━━━━━━━╾────────────────"<<endl;
}

View file

@ -416,10 +416,40 @@
<icon BUILTIN="button_ok"/>
</node>
</node>
<node CREATED="1448691315849" ID="ID_1198560195" MODIFIED="1448691320189" TEXT="Bindugs-Regel">
<node CREATED="1448691315849" ID="ID_1198560195" MODIFIED="1452561018347" TEXT="Bindugs-Regel">
<icon BUILTIN="hourglass"/>
<node CREATED="1448691343406" ID="ID_642235825" MODIFIED="1448691350558" TEXT="funktor"/>
<node CREATED="1448691324304" ID="ID_1103199702" MODIFIED="1448691338522" TEXT="definiert Bezugs-Quellen"/>
<node CREATED="1448691355340" ID="ID_724965495" MODIFIED="1448691465633" TEXT="liefert Record&lt;GenNode&gt;"/>
<node CREATED="1452560897720" ID="ID_1869468443" MODIFIED="1452561022338" TEXT="vorerst noch nicht impl...">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
hier geht es darum, eine Regel zu generieren,
</p>
<p>
die dann den zugrundeliegenden Command-Prototyp automatisch mit konkreten Aufrufparametern binden kann,
</p>
<p>
sobald bestimmte Umst&#228;nde im UI einschl&#228;gig werden
</p>
<p>
</p>
<p>
Das kann ich f&#252;r die ersten Tests auslassen, und stattdessen einfach
</p>
<p>
den InvocationTrail manuell im Testcode binden
</p>
</body>
</html>
</richcontent>
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
</node>
</node>
<node CREATED="1448691865257" ID="ID_1343859473" MODIFIED="1448691874244" TEXT="Command-Binding wird gesendet">
<node CREATED="1448691954533" ID="ID_966334383" MODIFIED="1448691960295" TEXT="Performance">
@ -452,9 +482,26 @@
</body>
</html></richcontent>
</node>
<node CREATED="1450490565739" ID="ID_849102091" MODIFIED="1450490602009" TEXT="implementiert ist: erstellen im InvocationTrail">
<node CREATED="1450490565739" ID="ID_849102091" MODIFIED="1452557610273" TEXT="implementiert ist: Erstellen im InvocationTrail">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1452561062226" ID="ID_444925471" MODIFIED="1452561136752" TEXT="convenience overload f&#xfc;r mehrere Argumente">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
gemeint, das Model-Element (Tangible) sollte einen solchen Overload anbieten,
</p>
<p>
der unimttelbar Datenwerte nimmt und sie in einen Argument-Record packt
</p>
</body>
</html>
</richcontent>
<icon BUILTIN="pencil"/>
</node>
<node CREATED="1450490580473" ID="ID_925248058" MODIFIED="1450490599519" TEXT="nicht implementiert: Empfangen und Binden">
<icon BUILTIN="flag-yellow"/>
</node>