diff --git a/src/gui/ctrl/bus-controller.cpp b/src/gui/ctrl/bus-controller.cpp index 3ae85846f..de7e3374f 100644 --- a/src/gui/ctrl/bus-controller.cpp +++ b/src/gui/ctrl/bus-controller.cpp @@ -77,6 +77,13 @@ namespace ctrl { return std::move( BusTerm(newAddress, *this)); } + BusTerm::ID + BusTerm::getID() const + { + return endpointID_; + } + + /* ==== standard implementation of the BusTerm interface ==== */ diff --git a/src/gui/ctrl/bus-term.hpp b/src/gui/ctrl/bus-term.hpp index 4b3c0c856..4ab45d811 100644 --- a/src/gui/ctrl/bus-term.hpp +++ b/src/gui/ctrl/bus-term.hpp @@ -109,6 +109,8 @@ namespace ctrl{ BusTerm&& attach (ID newAddress); + ID getID() const; + /** may be moved, but not copied, * due to the embedded identity */ BusTerm(BusTerm&&) = default; diff --git a/src/gui/interact/interaction-state-manager.cpp b/src/gui/interact/interaction-state-manager.cpp index 95c810f50..3566f9000 100644 --- a/src/gui/interact/interaction-state-manager.cpp +++ b/src/gui/interact/interaction-state-manager.cpp @@ -58,15 +58,6 @@ namespace interact { - /** - * - * @param id - * @return - */ - string - fun (string& id) - { - return "x"+id; - } + /** nonsense */ }} // namespace gui::interact diff --git a/src/gui/interact/invocation-trail.hpp b/src/gui/interact/invocation-trail.hpp index 6fd7a821d..649add17f 100644 --- a/src/gui/interact/invocation-trail.hpp +++ b/src/gui/interact/invocation-trail.hpp @@ -51,6 +51,13 @@ #include +/** @todo unused as of 11/2015 + * some additional instantiation metadata + * could be passed alongside with the invocation. + */ +#define RESERVED_FOR_FUTURE_USE_ 42 + + namespace gui { namespace interact { @@ -84,7 +91,7 @@ namespace interact { GenNode bang() const { - return GenNode(cmdID_, FLAGS); + return GenNode(cmdID_, RESERVED_FOR_FUTURE_USE_); } operator string() const @@ -93,12 +100,6 @@ namespace interact { } private: - - /** @todo unused as of 11/2015 - * some additional instantiation metadata - * could be passed alongside with the invocation. - */ - static const int FLAGS = 42; }; diff --git a/src/gui/model/tangible.cpp b/src/gui/model/tangible.cpp index 787006b78..7cc3feaa0 100644 --- a/src/gui/model/tangible.cpp +++ b/src/gui/model/tangible.cpp @@ -59,6 +59,14 @@ namespace model { + /** */ + void + Tangible::reset() + { + this->doReset(); + } + + /** * Prepare a command or action for actual invocation, once the execution context * has been established. The action is not executed right away, but it is now ready diff --git a/src/gui/model/tangible.hpp b/src/gui/model/tangible.hpp index eec3cbca5..215fd6683 100644 --- a/src/gui/model/tangible.hpp +++ b/src/gui/model/tangible.hpp @@ -88,23 +88,23 @@ namespace model { void prepareCommand (Cmd const& prototype, Rec&& arguments); void issueCommand (Cmd const& preparedAction); - void slotExpand(); - void slotReveal(); + void slotExpand() { this->doExpand(); } + void slotReveal() { this->doReveal(); } - void noteMsg(); - void noteErr(); - void noteFlash(); - void noteMark(); + void noteMsg (string m) { this->doMsg(m); } + void noteErr (string e) { this->doErr(e); } + void noteFlash() { this->doFlash();} + void noteMark(GenNode const& n) { this->doMark(n);} protected: virtual void doReset() =0; virtual void doExpand() =0; virtual void doReveal() =0; - virtual void doMsg() =0; - virtual void doErr() =0; - virtual void doFlash() =0; - virtual void doMark() =0; + virtual void doMsg (string) =0; + virtual void doErr (string) =0; + virtual void doFlash() =0; + virtual void doMark(GenNode const&) =0; private: }; diff --git a/src/lib/test/event-log.hpp b/src/lib/test/event-log.hpp index 53dd1434d..f2b5a21c4 100644 --- a/src/lib/test/event-log.hpp +++ b/src/lib/test/event-log.hpp @@ -44,10 +44,14 @@ #include "lib/error.hpp" +#include "lib/idi/entry-id.hpp" +#include "lib/iter-adapter-stl.hpp" +#include "lib/diff/record.hpp" //#include "lib/time/timevalue.hpp" //#include -//#include +#include +#include @@ -55,16 +59,204 @@ namespace lib { namespace test{ // using lib::Literal; -// using std::string; + using std::string; // using std::rand; + /** + * @internal ongoing evaluation and match within an [EventLog]. + * @throws error::Fatal when the expected match fails (error::LUMIERA_ERROR_ASSERTION) + */ + class EventMatch + { + friend class EventLog; + + public: + + EventMatch& + before (string match) + { + UNIMPLEMENTED("process combined relational match"); + } + + EventMatch& + beforeMatch (string regExp) + { + UNIMPLEMENTED("process combined relational regular expression match"); + } + + EventMatch& + beforeEvent (string match) + { + UNIMPLEMENTED("process combined relational match"); + } + + EventMatch& + beforeCall (string match) + { + UNIMPLEMENTED("process combined relational match"); + } + + EventMatch& + after (string match) + { + UNIMPLEMENTED("process combined relational match backwards"); + } + + EventMatch& + afterMatch (string regExp) + { + UNIMPLEMENTED("process combined relational regular expression match backwards"); + } + + EventMatch& + afterEvent (string match) + { + UNIMPLEMENTED("process combined relational match backwards"); + } + + EventMatch& + afterCall (string match) + { + UNIMPLEMENTED("process combined relational match backwards"); + } + + EventMatch& + arg () + { + UNIMPLEMENTED("process match on no-arg call argument list"); + } + + template + EventMatch& + arg (string match, MORE...args) + { + UNIMPLEMENTED("process match on call argument list"); + } + + template + EventMatch& + argMatch (string regExp, MORE...args) + { + UNIMPLEMENTED("process regular expression match on call argument list"); + } + + EventMatch& + on (string sourceID) + { + UNIMPLEMENTED("process additional filter on source of log entry"); + } + }; + /** * Helper to log and verify the occurrence of events. */ class EventLog { + using Entry = lib::diff::Record; + using Log = std::vector; + using Iter = Log::const_iterator; + string logID_; + Log log_; + + public: + explicit + EventLog (string logID) + : logID_(logID) + { + UNIMPLEMENTED("initial log entry"); + } + + template + explicit + EventLog (const X *const) + : EventLog(idi::typeSymbol()) + { } + + + // standard copy operations acceptable + + + EventLog& + join (EventLog& otherLog) + { + UNIMPLEMENTED("log join"); + return *this; + } + + + + /* ==== Logging API ==== */ + + EventLog& + event (string text) + { + return *this; + } + + + template + static string + instanceHash(const X *const) + { + UNIMPLEMENTED ("generate an object instance hash"); + } + + + + /* ==== Iteration ==== */ + + bool + empty() const + { + UNIMPLEMENTED ("collection behaviour"); + } + + + typedef Iter const_iterator; + typedef const Entry value_type; + + const_iterator begin() const { return log_.begin(); } + const_iterator end() const { return log_.end(); } + + friend const_iterator begin (EventLog const& log) { return log.begin(); } + friend const_iterator end (EventLog const& log) { return log.end(); } + + + + + /* ==== Query/Verification API ==== */ + + EventMatch + verify (string match) + { + UNIMPLEMENTED("start matching sequence"); + } + + EventMatch + verifyMatch (string regExp) + { + UNIMPLEMENTED("start matching sequence for regular expression match"); + } + + EventMatch + verifyEvent (string match) + { + UNIMPLEMENTED("start matching sequence"); + } + + EventMatch + verifyCall (string match) + { + UNIMPLEMENTED("start matching sequence"); + } + + EventMatch + ensureNot (string match) + { + UNIMPLEMENTED("start matching sequence"); + } }; diff --git a/tests/gui/abstract-tangible-test.cpp b/tests/gui/abstract-tangible-test.cpp index 55d934cbb..405dfcbad 100644 --- a/tests/gui/abstract-tangible-test.cpp +++ b/tests/gui/abstract-tangible-test.cpp @@ -47,7 +47,9 @@ #include "lib/test/run.hpp" #include "lib/test/test-helper.hpp" +#include "lib/test/event-log.hpp" #include "test/mock-elm.hpp" +#include "lib/idi/entry-id.hpp" #include "lib/error.hpp" //#include "gui/model/session-facade.hpp" //#include "gui/model/diagnostics.hpp" @@ -59,6 +61,9 @@ //#include //#include +using gui::test::MockElm; +using lib::test::EventLog; +using lib::idi::EntryID; //using boost::lexical_cast; //using util::contains; //using std::string; @@ -115,12 +120,13 @@ namespace test { verify_mockManipulation () { MockElm mock("dummy"); + mock.verify("ctor"); mock.verifyEvent("ctor"); mock.verify("ctor").arg("dummy"); CHECK ("dummy" == mock.getID().getSym()); - CHECK ("ID-dummy" = string(mock.getID())); + CHECK (EntryID("dummy") == mock.getID()); VERIFY_ERROR (ASSERTION, mock.verifyCall("reset")); @@ -156,7 +162,7 @@ namespace test { .before("reset") .before("lorem ipsum"); - MockElm foo("foo"), bar; + MockElm foo("foo"), bar("bar"); foo.verify("ctor").arg("foo"); bar.verify("ctor").arg(); @@ -165,16 +171,16 @@ namespace test { mock.ensureNot("foo"); VERIFY_ERROR (ASSERTION, foo.ensureNot("foo")); - log.join(bar).join(foo); - log.verifyEvent("logJoin").arg(bar.getID()) + log.join(bar.getLog()).join(foo.getLog()); + log.verifyEvent("logJoin").arg(bar.getID().getSym()) .beforeEvent("logJoin").arg("foo"); - mock.verifyEvent("logJoin").arg(bar.getID()) + mock.verifyEvent("logJoin").arg(bar.getID().getSym()) .beforeEvent("logJoin").arg("foo"); mock.verify("ctor").arg("foo"); log.verify("ctor").arg("foo"); log.verify("ctor").arg("dummy") - .before("ctor").arg(bar.getID()) + .before("ctor").arg(bar.getID().getSym()) .before("ctor").arg("foo"); mock.kill(); diff --git a/tests/gui/test/mock-elm.hpp b/tests/gui/test/mock-elm.hpp index 967000497..bf0cb7d48 100644 --- a/tests/gui/test/mock-elm.hpp +++ b/tests/gui/test/mock-elm.hpp @@ -43,8 +43,9 @@ #include "lib/error.hpp" -#include "lib/idi/entry-id.hpp" +//#include "lib/idi/entry-id.hpp" //#include "lib/util.hpp" +#include "lib/test/event-log.hpp" #include "gui/model/tangible.hpp" #include "lib/diff/record.hpp" #include "test/nexus.hpp" @@ -56,14 +57,16 @@ namespace gui { namespace error = lumiera::error; using error::LUMIERA_ERROR_ASSERTION; + using lib::test::EventLog; + using lib::test::EventMatch; namespace test{ // using lib::HashVal; // using util::isnil; - using lib::idi::EntryID; - using lib::diff::Record; +// using lib::idi::EntryID; +// using lib::diff::Record; using std::string; @@ -81,40 +84,41 @@ namespace test{ class MockElm : public gui::model::Tangible { + EventLog log_{this}; /* ==== Tangible interface ==== */ - virtual void doReset() + virtual void doReset() override { UNIMPLEMENTED ("mock doReset"); } - virtual void doExpand() + virtual void doExpand() override { UNIMPLEMENTED ("mock doExpand"); } - virtual void doReveal() + virtual void doReveal() override { UNIMPLEMENTED ("mock doReveal"); } - virtual void doMsg() + virtual void doMsg (string text) override { UNIMPLEMENTED ("mock doMsg"); } - virtual void doErr() + virtual void doErr (string text) override { UNIMPLEMENTED ("mock doErr"); } - virtual void doFlash() + virtual void doFlash() override { UNIMPLEMENTED ("mock doFlash"); } - virtual void doMark() + virtual void doMark (GenNode const& mark) override { UNIMPLEMENTED ("mock doMark"); } @@ -124,13 +128,87 @@ namespace test{ public: explicit MockElm(string id) - : MockElm(EntryID(id)) + : MockElm(lib::idi::EntryID(id)) { } explicit MockElm(ID identity, ctrl::BusTerm& nexus =Nexus::testUI()) : gui::model::Tangible(identity, nexus) { } + + + /* ==== special operations API ==== */ + + void + kill() + { + UNIMPLEMENTED ("suicide"); + } + + + /* ==== Query/Verification API ==== */ + + ID getID() const + { + return uiBus_.getID(); + } + + EventLog& + getLog() + { + return log_; + } + + + bool + isTouched() const + { + UNIMPLEMENTED ("pristine status"); + } + + bool + isExpanded() const + { + UNIMPLEMENTED ("UI element expansion status"); + } + + + EventMatch + verify (string match) + { + return getLog().verify(match); + } + + EventMatch + verifyMatch (string regExp) + { + return getLog().verifyMatch(regExp); + } + + EventMatch + verifyEvent (string match) + { + return getLog().verifyEvent(match); + } + + EventMatch + verifyCall (string match) + { + return getLog().verifyCall(match); + } + + EventMatch + ensureNot (string match) + { + return getLog().ensureNot(match); + } + + /** special verification match on a "note" message to this element */ + EventMatch + verifyNote (string msgContentMatch) + { + UNIMPLEMENTED ("generic match"); + } }; diff --git a/tests/gui/test/nexus.cpp b/tests/gui/test/nexus.cpp index 54c8d9cde..e3b6816f3 100644 --- a/tests/gui/test/nexus.cpp +++ b/tests/gui/test/nexus.cpp @@ -66,7 +66,7 @@ namespace test{ * which allows to hook up new nodes for test */ ctrl::BusTerm& - testUI() + Nexus::testUI() { UNIMPLEMENTED("test nexus"); } diff --git a/tests/library/test/test-event-log-test.cpp b/tests/library/test/test-event-log-test.cpp index dcba18388..db6432542 100644 --- a/tests/library/test/test-event-log-test.cpp +++ b/tests/library/test/test-event-log-test.cpp @@ -24,12 +24,15 @@ #include "lib/test/run.hpp" #include "lib/test/test-helper.hpp" #include "lib/format-util.hpp" +#include "lib/test/event-log.hpp" #include "lib/error.hpp" +#include "lib/util.hpp" #include #include using util::join; +using util::isnil; using lumiera::error::LUMIERA_ERROR_ASSERTION; using std::string; @@ -50,8 +53,6 @@ namespace test{ struct Murpf { }; - void doThrow() { throw Error("because I feel like it"); } - int dontThrow() { return 2+2; } /***********************************************************//** @@ -84,9 +85,9 @@ namespace test{ VERIFY_ERROR (ASSERTION, log.verify("γ")); log.verify("α").before("β"); - VERIFY_ERROR (ASSERTION, verify("β").before("α")); + VERIFY_ERROR (ASSERTION, log.verify("β").before("α")); - CHECK (join(log) == "LOG::TestEventLog_test"+Log::instanceHash(this) + CHECK (join(log) == "LOG::TestEventLog_test"+EventLog::instanceHash(this) + ", Rec(event| |{α}), Rec(event| |{β})"); }