From de71baccc3c81d60600c6d64c0700b6b7dda67e4 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 12 Jan 2016 02:59:16 +0100 Subject: [PATCH] use a inline command handler to actually invoke. Unit test PASS Wow! This innocuous little commit integrates several subsystems for the first time And all worked right away! --- tests/gui/abstract-tangible-test.cpp | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/gui/abstract-tangible-test.cpp b/tests/gui/abstract-tangible-test.cpp index 7194f145b..1592917d0 100644 --- a/tests/gui/abstract-tangible-test.cpp +++ b/tests/gui/abstract-tangible-test.cpp @@ -63,6 +63,9 @@ using lib::Symbol; using gui::test::MockElm; using lib::test::EventLog; using lib::idi::EntryID; +using lib::diff::Rec; +using lib::diff::GenNode; +using lib::diff::DataCap; using proc::control::Command; using proc::control::CommandDef; using gui::interact::InvocationTrail; @@ -96,8 +99,51 @@ namespace test { dummyState = oldState; } + + const Symbol DUMMY_CMD_ID{"test.AbstractTangibleTest_dummy_command"}; + + /** + * dummy Command handler, + * which can be hooked up to the TestNexus + * and causes a real command invocation + * when receiving invocation messages + * @warning all hard wired -- works only for this command + */ + void + processCommandInvocation (GenNode const& commandMsg) + { + REQUIRE (string(DUMMY_CMD_ID) == commandMsg.idi.getSym()); + + class CommandBindingDetector + : public DataCap::Predicate + { + bool + handle (Rec const& binding) override + { + auto cmd = Command::get(DUMMY_CMD_ID); + auto arg = binding.scope()->data.get(); + + cmd.bind (arg); + return true; + } + + bool + handle (int const&) override + { + auto cmd = Command::get(DUMMY_CMD_ID); + + cmd(); + return true; + } + } + commandInvoker; + + commandMsg.data.accept (commandInvoker); + } + + }//(End) test fixture @@ -265,6 +311,8 @@ namespace test { .captureUndo (capture) .undoOperation (undoIt); + gui::test::Nexus::setCommandHandler (&processCommandInvocation); + // Usually it's the InvocationStateManager's job to // prepare an "InvocationTrail", which is a prospective // Command invocation about to happen soon. @@ -295,6 +343,10 @@ namespace test { cout << "____Nexus-Log_________________\n" << util::join(nexusLog, "\n") << "\n───╼━━━━━━━━━╾────────────────"<