Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MockElm Class Reference

#include "/Werk/devel/lumi/tests/gui/test/mock-elm.hpp"

Description

Mock UI element or controller.

Within Lumiera, all interface components of relevance are based on the [Tangible] interface, which we mock here for unit testing. This special implementation is instrumented to log any invocation and any messages sent or received through the UI Backbone, which is formed by the UI-Bus.

Todo:
some usage details
See also
abstract-tangible-test.cpp

Definition at line 109 of file mock-elm.hpp.

Public Member Functions

 MockElm (string id)
 
 MockElm (ID identity, ctrl::BusTerm &nexus=Nexus::testUI())
 
 ~MockElm ()
 document our death in the diagnostic log. More...
 
EventMatch ensureNot (string match) const
 
string getError () const
 
ID getID () const
 
EventLog const & getLog () const
 
string getMessage () const
 
bool isError () const
 
bool isExpanded () const
 
bool isTouched () const
 
EventLogjoinLog (MockElm &otherMock)
 
EventLogjoinLog (EventLog &otherLog)
 
void kill ()
 commit suicide. More...
 
EventMatch verify (string match) const
 
EventMatch verifyCall (string match) const
 
EventMatch verifyEvent (string match) const
 
EventMatch verifyEvent (string classifier, string match) const
 
EventMatch verifyMark (string id) const
 special verification match on a "state mark" message to this element More...
 
EventMatch verifyMark (string id, string payloadMatch) const
 verification match on a specific "state mark" message More...
 
template<typename X >
EventMatch verifyMark (string id, X const &something) const
 
EventMatch verifyMatch (string regExp) const
 
- Public Member Functions inherited from Tangible
virtual ~Tangible ()
 this is an interface More...
 
void clearErr ()
 invoke the hook to clear error markers More...
 
void clearMsg ()
 invoke the hook to clear notification messages More...
 
template<typename... ARGS>
void invoke (Symbol cmdID, ARGS &&...)
 
void invoke (Symbol cmdID, Rec &&arguments)
 Perform a command or action, once the execution context has been established. More...
 
template<typename... ARGS>
void invoke (Symbol cmdID, ARGS &&...args)
 convenience shortcut to issue a command with several arguments More...
 
void mark (GenNode const &)
 generic handler for all incoming "state mark" messages More...
 
void markErr (string error)
 push an error state tag to the element More...
 
void markFlash ()
 highlight the element visually to catch the user's attention More...
 
void markMsg (string message)
 push a notification (or warning) message to the element. More...
 
 operator ID () const
 
 operator LuidH () const
 
void reset ()
 invoke the generic reset hook More...
 
void slotCollapse ()
 Collapse or minimise this element and remember the collapsed state. More...
 
void slotExpand ()
 Expand this element and remember the expanded state. More...
 
void slotReveal (ID child)
 
- Public Member Functions inherited from DiffMutable
virtual ~DiffMutable ()
 this is an interface More...
 

Public Attributes

std::map< string, string > attrib
 
std::vector< PMockElmscope
 

Protected Member Functions

string identify () const
 
- Protected Member Functions inherited from Tangible
 Tangible (ID identity, ctrl::BusTerm &nexus)
 

Private Types

using _Par = gui::model::Tangible
 

Private Member Functions

virtual void buildMutator (TreeMutator::Handle buffer) override
 build a custom implementation of the TreeMutator interface, suitably wired to cause appropriate changes to the opaque data structure, in accordance to the semantics of the tree diff language. More...
 
virtual bool doClearErr () override
 
virtual bool doClearMsg () override
 
virtual bool doErr (string text) override
 
virtual bool doExpand (bool yes) override
 
virtual void doFlash () override
 
virtual void doMark (GenNode const &mark) override
 default implementation and catch-all handler for receiving »state mark« messages. More...
 
virtual bool doMsg (string text) override
 
virtual bool doReset () override
 
virtual void doReveal (ID child) override
 
virtual void doRevealYourself () override
 

Private Attributes

string error_
 
bool expanded_
 
EventLog log_
 
string message_
 
bool virgin_
 

Additional Inherited Members

- Public Types inherited from Tangible
using ID = ctrl::BusTerm::ID
 
using LuidH = lib::hash::LuidH
 
- Protected Types inherited from Tangible
using GenNode = lib::diff::GenNode
 
using Rec = lib::diff::Rec
 
- Protected Attributes inherited from Tangible
ctrl::BusTerm uiBus_
 

Member Typedef Documentation

using _Par = gui::model::Tangible
private

Definition at line 112 of file mock-elm.hpp.

Constructor & Destructor Documentation

MockElm ( string  id)
inlineexplicit

Definition at line 310 of file mock-elm.hpp.

MockElm ( ID  identity,
ctrl::BusTerm nexus = Nexus::testUI() 
)
inlineexplicit

Definition at line 315 of file mock-elm.hpp.

References EventLog::call(), EventLog::create(), MockElm::getID(), MockElm::identify(), and MockElm::log_.

+ Here is the call graph for this function:

~MockElm ( )
inline

document our death in the diagnostic log.

Definition at line 324 of file mock-elm.hpp.

References EventLog::call(), EventLog::destroy(), MockElm::getID(), MockElm::identify(), MockElm::log_, and lumiera_error().

+ Here is the call graph for this function:

Member Function Documentation

virtual bool doReset ( )
inlineoverrideprivatevirtual

Implements Tangible.

Definition at line 127 of file mock-elm.hpp.

References EventLog::call(), EventLog::event(), MockElm::expanded_, MockElm::identify(), MockElm::log_, and MockElm::virgin_.

+ Here is the call graph for this function:

virtual bool doExpand ( bool  yes)
inlineoverrideprivatevirtual

Implements Tangible.

Definition at line 142 of file mock-elm.hpp.

References EventLog::call(), EventLog::event(), MockElm::expanded_, MockElm::identify(), MockElm::log_, and MockElm::virgin_.

+ Here is the call graph for this function:

virtual void doReveal ( ID  child)
inlineoverrideprivatevirtual

Implements Tangible.

Definition at line 155 of file mock-elm.hpp.

virtual void doRevealYourself ( )
inlineoverrideprivatevirtual

Implements Tangible.

Definition at line 161 of file mock-elm.hpp.

virtual bool doMsg ( string  text)
inlineoverrideprivatevirtual

Implements Tangible.

Definition at line 167 of file mock-elm.hpp.

References EventLog::call(), MockElm::identify(), MockElm::log_, EventLog::note(), and MockElm::virgin_.

+ Here is the call graph for this function:

virtual bool doClearMsg ( )
inlineoverrideprivatevirtual

Implements Tangible.

Definition at line 179 of file mock-elm.hpp.

References EventLog::call(), MockElm::identify(), util::isnil(), MockElm::log_, and EventLog::note().

+ Here is the call graph for this function:

virtual bool doErr ( string  text)
inlineoverrideprivatevirtual

Implements Tangible.

Definition at line 191 of file mock-elm.hpp.

References EventLog::call(), MockElm::identify(), MockElm::log_, EventLog::note(), and MockElm::virgin_.

+ Here is the call graph for this function:

virtual bool doClearErr ( )
inlineoverrideprivatevirtual

Implements Tangible.

Definition at line 203 of file mock-elm.hpp.

References EventLog::call(), MockElm::identify(), MockElm::isError(), MockElm::log_, and EventLog::note().

+ Here is the call graph for this function:

virtual void doFlash ( )
inlineoverrideprivatevirtual

Implements Tangible.

Definition at line 215 of file mock-elm.hpp.

References EventLog::call(), MockElm::identify(), MockElm::log_, and EventLog::note().

+ Here is the call graph for this function:

virtual void doMark ( GenNode const &  stateMark)
inlineoverrideprivatevirtual

default implementation and catch-all handler for receiving »state mark« messages.

Such messages serve either to cause a presentation state effect specific to this element, or they are used to re-play a former state change to restore some specific UI state captured within a past working session. Events handled here:

  • expand with a bool argument calls the doExpand(bool) virtual function. It is up to the concrete element to give this a tangible meaning, e.g. a track might switch to detail view and a clip might reveal attached effects.
  • reset restores the element to the hard wired default, by invoking doReset()
  • revealYourself prompts the element to take the necessary actions to bring itself into view. There is no requirement for an element to even implement this call, but those which do typically know some kind of _"parent object"_ to forward this request, by invoking doReveal(myID) on this parent. For instance, a clip might ask the enclosing track, which in turn might call the enclosing timeline display for help, resulting in a scroll action to bring the clip into sight.
    Note
    this is a default implementation for a virtual function declared abstract with the intention for derived classes to tail-call this default handler.

Implements Tangible.

Definition at line 223 of file mock-elm.hpp.

References EventLog::call(), BareEntryID::getSym(), MockElm::identify(), GenNode::idi, MockElm::log_, Tangible::mark(), EventLog::note(), and MockElm::virgin_.

+ Here is the call graph for this function:

virtual void buildMutator ( TreeMutator::Handle  buffer)
inlineoverrideprivatevirtual

build a custom implementation of the TreeMutator interface, suitably wired to cause appropriate changes to the opaque data structure, in accordance to the semantics of the tree diff language.

Parameters
buffera buffer handle, which can be used to placement-construct

Implements Tangible.

Definition at line 236 of file mock-elm.hpp.

References MockElm::attrib, TreeMutator::build(), EventLog::call(), GenNode::data, EventLog::event(), MockElm::getID(), BareEntryID::getSym(), MockElm::identify(), GenNode::idi, GenNode::isNamed(), DataCap::isNested(), MockElm::log_, MockElm::scope, and Tangible::uiBus_.

+ Here is the call graph for this function:

string identify ( ) const
inlineprotected

Definition at line 302 of file mock-elm.hpp.

References MockElm::getID(), and lib::idi::instanceTypeID().

Referenced by MockElm::buildMutator(), MockElm::doClearErr(), MockElm::doClearMsg(), MockElm::doErr(), MockElm::doExpand(), MockElm::doFlash(), MockElm::doMark(), MockElm::doMsg(), MockElm::doReset(), MockElm::kill(), MockElm::MockElm(), and MockElm::~MockElm().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void kill ( )
inline

commit suicide.

Warning
admittedly a wonky operation
Remarks
here the mock emulates the act of dying, by snuffing the UI-Bus connection sneakily. We leave the dead corpse hanging around, just for sake of further investigation, of course.

Definition at line 354 of file mock-elm.hpp.

References EventLog::call(), EventLog::destroy(), EventLog::event(), MockElm::getID(), MockElm::identify(), MockElm::log_, Tangible::uiBus_, and Nexus::zombificate().

+ Here is the call graph for this function:

ID getID ( ) const
inline

Definition at line 374 of file mock-elm.hpp.

References BusTerm::getID(), and Tangible::uiBus_.

Referenced by MockElm::buildMutator(), BusTerm_test::captureStateMark(), BusTerm_test::clearStates(), MockElm::identify(), MockElm::kill(), AbstractTangible_test::markState(), MockElm::MockElm(), AbstractTangible_test::mutate(), AbstractTangible_test::notify(), BusTerm_test::pushDiff(), BusTerm_test::replayStateMark(), BusTerm_test::verifyNotifications(), and MockElm::~MockElm().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool isTouched ( ) const
inline

Definition at line 380 of file mock-elm.hpp.

References MockElm::virgin_.

Referenced by BusTerm_test::clearStates(), AbstractTangible_test::markState(), BusTerm_test::replayStateMark(), and BusTerm_test::verifyNotifications().

+ Here is the caller graph for this function:

bool isExpanded ( ) const
inline

Definition at line 386 of file mock-elm.hpp.

References MockElm::expanded_.

Referenced by BusTerm_test::clearStates(), AbstractTangible_test::markState(), and BusTerm_test::replayStateMark().

+ Here is the caller graph for this function:

bool isError ( ) const
inline

Definition at line 392 of file mock-elm.hpp.

References util::isnil().

Referenced by BusTerm_test::clearStates(), MockElm::doClearErr(), AbstractTangible_test::notify(), and BusTerm_test::verifyNotifications().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

string getMessage ( ) const
inline

Definition at line 398 of file mock-elm.hpp.

References MockElm::message_.

Referenced by BusTerm_test::clearStates(), AbstractTangible_test::notify(), and BusTerm_test::verifyNotifications().

+ Here is the caller graph for this function:

string getError ( ) const
inline

Definition at line 404 of file mock-elm.hpp.

References MockElm::error_.

Referenced by BusTerm_test::clearStates(), AbstractTangible_test::notify(), and BusTerm_test::verifyNotifications().

+ Here is the caller graph for this function:

EventMatch verify ( string  match) const
inline

Definition at line 412 of file mock-elm.hpp.

References MockElm::getLog(), and EventLog::verify().

Referenced by AbstractTangible_test::notify(), and AbstractTangible_test::verify_mockManipulation().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EventMatch verifyMatch ( string  regExp) const
inline

Definition at line 418 of file mock-elm.hpp.

References MockElm::getLog(), and EventLog::verifyMatch().

+ Here is the call graph for this function:

EventMatch verifyEvent ( string  match) const
inline

Definition at line 424 of file mock-elm.hpp.

References MockElm::getLog(), and EventLog::verifyEvent().

Referenced by AbstractTangible_test::markState(), and AbstractTangible_test::mutate().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EventMatch verifyEvent ( string  classifier,
string  match 
) const
inline

Definition at line 430 of file mock-elm.hpp.

References MockElm::getLog(), and EventLog::verifyEvent().

+ Here is the call graph for this function:

EventMatch verifyCall ( string  match) const
inline

Definition at line 436 of file mock-elm.hpp.

References MockElm::getLog(), and EventLog::verifyCall().

Referenced by AbstractTangible_test::markState().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EventMatch ensureNot ( string  match) const
inline

Definition at line 442 of file mock-elm.hpp.

References EventLog::ensureNot(), and MockElm::getLog().

Referenced by AbstractTangible_test::markState(), AbstractTangible_test::notify(), and AbstractTangible_test::verify_mockManipulation().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EventMatch verifyMark ( string  id) const
inline

special verification match on a "state mark" message to this element

Definition at line 449 of file mock-elm.hpp.

References MockElm::getLog(), EventMatch::id(), EventMatch::type(), and EventLog::verify().

Referenced by AbstractTangible_test::markState(), and AbstractTangible_test::notify().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EventMatch verifyMark ( string  id,
string  payloadMatch 
) const
inline

verification match on a specific "state mark" message

Parameters
idthe ID-symbol used, identifying the kind of notification message
payloadMatchto be applied to the payload of the message solely

Definition at line 459 of file mock-elm.hpp.

References MockElm::getLog(), EventMatch::id(), EventMatch::type(), and EventLog::verifyEvent().

+ Here is the call graph for this function:

EventMatch verifyMark ( string  id,
X const &  something 
) const
inline

Definition at line 466 of file mock-elm.hpp.

References MockElm::getLog(), EventMatch::id(), EventMatch::type(), and EventLog::verifyEvent().

+ Here is the call graph for this function:

EventLog const& getLog ( ) const
inline

Definition at line 473 of file mock-elm.hpp.

References MockElm::log_.

Referenced by MockElm::ensureNot(), AbstractTangible_test::markState(), AbstractTangible_test::mutate(), AbstractTangible_test::notify(), BusTerm_test::pushDiff(), MockElm::verify(), MockElm::verifyCall(), MockElm::verifyEvent(), MockElm::verifyMark(), and MockElm::verifyMatch().

+ Here is the caller graph for this function:

EventLog& joinLog ( MockElm otherMock)
inline

Definition at line 479 of file mock-elm.hpp.

References EventLog::joinInto(), and MockElm::log_.

Referenced by BusTerm_test::clearStates(), AbstractTangible_test::verify_mockManipulation(), and BusTerm_test::verifyNotifications().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EventLog& joinLog ( EventLog otherLog)
inline

Definition at line 486 of file mock-elm.hpp.

References EventLog::joinInto(), and MockElm::log_.

+ Here is the call graph for this function:

Member Data Documentation

bool virgin_
private
bool expanded_
private

Definition at line 117 of file mock-elm.hpp.

Referenced by MockElm::doExpand(), MockElm::doReset(), and MockElm::isExpanded().

string message_
private

Definition at line 119 of file mock-elm.hpp.

Referenced by MockElm::getMessage().

string error_
private

Definition at line 120 of file mock-elm.hpp.

Referenced by MockElm::getError().

std::map<string, string> attrib
std::vector<PMockElm> scope
+ Inheritance diagram for MockElm:
+ Collaboration diagram for MockElm:

The documentation for this class was generated from the following file: