54#include <sigc++/signal.h>
78 using LERR_(WRONG_TYPE);
100 undoIt (
int,
int oldState)
122 auto arg = commandMsg.
data.
get<Rec>().scope()->data.get<
int>();
209 CHECK (mock.verify(
"ctor"));
210 CHECK (mock.verifyEvent(
"create",
"dummy"));
211 CHECK (mock.verify(
"ctor").arg(
"dummy",
"TestNexus").on(&mock));
213 CHECK (
"dummy" == mock.getID().getSym());
216 CHECK (!mock.verifyCall(
"reset"));
220 CHECK (mock.isExpanded());
223 CHECK (mock.verify(
"reset"));
224 CHECK (mock.verifyCall(
"reset"));
225 CHECK (mock.verifyCall(
"reset").on(&mock));
226 CHECK (mock.verifyCall(
"reset").on(
"dummy"));
227 CHECK (mock.verifyEvent(
"reset"));
228 CHECK (mock.verify(
"reset").after(
"ctor"));
229 CHECK (mock.verify(
"ctor").before(
"reset"));
230 CHECK (mock.ensureNot(
"reset").before(
"ctor"));
231 CHECK (mock.ensureNot(
"ctor").after(
"reset"));
233 CHECK (mock.verify(
"reset").beforeEvent(
"reset"));
234 CHECK (mock.verifyCall(
"reset").beforeEvent(
"reset"));
235 CHECK (!mock.verifyCall(
"reset").afterEvent(
"reset"));
237 CHECK (!mock.isTouched());
238 CHECK (!mock.isExpanded());
240 mock.markMsg(
"qui dolorem ipsum quia dolor sit amet consectetur adipisci velit.");
241 CHECK (mock.verifyMark(
"Message",
"dolor"));
242 CHECK (mock.verifyCall(
"doMsg"));
243 CHECK (mock.verifyCall(
"doMsg").arg(
"lorem ipsum"));
244 CHECK (mock.verifyCall(
"doMsg").argMatch(
"dolor.+dolor\\s+"));
245 CHECK (mock.verifyMatch(
"Rec\\(mark.+ID = Message.+\\{.+lorem ipsum"));
253 MockElm foo(
"foo"), bar(
"bar");
254 foo.verify(
"ctor").arg(
"foo");
259 mock.ensureNot(
"foo");
260 CHECK (!foo.ensureNot(
"foo"));
269 CHECK (mock.verifyEvent(
"logJoin",
"bar")
270 .beforeEvent(
"logJoin",
"foo"));
271 CHECK (mock.verifyEvent(
"create",
"foo"));
279 foo.markMsg(
"dummy killed");
289 CHECK (nexusLog.
verifyEvent(
"dummy successfully zombificated")
291 .
beforeEvent(
"error",
"sent note message to ZombieNexus"));
294 cout <<
"____Event-Log_________________\n"
296 <<
"\n───╼━━━━━━━━━╾────────────────"<<endl;
298 cout <<
"____Nexus-Log_________________\n"
300 <<
"\n───╼━━━━━━━━━╾────────────────"<<endl;
314 .captureUndo (capture)
315 .undoOperation (undoIt);
322 int prevState = dummyState;
323 int concreteParam = 1 + rani(100);
326 CHECK (nexusLog.ensureNot(
string(DUMMY_CMD_ID)));
330 mock.
invoke (DUMMY_CMD_ID, concreteParam);
331 CHECK (dummyState == concreteParam);
332 CHECK (nexusLog.verifyCall(
"act").arg(
"«int»|" +toString(concreteParam))
333 .beforeEvent(
"bind and trigger command \""+DUMMY_CMD_ID));
337 CHECK (dummyState == prevState);
339 cout <<
"____Nexus-Log_________________\n"
341 <<
"\n───╼━━━━━━━━━╾────────────────"<<endl;
369 sigc::signal<void> trigger_expand;
370 sigc::signal<void> trigger_collapse;
381 CHECK (nexusLog.ensureNot(
"state-mark"));
391 CHECK (nexusLog.verifyCall(
"note").arg(targetID,
GenNode{
"expand", true})
392 .before(
"handling state-mark"));
402 CHECK (nexusLog.verifyCall(
"note").arg(targetID,
GenNode{
"expand", true})
403 .before(
"handling state-mark")
404 .beforeCall(
"note").arg(targetID,
GenNode{
"expand", false})
405 .before(
"handling state-mark"));
414 CHECK (nexusLog.ensureNot(
"handling state-mark")
415 .beforeCall(
"note").arg(targetID,
GenNode{
"expand", false})
416 .before(
"handling state-mark")
417 .beforeCall(
"note").arg(targetID,
GenNode{
"expand", false}));
422 auto stateMark =
GenNode{
"expand",
true};
428 uiBus.mark (targetID, stateMark);
430 CHECK (nexusLog.verifyCall(
"mark").arg(targetID, stateMark)
431 .before(
"delivered mark to "+
string(targetID)).arg(stateMark));
444 uiBus.mark (targetID,
GenNode{
"reset",
true});
456 cout <<
"____Event-Log_________________\n"
458 <<
"\n───╼━━━━━━━━━╾────────────────"<<endl;
460 cout <<
"____Nexus-Log_________________\n"
462 <<
"\n───╼━━━━━━━━━╾────────────────"<<endl;
479 sigc::signal<void> trigger_reveal;
486 CHECK (nexusLog.ensureNot(
"state-mark"));
488 bool revealed =
false;
497 CHECK (
true == revealed);
505 CHECK (nexusLog.verifyCall(
"note").arg(targetID,
GenNode{
"expand", true})
506 .before(
"handling state-mark"));
511 auto stateMark =
GenNode{
"reveal", 47};
513 CHECK (nexusLog.ensureNot(
"reveal"));
515 uiBus.mark (targetID, stateMark);
517 CHECK (
true == revealed);
523 CHECK (nexusLog.verifyCall(
"mark").arg(targetID, stateMark)
524 .after(
"handling state-mark")
526 .beforeEvent(
"delivered mark"));
534 CHECK (nexusLog.ensureNot(
"note")
535 .afterCall(
"mark").arg(targetID, stateMark)
536 .after(
"handling state-mark"));
540 cout <<
"____Event-Log_________________\n"
542 <<
"\n───╼━━━━━━━━━╾────────────────"<<endl;
544 cout <<
"____Nexus-Log_________________\n"
546 <<
"\n───╼━━━━━━━━━╾────────────────"<<endl;
572 uiBus.mark (targetID,
GenNode{
"Flash",
true });
580 uiBus.mark (targetID,
GenNode{
"Error",
"getting serious"});
583 CHECK (
"getting serious" == mock.
getError());
586 uiBus.mark (targetID,
GenNode{
"Message",
"by mistake"});
587 CHECK (mock.
verifyMark(
"Message",
"mistake"));
589 CHECK (
"getting serious" == mock.
getError());
591 CHECK (mock.
verify(
"target")
602 CHECK (nexusLog.verifyCall(
"mark").arg(targetID,
Time::NEVER));
603 CHECK (nexusLog.ensureNot(
"delivered mark").arg(
Time::NEVER));
604 CHECK (
"getting serious" == mock.
getError());
612 cout <<
"____Event-Log_________________\n"
614 <<
"\n───╼━━━━━━━━━╾────────────────"<<endl;
616 cout <<
"____Nexus-Log_________________\n"
618 <<
"\n───╼━━━━━━━━━╾────────────────"<<endl;
661 rootMock.
attrib[
"α"] =
"Centauri";
662 CHECK (
"Centauri" == rootMock.
attrib[
"α"]);
663 CHECK (isnil (rootMock.
scope));
670 ATTRIB_AL =
GenNode(
"α",
"quadrant"),
671 ATTRIB_PI =
GenNode(
"π", 3.14159265),
672 CHILD_1 = MakeRec().
genNode(
"a"),
673 CHILD_2 = MakeRec().
genNode(
"b");
697 uiBus.change(rootID, diffSrc.generateDiff());
704 CHECK (2 == rootMock.
scope.size());
705 CHECK (rootMock.
attrib[
"α"] ==
"quadrant");
706 CHECK (childA.
getID() == diffSrc.CHILD_1.idi);
707 CHECK (childB.
getID() == diffSrc.CHILD_2.idi);
708 CHECK (childB.
attrib[
"π"] ==
"3.1415927");
725 CHECK (nexusLog.verifyCall(
"routeAdd").arg(rootMock.
getID(),
memLocation(rootMock))
726 .beforeCall(
"change") .argMatch(rootMock.
getID(),
727 "after.+ins.+ins.+set.+mut.+ins.+emu")
730 .beforeEvent(
"applied diff to "+
string(rootMock.
getID()))
733 cout <<
"____Event-Log_________________\n"
735 <<
"\n───╼━━━━━━━━━╾────────────────"<<endl;
737 cout <<
"____Nexus-Log_________________\n"
739 <<
"\n───╼━━━━━━━━━╾────────────────"<<endl;
Token or Atom with distinct identity.
object-like record of data.
type erased baseclass for building a combined hash and symbolic ID.
string const & getSym() const
Helper to log and verify the occurrence of events.
EventMatch verify(string match) const
start a query to match for some substring.
EventMatch verifyEvent(string match) const
start a query to match for some event.
EventMatch ensureNot(string match) const
start a query to ensure the given expression does not match.
EventMatch & afterCall(string match)
find a function invocation backwards, before the current point of reference
EventMatch & arg(ARGS const &...args)
refine filter to additionally require specific arguments
EventMatch & before(string match)
find a match (substring match) of the given text in an EventLog entry after the current position
EventMatch & beforeEvent(string match)
find a match for an "event" after the current point of reference
EventMatch & afterEvent(string match)
EventMatch & on(string targetID)
refine filter to additionally match the ‘'this’` attribute
EventMatch & beforeCall(string match)
find a match for some function invocation after the current point of reference
Lumiera's internal time value datatype.
static const Time NEVER
border condition marker value. NEVER >= any time value
Interface common to all UI elements of relevance for the Lumiera application.
void slotReveal()
Cause the element to be brought into sight.
void invoke(Symbol cmdID, ARGS &&...)
void slotCollapse()
Collapse or minimise this element and remember the collapsed state.
void installRevealer(Revealer::RevealeItFun)
Configure the (optional) functionality to bring the UI-Element into sight.
void reset()
invoke the generic reset hook
void slotExpand()
Expand this element and remember the expanded state.
void verify_mockManipulation()
static string memLocation(Tangible &uiElm)
Mock UI element or controller.
string getMessage() const
EventMatch verifyMark(string id) const
special verification match on a "state mark" message to this element
EventLog const & getLog() const
EventMatch verify(string match) const
std::map< string, string > attrib
std::vector< PMockElm > scope
EventMatch verifyCall(string match) const
EventMatch verifyEvent(string match) const
EventMatch ensureNot(string match) const
EventLog & joinLog(MockElm &otherMock)
static ctrl::BusTerm & testUI()
get a connection point to a UI backbone faked for test
static void setCommandHandler(CommandHandler=CommandHandler())
install a closure (custom handler function) to deal with any command invocations encountered in the t...
static lib::test::EventLog const & getLog()
static lib::test::EventLog const & startNewLog()
Helper class used solely for defining a Command-Object.
auto operation(FUN operation_to_define)
Handle object representing a single Command instance to be used by client code.
static Command get(Symbol cmdID)
Access existing command for use.
Actually defining a command and binding it to execution parameters.
Bare symbolic and hash ID used for accounting of asset like entries.
Lumiera error handling (C++ interface).
Support for verifying the occurrence of events from unit tests.
Generic functions to build identification schemes.
A generic interface element instrumented for unit testing.
Generic Message with an embedded diff, to describe changes to model elements.
string instanceTypeID(const TY *const obj)
designation of an distinct object instance
void processCommandInvocation(GenNode const &commandMsg)
dummy Command handler, which can be hooked up to the TestNexus and causes a real command invocation o...
const Symbol DUMMY_CMD_ID
lib::idi::BareEntryID const & ID
Lumiera GTK UI implementation root.
Test runner and basic definitions for tests.
std::string toString(TY const &val) noexcept
get some string representation of any object, reliably.
string join(COLL &&coll, string const &delim=", ")
enumerate a collection's contents, separated by delimiter.
bool isnil(lib::time::Duration const &dur)
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
generic data element node within a tree
Opaque message to effect a structural change on a target, which is likewise only known in an abstract...
Constructor for a specially crafted 'ref GenNode'.
static const Ref ATTRIBS
symbolic ID ref "_ATTRIBS_"
typed symbolic and hash ID for asset-like position accounting.
Marker types to indicate a literal string and a Symbol.
A collection of frequently used helper functions to support unit testing.
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
#define MARK_TEST_FUN
Macro to mark the current test function in STDOUT.
A fake UI backbone for investigations and unit testing.
a family of time value like entities and their relationships.
A token language to represent structural changes in a tree like hierarchical data structure.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...