Lumiera  0.pre.03
»edit your freedom«
MockElm Class Reference

#include "/Werk/devel/lumi/tests/stage/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 110 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
 
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
 
void clearErr ()
 invoke the hook to clear error markers More...
 
void clearMsg ()
 invoke the hook to clear notification messages More...
 
ID getID () const
 
void installExpander (Expander::ProbeFun, Expander::ChangeFun)
 Configure the (optional) functionality to expand or collapse the UI-Element. More...
 
void installRevealer (Revealer::RevealeItFun)
 Configure the (optional) functionality to bring the UI-Element into sight. 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
 
void mark (GenNode const &)
 generic handler for all incoming "state mark" messages
 
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 LuidH () const
 
 operator string () const
 diagnostic representation. More...
 
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 ()
 Cause the element to be brought into sight. More...
 
- Public Member Functions inherited from DiffMutable
virtual ~DiffMutable ()
 this is an interface
 

Public Attributes

std::map< string, string > attrib
 
std::vector< PMockElm > scope
 

Protected Member Functions

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

Private Types

using _Par = stage::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
 generic default implementation of the expand/collapse functionality. More...
 
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 () override
 generic default implementation of the "reveal" functionality. More...
 

Private Attributes

string error_
 
bool expanded_ {false}
 
EventLog log_ {this->identify()}
 
string message_
 
bool virgin_ {true}
 

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
Expander expand_
 
Revealer reveal_
 
ctrl::BusTerm uiBus_
 

Constructor & Destructor Documentation

◆ ~MockElm()

~MockElm ( )
inline

document our death in the diagnostic log.

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

References EventLog::call(), EventLog::destroy(), and lumiera_error().

+ Here is the call graph for this function:

Member Function Documentation

◆ doExpand()

virtual bool doExpand ( bool  yes)
inlineoverrideprivatevirtual

generic default implementation of the expand/collapse functionality.

Based on the #expand_ functor, which needs to be configured explicitly to enable this functionality.

Returns
true if the actual expansion state has been changed.

Reimplemented from Tangible.

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

References EventLog::call().

+ Here is the call graph for this function:

◆ doReveal()

virtual void doReveal ( )
inlineoverrideprivatevirtual

generic default implementation of the "reveal" functionality.

Based on the #reveal_ functor, which needs to be configured explicitly to enable this functionality.

Reimplemented from Tangible.

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

References EventLog::call().

+ Here is the call graph for this function:

◆ doMark()

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()
  • reveal 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 213 of file mock-elm.hpp.

References EventLog::call(), and Tangible::mark().

+ Here is the call graph for this function:

◆ buildMutator()

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 226 of file mock-elm.hpp.

References TreeMutator::build(), EventLog::call(), lib::diff::anonymous_namespace{tree-mutator-collection-binding.hpp}::collection(), EventLog::create(), PlantingHandle< BA, DEFAULT >::emplace(), EventLog::event(), Tangible::installExpander(), lib::idi::instanceTypeID(), DataCap::isNested(), lib::diff::anonymous_namespace{test-mutation-target.hpp}::render(), and Nexus::testUI().

+ Here is the call graph for this function:

◆ kill()

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 351 of file mock-elm.hpp.

References EventLog::call(), EventLog::destroy(), EventLog::event(), and Nexus::zombificate().

+ Here is the call graph for this function:

◆ verifyMark()

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 456 of file mock-elm.hpp.

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

+ Here is the call graph for this function:
+ Inheritance diagram for MockElm:
+ Collaboration diagram for MockElm:

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