59 #ifndef STAGE_TEST_MOCK_ELM_H 60 #define STAGE_TEST_MOCK_ELM_H 94 using PMockElm = std::unique_ptr<MockElm>;
116 bool expanded_{
false};
128 log_.
call(this->identify(),
string{MARK_reset});
136 log_.
event(
string{MARK_reset});
143 log_.
call(this->identify(),
string{MARK_expand}, yes);
144 return Tangible::doExpand (yes);
150 log_.
call(this->identify(),
string{MARK_reveal});
151 Tangible::doReveal();
155 doMsg (
string text)
override 157 log_.
call (this->identify(),
"doMsg", text);
158 cout << this->identify() <<
" <-- Message(\""<<text<<
"\")" <<endl;
161 log_.note (
"type=mark",
"ID=Message", text);
167 doClearMsg ()
override 169 log_.
call (this->identify(),
"doClearMsg");
170 if (isnil (message_))
174 log_.note (
"type=mark",
"ID=Message",
"Message notification cleared");
179 doErr (
string text)
override 181 log_.
call (this->identify(),
"doErr", text);
182 cerr << this->identify() <<
" <-- Error(\""<<text<<
"\")" <<endl;
185 log_.note (
"type=mark",
"ID=Error", text);
191 doClearErr ()
override 193 log_.
call (this->identify(),
"doClearErr");
198 log_.note (
"type=mark",
"ID=Error",
"Error state cleared");
205 log_.
call (this->identify(),
"doFlash");
206 cout << this->identify() <<
" <-- Flash!" <<endl;
207 log_.note (
"type=mark",
"ID=Flash");
213 log_.
call (this->identify(),
"doMark", mark);
214 cout << this->identify() <<
" <-- state-mark = "<< mark <<endl;
215 log_.note (
"type=mark",
"ID="+mark.idi.getSym(),
mark);
217 this->virgin_ =
false;
220 Tangible::doMark (mark);
226 using Attrib = std::pair<const string,string>;
230 log_.
call (this->identify(),
"buildMutator");
231 cout << this->identify() <<
" <-- DIFF" <<endl;
236 .isApplicableIf ([&](
GenNode const& spec) ->
bool 240 .matchElement ([&](
GenNode const& spec, PMockElm
const& elm) ->
bool 242 return spec.idi == elm->getID();
244 .constructFrom ([&](
GenNode const& spec) -> PMockElm
246 log_.
event(
"diff",
"create child \""+spec.idi.getSym()+
"\"");
247 PMockElm child = std::make_unique<MockElm>(spec.idi, this->uiBus_);
248 child->joinLog(*
this);
253 if (target->getID() != subID)
return false;
254 target->buildMutator (buff);
255 log_.
event(
"diff",
">>Scope>> "+subID.getSym());
259 .isApplicableIf ([&](
GenNode const& spec) ->
bool 261 return spec.isNamed()
264 .matchElement ([&](
GenNode const& spec, Attrib
const& elm) ->
bool 266 return elm.first == spec.idi.getSym();
268 .constructFrom ([&](
GenNode const& spec) -> Attrib
270 string key{spec.idi.getSym()},
272 log_.
event(
"diff",
"++Attrib++ "+key+
" = "+val);
275 .assignElement ([&](Attrib& target,
GenNode const& spec) ->
bool 277 string key{spec.idi.getSym()},
278 newVal{
render (spec.data)};
279 log_.
event(
"diff",
"set Attrib "+key+
" <-"+newVal);
280 target.second = newVal;
284 log_.
event (
"diff", getID().getSym() +
" accepts mutation...");
306 log_.
call (this->identify(),
"ctor", identity,
string(nexus));
307 log_.
create (getID().getSym());
313 log_.
event (expanded_?
"expanded" :
"collapsed");
322 log_.
call (this->identify(),
"dtor");
323 log_.
destroy (getID().getSym());
329 cerr <<
"Error while logging shutdown of Mock-UI-Element: " << errID <<endl;
331 cerr <<
"Unknown Error while logging shutdown of Mock-UI-Element." <<endl;
351 log_.
call (this->identify(),
"kill");
352 log_.
destroy (getID().getSym());
355 log_.
event (
string(getID()) +
" successfully connected to zombie bus");
363 std::map<string, string> attrib;
364 std::vector<PMockElm> scope;
371 return uiBus_.getID();
389 return not isnil(error_);
407 verify (
string match)
const 409 return getLog().
verify(match);
413 verifyMatch (
string regExp)
const 419 verifyEvent (
string match)
const 425 verifyEvent (
string classifier,
string match)
const 431 verifyCall (
string match)
const 437 ensureNot (
string match)
const 461 verifyMark (
string id, X
const& something)
const EventMatch & type(string typeID)
refine filter to additionally require a matching log entry type
EventLog & event(string text)
log some text as event
virtual void doReveal() override
generic default implementation of the "reveal" functionality.
Abstraction: a tangible element of the User Interface.
string render(DataCap const &)
Hard wired key constants and basic definitions for communication with the GUI.
connection point at the UI-Bus.
bool isNested() const
determine if payload constitutes a nested scope ("object")
Support for verifying the occurrence of events from unit tests.
A fake UI backbone for investigations and unit testing.
EventMatch verifyMark(string id) const
special verification match on a "state mark" message to this element
Helper to log and verify the occurrence of events.
typed symbolic and hash ID for asset-like position accounting.
EventLog & create(string text)
Log the creation of an object.
void mark(GenNode const &)
generic handler for all incoming "state mark" messages
EventMatch verifyEvent(string match) const
start a query to match for some event.
Generic functions to build identification schemes.
static Builder< TreeMutator > build()
DSL: start building a custom adapted tree mutator, where the operations are tied by closures or wrapp...
SUB & emplace(SUB &&implementation)
move-construct an instance of a subclass into the opaque buffer
Token or Atom with distinct identity.
EventMatch verifyCall(string match) const
start a query to match especially a function call
A handle to allow for safe »remote implantation« of an unknown subclass into a given opaque InPlaceBu...
Special collection to represent object-like data.
EventMatch ensureNot(string match) const
start a query to ensure the given expression does not match.
Marker types to indicate a literal string and a Symbol.
~MockElm()
document our death in the diagnostic log.
Lumiera GTK UI implementation root.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
EventLog & call(string target, string function)
Log occurrence of a function call with no arguments.
lumiera_err lumiera_error(void)
Get and clear current error state.
EventLog & joinInto(EventLog &otherLog)
Merge this log into another log, forming a combined log.
virtual bool doExpand(bool yes) override
generic default implementation of the expand/collapse functionality.
EventMatch verifyMark(string id, string payloadMatch) const
verification match on a specific "state mark" message
void kill()
commit suicide.
EventMatch & id(string classifier)
refine filter to additionally match on the ID attribute
virtual void doMark(GenNode const &mark) override
default implementation and catch-all handler for receiving »state mark« messages. ...
static void zombificate(ctrl::BusTerm &)
kill the given [BusTerm] and implant a dead terminal in place
void installExpander(Expander::ProbeFun, Expander::ChangeFun)
Configure the (optional) functionality to expand or collapse the UI-Element.
Lumiera error handling (C++ interface).
string instanceTypeID(const TY *const obj)
designation of an distinct object instance
static ctrl::BusTerm & testUI()
get a connection point to a UI backbone faked for test
Mock UI element or controller.
EventMatch verify(string match) const
start a query to match for some substring.
EventLog & destroy(string text)
Log the destruction of an object.
EventMatch verifyMatch(string regExp) const
start a query to match with a regular expression
Interface common to all UI elements of relevance for the Lumiera application.
auto collection(COLL &coll)
Entry point to a nested DSL for setup and configuration of a collection binding.
virtual void buildMutator(TreeMutator::Handle buffer) override
build a custom implementation of the TreeMutator interface, suitably wired to cause appropriate chang...
Diagnostic helper for unit tests regarding mutation of custom data.
generic data element node within a tree
Customisable intermediary to abstract mutating operations on arbitrary, hierarchical object-like data...