Lumiera  0.pre.03
»edit your freedom«
mock-elm.hpp File Reference

Go to the source code of this file.

Description

A generic interface element instrumented for unit testing.

All relevant building blocks within the Lumiera GTK UI are based on stage::model::Tangible, meaning that any generic effect of interface interactions can be expressed in terms of this interface contract. As far as the UI participates in interactions with the lower layers, like e.g. command invocation, structure updates and state notifications, these processes can be modelled and verified with the help of a specially prepared Tangible instance. This stage::test::MockElm provides the necessary instrumentation to observe what has been invoked and received.

Since the purpose of a mock interface element is to test interactions and responses targeted at a generic interface element, the MockElm incorporates an implementation independent from the real stage::model::Widget or stage::model::Controller. This mock implementation is basically NOP, while logging any invocation. Matters get a bit fuzzy, when it comes to the distinction between widget and controller. Yet we should note that the purpose of this setup is to cover the connectivity and integration with the UI, not the tangible "mechanics" of the UI itself. It can be argued that covering the latter with unit tests is pretty much moot and will result just in a huge pile of code duplication and maintenance burden.

People typically start to look into unit testing of user interfaces when faced with a largely dysfunctional architecture, where core functionality is littered and tangled into the presentation code. While in a system knowingly built with a distinct core, the UI should not contain anything not tangible enough as just to be verified by watching it in action. The push of a button should just invoke an action, and the action itself should be self contained enough to be tested in isolation. The UI-Bus and the generic widget base was built to serve as a foundation to achieve that goal.

See also
abstract-tangible-test.cpp

Definition in file mock-elm.hpp.

#include "lib/error.hpp"
#include "include/ui-protocol.hpp"
#include "lib/test/event-log.hpp"
#include "stage/model/tangible.hpp"
#include "lib/diff/record.hpp"
#include "lib/idi/genfunc.hpp"
#include "test/test-nexus.hpp"
#include "lib/diff/test-mutation-target.hpp"
#include "lib/format-cout.hpp"
#include "lib/symbol.hpp"
#include "lib/util.hpp"
#include <string>
#include <memory>
#include <vector>
#include <map>

Classes

class  MockElm
 Mock UI element or controller. More...
 

Typedefs

using PMockElm = std::unique_ptr< MockElm >
 

Namespaces

 stage
 Lumiera GTK UI implementation root.