LocationQuery: draft unit test to cover the query API
This commit is contained in:
parent
fd3777de54
commit
2c96fcd164
2 changed files with 111 additions and 9 deletions
|
|
@ -56,8 +56,9 @@ namespace interact {
|
|||
namespace test {
|
||||
|
||||
// using lumiera::error::LUMIERA_ERROR_WRONG_TYPE;
|
||||
using lumiera::error::LUMIERA_ERROR_INDEX_BOUNDS;
|
||||
using lumiera::error::LUMIERA_ERROR_LOGIC;
|
||||
// using lumiera::error::LUMIERA_ERROR_INDEX_BOUNDS;
|
||||
using lumiera::error::LUMIERA_ERROR_STATE;
|
||||
// using lumiera::error::LUMIERA_ERROR_LOGIC;
|
||||
|
||||
namespace { //Test fixture...
|
||||
|
||||
|
|
@ -123,10 +124,105 @@ namespace test {
|
|||
}
|
||||
|
||||
|
||||
/** @test verify the command-and-query interface backing the resolver.
|
||||
* This test actually uses a dummy implementation of the interface, which,
|
||||
* instead of navigating an actual UI topology, just uses a `Record<GenNode>`
|
||||
* (a "GenNode tree") to emulate the hierarchical structure of UI components.
|
||||
* @remarks note some twists how the GenNode tree is used here to represent
|
||||
* an imaginary UI structure:
|
||||
* - we use the special _type_ attribute to represent the _perspective_
|
||||
* within each window; deliberately, we'll use this twisted structure
|
||||
* here to highlight the fact that the backing structure need not be
|
||||
* homogeneous; rather, it may require explicit branching
|
||||
* - we use the _attributes_ within the GenNode "object" representation,
|
||||
* since these are named nested elements, and the whole notion of an
|
||||
* UI coordinate path is based on named child components
|
||||
* - we use the _object builder_ helper to define the whole structure
|
||||
* as nested inline tree; this leads to a somewhat confusing notation,
|
||||
* where the names of the child nodes are spelled of at the closing
|
||||
* bracket of each construct.
|
||||
* - there is a special convention _for this test setup solely_ to
|
||||
* set the `currentWindow` to be the last one in list -- in a real
|
||||
* UI this would not of course not be a configurable property of
|
||||
* the LocationQuery, but rather just reflect the transient window
|
||||
* state and return the currently activated window
|
||||
*/
|
||||
void
|
||||
verify_backingQuery()
|
||||
{
|
||||
UNIMPLEMENTED ("verify the command-and-query interface backing the resolver");
|
||||
GenNodeLocationQuery queryAPI{MakeRec().scope(
|
||||
MakeRec()
|
||||
.type("perspective-A")
|
||||
.scope(
|
||||
MakeRec()
|
||||
.scope(
|
||||
MakeRec()
|
||||
.genNode("firstView"),
|
||||
MakeRec()
|
||||
.genNode("secondView")
|
||||
).genNode("panelX")
|
||||
).genNode("window-1"),
|
||||
MakeRec()
|
||||
.type("perspective-B")
|
||||
.scope(
|
||||
MakeRec()
|
||||
.genNode("panelY")
|
||||
).genNode("window-2"),
|
||||
MakeRec()
|
||||
.type("perspective-C")
|
||||
.scope(
|
||||
MakeRec()
|
||||
.scope(
|
||||
MakeRec()
|
||||
.genNode("thirdView")
|
||||
).genNode("panelZ"),
|
||||
MakeRec()
|
||||
.genNode("panelZZ")
|
||||
).genNode("window-3")
|
||||
)};
|
||||
|
||||
// the LocationQuery API works by matching a UICoord spec against the "real" structure
|
||||
UICoord uic1 = UICoord::window("window-2").persp("perspective-B");
|
||||
UICoord uic2 = UICoord::window("windows");
|
||||
UICoord uic3 = UICoord::firstWindow().persp("perspective-A").panel("panelX").view("secondView");
|
||||
UICoord uic4 = UICoord::currentWindow().persp("perspective-B");
|
||||
UICoord uic5 = UICoord::currentWindow().persp("perspective-C").panel("panelZ").view("someOtherView");
|
||||
|
||||
CHECK ("window-2" == queryAPI.determineAnchor(uic1));
|
||||
CHECK (Symbol::BOTTOM == queryAPI.determineAnchor(uic2));
|
||||
CHECK ("window-1" == queryAPI.determineAnchor(uic3));
|
||||
CHECK ("window-3" == queryAPI.determineAnchor(uic4));
|
||||
CHECK ("window-3" == queryAPI.determineAnchor(uic5));
|
||||
|
||||
CHECK (2 == queryAPI.determineCoverage(uic1));
|
||||
CHECK (0 == queryAPI.determineCoverage(uic2));
|
||||
CHECK (4 == queryAPI.determineCoverage(uic3));
|
||||
CHECK (1 == queryAPI.determineCoverage(uic4));
|
||||
CHECK (3 == queryAPI.determineCoverage(uic5));
|
||||
|
||||
LocationQuery::ChildIter cii = queryAPI.getChildren(uic3, 3);
|
||||
CHECK (not isnil(cii));
|
||||
CHECK ("firstView" == *cii);
|
||||
++cii;
|
||||
CHECK ("secondView" == *cii);
|
||||
CHECK (not isnil(cii));
|
||||
++cii;
|
||||
CHECK (isnil(cii));
|
||||
|
||||
CHECK ("window-1, window-2, window-3" == join (queryAPI.getChildren (uic3, 0)));
|
||||
CHECK ("perspective-A" == join (queryAPI.getChildren (uic3, 1)));
|
||||
CHECK ("panelX" == join (queryAPI.getChildren (uic3, 2)));
|
||||
CHECK ("firstView, secondView" == join (queryAPI.getChildren (uic3, 3)));
|
||||
CHECK (isnil ( queryAPI.getChildren (uic3, 4))); // "firstView" has no children
|
||||
|
||||
CHECK ("window-1, window-2, window-3" == join (queryAPI.getChildren (uic2, 0)));
|
||||
VERIFY_ERROR (STATE, queryAPI.getChildren (uic2, 1) ); // "windows" at pos==0 is not covered by real UI
|
||||
|
||||
CHECK ("window-1, window-2, window-3" == join (queryAPI.getChildren (uic5, 0)));
|
||||
CHECK ("perspective-C" == join (queryAPI.getChildren (uic5, 1)));
|
||||
CHECK ("panelZ, panelZZ" == join (queryAPI.getChildren (uic5, 2)));
|
||||
CHECK ("thirdView" == join (queryAPI.getChildren (uic5, 3)));
|
||||
VERIFY_ERROR (STATE, queryAPI.getChildren (uic5, 4) ); // "someOtherView" at level 4 does not exist
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4231,8 +4231,8 @@
|
|||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1506181800067" ID="ID_196802981" MODIFIED="1506181809619" TEXT="Wiring">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1506181802699" ID="ID_582767851" MODIFIED="1506181810370" TEXT="Test-Setup">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1506181802699" ID="ID_582767851" MODIFIED="1508625703401" TEXT="Test-Setup">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508537003861" ID="ID_846599209" MODIFIED="1508537009333" TEXT="Semantik">
|
||||
|
|
@ -4257,8 +4257,14 @@
|
|||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508537057661" ID="ID_1582824657" MODIFIED="1508537073664" TEXT="was heißt "covern"?">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node CREATED="1508538092061" ID="ID_731131821" MODIFIED="1508538096663" TEXT="komplett/partiell?"/>
|
||||
<node CREATED="1508538108338" ID="ID_1403158284" MODIFIED="1508538112157" TEXT="so gut wie möglich"/>
|
||||
<node CREATED="1508538113098" ID="ID_415701605" MODIFIED="1508538181701" TEXT="eine Covfefe ermitteln"/>
|
||||
<node CREATED="1508538108338" ID="ID_1403158284" MODIFIED="1508625730742" TEXT="so gut wie möglich">
|
||||
<icon BUILTIN="forward"/>
|
||||
<node CREATED="1508625742468" ID="ID_511236910" MODIFIED="1508625745864" TEXT="kann partiell sein"/>
|
||||
<node CREATED="1508625746667" ID="ID_1562464707" MODIFIED="1508625757806" TEXT="endet aber stets mit einem expliziten Element"/>
|
||||
</node>
|
||||
<node CREATED="1508538113098" ID="ID_415701605" MODIFIED="1508625772283" TEXT="eine Covfefe ermitteln">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508537087378" ID="ID_548549576" MODIFIED="1508537098305" TEXT="Wildcards interpolieren">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
|
|
@ -4569,8 +4575,8 @@
|
|||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1506984645745" ID="ID_244163155" MODIFIED="1506984665826" TEXT="verify_simpleUsage">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1506984645747" ID="ID_517262443" MODIFIED="1506984665001" TEXT="verify_backingQuery">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1506984645747" ID="ID_517262443" MODIFIED="1508625810426" TEXT="verify_backingQuery">
|
||||
<icon BUILTIN="pencil"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1506984645748" ID="ID_1254044275" MODIFIED="1506984664457" TEXT="verify_queryAnchor">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue