50 #ifndef STAGE_TEST_MOCK_ELM_H 51 #define STAGE_TEST_MOCK_ELM_H 85 using PMockElm = std::unique_ptr<MockElm>;
107 bool expanded_{
false};
119 log_.
call(this->identify(),
string{MARK_reset});
127 log_.
event(
string{MARK_reset});
134 log_.
call(this->identify(),
string{MARK_expand}, yes);
135 return Tangible::doExpand (yes);
141 log_.
call(this->identify(),
string{MARK_reveal});
142 Tangible::doReveal();
146 doMsg (
string text)
override 148 log_.
call (this->identify(),
"doMsg", text);
149 cout << this->identify() <<
" <-- Message(\""<<text<<
"\")" <<endl;
152 log_.note (
"type=mark",
"ID=Message", text);
158 doClearMsg ()
override 160 log_.
call (this->identify(),
"doClearMsg");
161 if (isnil (message_))
165 log_.note (
"type=mark",
"ID=Message",
"Message notification cleared");
170 doErr (
string text)
override 172 log_.
call (this->identify(),
"doErr", text);
173 cerr << this->identify() <<
" <-- Error(\""<<text<<
"\")" <<endl;
176 log_.note (
"type=mark",
"ID=Error", text);
182 doClearErr ()
override 184 log_.
call (this->identify(),
"doClearErr");
189 log_.note (
"type=mark",
"ID=Error",
"Error state cleared");
196 log_.
call (this->identify(),
"doFlash");
197 cout << this->identify() <<
" <-- Flash!" <<endl;
198 log_.note (
"type=mark",
"ID=Flash");
204 log_.
call (this->identify(),
"doMark", mark);
205 cout << this->identify() <<
" <-- state-mark = "<< mark <<endl;
206 log_.note (
"type=mark",
"ID="+mark.idi.getSym(),
mark);
208 this->virgin_ =
false;
211 Tangible::doMark (mark);
217 using Attrib = std::pair<const string,string>;
221 log_.
call (this->identify(),
"buildMutator");
222 cout << this->identify() <<
" <-- DIFF" <<endl;
227 .isApplicableIf ([&](
GenNode const& spec) ->
bool 231 .matchElement ([&](
GenNode const& spec, PMockElm
const& elm) ->
bool 233 return spec.idi == elm->getID();
235 .constructFrom ([&](
GenNode const& spec) -> PMockElm
237 log_.
event(
"diff",
"create child \""+spec.idi.getSym()+
"\"");
238 PMockElm child = std::make_unique<MockElm>(spec.idi, this->uiBus_);
239 child->joinLog(*
this);
244 if (target->getID() != subID)
return false;
245 target->buildMutator (buff);
246 log_.
event(
"diff",
">>Scope>> "+subID.getSym());
250 .isApplicableIf ([&](
GenNode const& spec) ->
bool 252 return spec.isNamed()
255 .matchElement ([&](
GenNode const& spec, Attrib
const& elm) ->
bool 257 return elm.first == spec.idi.getSym();
259 .constructFrom ([&](
GenNode const& spec) -> Attrib
261 string key{spec.idi.getSym()},
263 log_.
event(
"diff",
"++Attrib++ "+key+
" = "+val);
266 .assignElement ([&](Attrib& target,
GenNode const& spec) ->
bool 268 string key{spec.idi.getSym()},
269 newVal{
render (spec.data)};
270 log_.
event(
"diff",
"set Attrib "+key+
" <-"+newVal);
271 target.second = newVal;
275 log_.
event (
"diff", getID().getSym() +
" accepts mutation...");
297 log_.
call (this->identify(),
"ctor", identity,
string(nexus));
298 log_.
create (getID().getSym());
304 log_.
event (expanded_?
"expanded" :
"collapsed");
313 log_.
call (this->identify(),
"dtor");
314 log_.
destroy (getID().getSym());
320 cerr <<
"Error while logging shutdown of Mock-UI-Element: " << errID <<endl;
322 cerr <<
"Unknown Error while logging shutdown of Mock-UI-Element." <<endl;
342 log_.
call (this->identify(),
"kill");
343 log_.
destroy (getID().getSym());
346 log_.
event (
string(getID()) +
" successfully connected to zombie bus");
354 std::map<string, string> attrib;
355 std::vector<PMockElm> scope;
362 return uiBus_.getID();
380 return not isnil(error_);
398 verify (
string match)
const 400 return getLog().
verify(match);
404 verifyMatch (
string regExp)
const 410 verifyEvent (
string match)
const 416 verifyEvent (
string classifier,
string match)
const 422 verifyCall (
string match)
const 428 ensureNot (
string match)
const 452 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...