implement and cover the zombie network

This commit is contained in:
Fischlurch 2015-12-26 22:56:43 +01:00
parent d7191959cf
commit a91d6a3bae
4 changed files with 73 additions and 21 deletions

View file

@ -49,6 +49,7 @@
#include "lib/test/test-helper.hpp"
#include "lib/test/event-log.hpp"
#include "test/mock-elm.hpp"
#include "test/test-nexus.hpp"
#include "lib/idi/entry-id.hpp"
#include "lib/error.hpp"
//#include "gui/model/session-facade.hpp"
@ -195,10 +196,22 @@ namespace test {
CHECK (log.verifyEvent("destroy","dummy")
.beforeCall("doMsg").on("foo"));
EventLog nexusLog = gui::test::Nexus::getLog();
CHECK (nexusLog.verifyEvent("destroy","dummy")
.beforeEvent("dummy successfully zombificated"));
mock.slotExpand();
cout << "____Event-Log________________\n"
CHECK (nexusLog.verifyEvent("dummy successfully zombificated")
.beforeCall("note").on("ZombieNexus").arg("defunct-dummy", "expand"));
cout << "____Event-Log_________________\n"
<< util::join(mock.getLog(), "\n")
<< "\n───╼━━━━━━━━━╾────────────────"<<endl;
cout << "____Nexus-Log_________________\n"
<< util::join(gui::test::Nexus::getLog(), "\n")
<< "\n───╼━━━━━━━━━╾────────────────"<<endl;
}

View file

@ -158,7 +158,7 @@ namespace test{
virtual void
doMark (GenNode const& mark) override
{
log_.call (this->identify(), "doMark");
log_.call (this->identify(), "doMark", mark);
cout << this->identify() << " <-- state-mark = "<< string(mark) <<endl;
log_.note ("type=mark", "ID="+mark.idi.getSym(), mark);
}

View file

@ -37,6 +37,7 @@
//#include "lib/symbol.hpp"
//#include "include/logging.h"
#include "test/test-nexus.hpp"
#include "lib/test/event-log.hpp"
#include "gui/ctrl/nexus.hpp"
#include "lib/diff/gen-node.hpp"
#include "lib/idi/entry-id.hpp"
@ -54,6 +55,7 @@ using std::endl;
using std::string;
//using lib::idi::EntryID;
using lib::test::EventLog;
using lib::diff::GenNode;
using gui::ctrl::BusTerm;
//using util::contains;
@ -76,6 +78,7 @@ namespace test{
class TestNexus
: public gui::ctrl::Nexus
{
EventLog log_{this};
virtual void
@ -94,14 +97,28 @@ namespace test{
virtual operator string() const
{
return lib::idi::instanceTypeID(this);
return getID().getSym()+"."+lib::idi::instanceTypeID(this);
}
public:
TestNexus()
: Nexus(*this, lib::idi::EntryID<TestNexus>("mock-UI"))
{ }
// standard copy operations
EventLog&
getLog()
{
return log_;
}
};
/** singleton instance of the [TestNexus]
* used for rigging unit tests */
lib::Depend<TestNexus> testNexus;
/**
@ -114,48 +131,64 @@ namespace test{
: public BusTerm
{
EventLog&
log()
{
return testNexus().getLog();
}
/* ==== defunct re-implementation of the BusTerm interface ==== */
virtual void
act (GenNode const& command)
{
UNIMPLEMENTED("zombie act");
log().call(this, "act", command);
log().error ("sent command invocation to ZombieNexus");
cerr << "Command " << string(command) << " -> ZombieNexus" <<endl;
}
virtual void
note (ID subject, GenNode const& mark) override
{
UNIMPLEMENTED ("zombie note.");
log().call(this, "note", subject, mark);
log().error ("sent note message to ZombieNexus");
cerr << "note message "<< string(mark)
<< " FROM:" << string(subject)
<< " -> ZombieNexus" <<endl;
}
virtual void
mark (ID subject, GenNode const& mark) override
{
UNIMPLEMENTED ("zombie mark.");
log().call(this, "mark", subject, mark);
log().error ("request to deliver mark message via ZombieNexus");
cerr << "mark message -> ZombieNexus" <<endl;
}
virtual operator string() const
{
return lib::idi::instanceTypeID(this);
return getID().getSym()+"."+lib::idi::instanceTypeID(this);
}
virtual BusTerm&
routeAdd (ID identity, Tangible& newNode) override
{
UNIMPLEMENTED ("zombie routeAdd.");
log().call(this, "routeAdd", identity, newNode);
log().error ("attempt to connect against ZombieNexus");
cerr << "connect("<<string(identity)<<" -> ZombieNexus" <<endl;
}
virtual void
routeDetach (ID node) noexcept override
{
UNIMPLEMENTED ("zombie routeDetach.");
log().call(this, "routeDetach", node);
log().error ("disconnect from ZombieNexus");
cerr << "disconnect("<<string(node)<<" -> ZombieNexus" <<endl;
}
public:
/** fabricate a "dead terminal", marked as deceased, viciously connected to itself.
* @note intentionally to be sliced right after generation.
@ -178,17 +211,12 @@ namespace test{
lib::Depend<TestNexus> testNexus;
lib::Depend<ZombieNexus> zombieNexus;
} // internal details
//NA::~NA() { }
/**
* @return reference to a node of the test UI bus,
@ -200,6 +228,13 @@ namespace test{
return testNexus();
}
lib::test::EventLog const&
Nexus::getLog()
{
return testNexus().getLog();
}
/**
* @return a defunct BusTerm with up-link to [ZombieNexus]
@ -210,10 +245,11 @@ namespace test{
{
string lateName = doomed.getID().getSym();
doomed.~BusTerm();
// log_.destroy (lateName);
testNexus().getLog().destroy (lateName);
static_assert (sizeof(BusTerm) >= sizeof(ZombieNexus), "Zombie overflow");
new(&doomed) ZombieNexus{lateName, zombieNexus()};
testNexus().getLog().event(lateName + " successfully zombificated.");
}
}} // namespace gui::test

View file

@ -45,6 +45,7 @@
#include "lib/error.hpp"
//#include "lib/idi/entry-id.hpp"
#include "gui/ctrl/bus-term.hpp"
#include "lib/test/event-log.hpp"
//#include "lib/util.hpp"
//#include "gui/model/tangible.hpp"
//#include "lib/diff/record.hpp"
@ -81,6 +82,8 @@ namespace test{
/** kill the given [BusTerm] and implant a dead terminal in place */
static void zombificate(ctrl::BusTerm&);
static lib::test::EventLog const& getLog();
};