Navigator: unit test simple cases of coverage

This commit is contained in:
Fischlurch 2018-01-04 04:52:09 +01:00
parent 2a87a80e33
commit f4648c393f
4 changed files with 115 additions and 48 deletions

View file

@ -330,6 +330,12 @@ namespace interact {
}
/** diagnostics */
operator string() const { return string(this->uic_); }
size_t coverDepth() const { return res_.depth; }
private:
/** establish a trivial anchorage and coverage, if possible.
* @note when the UICoord contains wildcards or is incomplete,

View file

@ -82,9 +82,8 @@ namespace test {
verify_simpleUsage();
verify_backingQuery();
verify_queryAnchor();
verify_queryCoverage();
verify_mutateCoverage();
verify_mutateAnchor();
verify_mutateCovered();
verify_mutateExtend();
}
@ -243,11 +242,14 @@ namespace test {
/** @test query anchorage of given UI coordinates.
* - an anchored UI coordinate spec explicitly rooted within a top level window.
* - an explicit UI coordinate spec impossible to anchor within current UI tree
* - a UI coordinate spec with dynamic reference to first/current window
* - an incomplete spec, which needs to be solved (pattern matched) to determine anchor.
*/
void
verify_queryAnchor()
{
GenNodeLocationQuery loQu{MakeRec()
GenNodeLocationQuery tree{MakeRec()
.set("window-1"
, MakeRec()
.type("perspective-A")
@ -268,12 +270,12 @@ namespace test {
UICoord uic5 = UICoord::currentWindow().panel("panelY");
UICoord uic6 = UICoord().view("someView").path("α/β/γ");
UICoordResolver r1{uic1, loQu};
UICoordResolver r2{uic2, loQu};
UICoordResolver r3{uic3, loQu};
UICoordResolver r4{uic4, loQu};
UICoordResolver r5{uic5, loQu};
UICoordResolver r6{uic6, loQu};
UICoordResolver r1{uic1, tree};
UICoordResolver r2{uic2, tree};
UICoordResolver r3{uic3, tree};
UICoordResolver r4{uic4, tree};
UICoordResolver r5{uic5, tree};
UICoordResolver r6{uic6, tree};
CHECK ( r1.isAnchored());
CHECK (not r2.isAnchored());
@ -291,10 +293,75 @@ namespace test {
}
/** @test patch matching algorithm to resolve UI coordinates with wildcards against the current UI structure tree.
* Since an UI coordinate path with gaps and wildcards could match anywhere, even several times, we need to perform
* an exhaustive search with backtracking over the whole tree. By convention, we use the first maximal solution,
* which can be just a partial solution, leaving an additional uncovered trailing part of the UI coordinate spec.
* Whenever a coordinate spec is _not explicit,_ has wildcards or a leading gap, we need to perform the full
* matching algorithm, even to just answer the question if coverage _is possible_. The result, i.e. the computed
* coverage, is cached internally, and can be used to _mutate_ the UI coordinate spec to match that coverage.
*
* This test verifies various corner cases; especially there is a rule to prevent a partial match based
* on wildcards solely, rather we require at least one explicit match to qualify as partial solution.
* - (r1) trivial cases not requiring a tree search
* ** total coverage
* ** partial coverage, leaving an uncovered suffix
*/
void
verify_queryCoverage()
verify_mutateCoverage()
{
UNIMPLEMENTED ("query coverage of given UI coordinates with respect to actual UI");
GenNodeLocationQuery tree{MakeRec()
.set("window-1"
, MakeRec()
.type("perspective-A")
.set("panelX"
, MakeRec()
.set("firstView", MakeRec())
.set("secondView", MakeRec())
)
)
.set("window-2"
, MakeRec()
.type("perspective-B")
.set("panelY", MakeRec())
)
.set("window-3"
, MakeRec()
.type("perspective-C")
.set("panelZ"
, MakeRec()
.set("thirdView", MakeRec())
)
.set("panelZZ", MakeRec())
)
};
/* === trivial cases === */
UICoordResolver r11 {UICoord::window("window-1")
.persp("perspective-A")
.panel("panelX"), tree};
CHECK (r11.isCovered());
CHECK (3 == r11.coverDepth());
UICoordResolver r12 {UICoord::window("window-1")
.persp("perspective-A")
.panel("panelX")
.view("thirdView"), tree};
CHECK (not r12.isCovered());
CHECK ( r12.isCoveredPartially());
CHECK (3 ==r12.coverDepth());
CHECK ("UI:window-1[perspective-A]-panelX.thirdView" == string(r12));
auto r12_covered = r12.cover();
CHECK (r12_covered.isCovered());
CHECK (r12_covered.isCoveredPartially());
CHECK (3 ==r12_covered.coverDepth());
CHECK ("UI:window-1[perspective-A]-panelX" == string(r12_covered));
UNIMPLEMENTED ("TODO: further cases of coverage query....");
}
@ -305,13 +372,6 @@ namespace test {
}
void
verify_mutateCovered()
{
UNIMPLEMENTED ("mutate given UI coordinates by reducing to covered part");
}
void
verify_mutateExtend()
{

View file

@ -9744,7 +9744,7 @@ The dispatch of //diff messages// is directly integrated into the UI-Bus -- whic
The Graphical User interface, the upper layer in this hierarchy, embodies everything of tangible relevance to the user working with the application. The interplay with Proc-Layer, the middle layer below the UI, is organised along the distinction between two realms of equal importance: on one side, there is the immediate //mechanics of the interface,// which is implemented directly within the ~UI-Layer, based on the Graphical User Interface Toolkit. And, on the other side, there are those //core concerns of working with media,// which are cast into the HighLevelModel at the heart of the middle layer.</pre>
</div>
<div title="UICoord" creator="Ichthyostega" modifier="Ichthyostega" created="201709222300" modified="201801011613" tags="def draft spec Concepts GuiPattern" changecount="22">
<div title="UICoord" creator="Ichthyostega" modifier="Ichthyostega" created="201709222300" modified="201801040350" tags="def draft spec Concepts GuiPattern" changecount="23">
<pre>//A topological addressing scheme to designate structural locations within the UI.//
Contrary to conventional screen pixel coordinates, here we aim at a topological description of the UI structure. Such a framework of structural reference allows us
* to refer to some &quot;place&quot; or &quot;space&quot; within the interface
@ -9792,7 +9792,7 @@ In addition to the //locally decidable properties// of a coordinate spec, which
:* it is //partially covered// with an remaining, uncovered extension part
:* it is //possible to cover completely//
:* it is //impossible to cover//
__Some fine points to note__: Anchorage and coverage are not the same thing, but coverage implies anchorage. Only when a path is complete (starts with the window spec) and explicit (has no wildcards), then anchorage implies also partial coverage (namely at least to depth 1). To determine the possible coverage means to perform a resolution with backtracking to pick the maximal solution. Moreover, since &quot;covered&quot; means that the path specification //is at least partially supported by the real UI,// we establish an additional constraint to ensure this resolution did not just match some arbitrary wildcards. Rather we demand that behind rsp. below the last wildcard there is at least one further explicit component in the path spec, which is supported by the real UI. As a consequence, the coverage resolution may fail altogether, while still providing at least a possible anchor point.
__Some fine points to note__: Anchorage and coverage are not the same thing, but coverage implies anchorage. Only when a path is complete (starts with the window spec) and explicit (has no wildcards), then anchorage implies also partial coverage (namely at least to depth 1). To determine the possibility of coverage means to perform a resolution with backtracking to pick the maximal solution. Moreover, since &quot;covered&quot; means that the path specification //is at least partially supported by the real UI,// we establish an additional constraint to ensure this resolution did not just match some arbitrary wildcards. Rather we demand that behind rsp. below the last wildcard there is at least one further explicit component in the path spec, which is supported by the real UI. As a consequence, the coverage resolution may fail altogether, while still providing at least a possible anchor point.
!!!Mutations
In addition to querying the interpretation of a given coordinate spec with respect to the current UI environment, it is also possible to rewrite or extend the spec based on this environment
;anchoring

View file

@ -4463,8 +4463,8 @@
<icon BUILTIN="yes"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508539143849" ID="ID_1632791283" MODIFIED="1508539182677" TEXT="path-resolution">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508539143849" ID="ID_1632791283" MODIFIED="1515037686112" TEXT="path-resolution">
<icon BUILTIN="pencil"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508539152568" ID="ID_153711822" MODIFIED="1508539175926" TEXT="Beschreibung">
<icon BUILTIN="flag-yellow"/>
<node CREATED="1508539226014" ID="ID_1714773115" MODIFIED="1511572072101" TEXT="informell...">
@ -4533,21 +4533,21 @@
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508539156879" ID="ID_1086207992" MODIFIED="1514748732189" TEXT="Layered Evaluation">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1508539156879" ID="ID_1086207992" MODIFIED="1515037663165" TEXT="Layered Evaluation">
<icon BUILTIN="button_ok"/>
<node COLOR="#338800" CREATED="1508539857115" ID="ID_1186310701" MODIFIED="1514330270783" TEXT="state: L&#xf6;sungs-Cache">
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508539879600" ID="ID_1527439493" MODIFIED="1514748699378" TEXT="Auswertungs-Frame (TreeExplorer)">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1508539879600" ID="ID_1527439493" MODIFIED="1515037657130" TEXT="Auswertungs-Frame (TreeExplorer)">
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1514748701222" ID="ID_1571444662" MODIFIED="1514748748468" TEXT="Varianten partiell/total">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1514748701222" ID="ID_1571444662" MODIFIED="1515037660962" TEXT="Varianten partiell/total">
<icon BUILTIN="button_ok"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508539166878" ID="ID_1751192686" MODIFIED="1514748674978" TEXT="Testf&#xe4;lle">
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508539166878" ID="ID_1751192686" MODIFIED="1515037680304" TEXT="Testf&#xe4;lle">
<arrowlink COLOR="#715b79" DESTINATION="ID_1362494392" ENDARROW="Default" ENDINCLINATION="-578;-16;" ID="Arrow_ID_1072715196" STARTARROW="None" STARTINCLINATION="477;0;"/>
<icon BUILTIN="flag-yellow"/>
<icon BUILTIN="pencil"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508539191283" ID="ID_1571889765" MODIFIED="1508539199219" TEXT="anchor">
@ -4559,8 +4559,8 @@
</node>
<node COLOR="#338800" CREATED="1508539195258" ID="ID_1044429952" MODIFIED="1509329355200" TEXT="cover">
<icon BUILTIN="button_ok"/>
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1508540823475" ID="ID_793410656" MODIFIED="1514330160095" TEXT="path-resolution ausf&#xfc;hren">
<icon BUILTIN="pencil"/>
<node COLOR="#338800" CREATED="1508540823475" ID="ID_793410656" MODIFIED="1515037714505" TEXT="path-resolution ausf&#xfc;hren">
<icon BUILTIN="button_ok"/>
<node CREATED="1509475490890" ID="ID_1616720086" MODIFIED="1509475494565" TEXT="rekursiv"/>
<node CREATED="1509475495057" ID="ID_27489504" MODIFIED="1509475501956" TEXT="Aufruf mit ResolutionState"/>
<node CREATED="1509475548066" ID="ID_1051318433" MODIFIED="1509475558373" TEXT="jede gefundene L&#xf6;sung &quot;abwerfen&quot;"/>
@ -4625,7 +4625,8 @@
<node CREATED="1514328757725" ID="ID_1835412332" MODIFIED="1514328766544" TEXT="auch &#xfc;ber Transformer und Abstraktionsbarrieren hinweg"/>
</node>
</node>
<node CREATED="1509495634766" ID="ID_422767906" MODIFIED="1509495638153" TEXT="Zusammenspiel">
<node CREATED="1509495634766" FOLDED="true" ID="ID_422767906" MODIFIED="1515037628032" TEXT="Zusammenspiel">
<icon BUILTIN="info"/>
<node CREATED="1509491594115" ID="ID_214903834" MODIFIED="1509491635369" TEXT="was tr&#xe4;gt LocationQuery bei?">
<icon BUILTIN="help"/>
<node CREATED="1509491778083" ID="ID_1393727273" MODIFIED="1509491782470" TEXT="den Ort im Baum"/>
@ -8356,7 +8357,7 @@
</node>
</node>
</node>
<node COLOR="#338800" CREATED="1510941748388" HGAP="38" ID="ID_209463158" MODIFIED="1515034445054" TEXT="Zustands-Layer" VSHIFT="1">
<node COLOR="#338800" CREATED="1510941748388" FOLDED="true" HGAP="38" ID="ID_209463158" MODIFIED="1515037581429" TEXT="Zustands-Layer" VSHIFT="1">
<icon BUILTIN="button_ok"/>
<node COLOR="#338800" CREATED="1514333524247" ID="ID_1136271037" MODIFIED="1514908803527" TEXT="Zustand umfa&#xdf;t...">
<icon BUILTIN="info"/>
@ -8368,7 +8369,7 @@
</node>
<node CREATED="1514333825991" ID="ID_541168831" MODIFIED="1514898080652" TEXT="isSolution (implizit)"/>
</node>
<node COLOR="#338800" CREATED="1514338393316" ID="ID_1224653593" MODIFIED="1514897686445" TEXT="f&#xfc;r jedes Element...">
<node COLOR="#338800" CREATED="1514338393316" ID="ID_1224653593" MODIFIED="1515037565965" TEXT="f&#xfc;r jedes Element...">
<icon BUILTIN="button_ok"/>
<node CREATED="1514338471073" ID="ID_1000829527" MODIFIED="1514908912290" STYLE="bubble" TEXT="target[depth] ==?">
<edge COLOR="#5b5ea6"/>
@ -8415,7 +8416,7 @@
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
</node>
</node>
<node COLOR="#338800" CREATED="1514828322209" HGAP="447" ID="ID_868482472" MODIFIED="1515034439374" TEXT="Implementierung" VSHIFT="24">
<node COLOR="#338800" CREATED="1514828322209" HGAP="447" ID="ID_868482472" MODIFIED="1515037575610" TEXT="Implementierung" VSHIFT="24">
<icon BUILTIN="button_ok"/>
<node CREATED="1514828365236" ID="ID_596741108" MODIFIED="1514828377582" TEXT="per Seiteneffekt auf den privaten Resolver-state"/>
<node CREATED="1514828408694" ID="ID_360791024" MODIFIED="1514828619139">
@ -8505,7 +8506,7 @@
</node>
</node>
</node>
<node CREATED="1514339655585" ID="ID_20763657" MODIFIED="1514339725688" TEXT="brauche">
<node CREATED="1514339655585" ID="ID_20763657" MODIFIED="1515037569236" TEXT="brauche">
<icon BUILTIN="forward"/>
<node CREATED="1514339665248" ID="ID_1142507602" MODIFIED="1514339776889" TEXT="low-level-Operation">
<richcontent TYPE="NOTE"><html>
@ -8582,7 +8583,7 @@
</node>
</node>
</node>
<node COLOR="#338800" CREATED="1510941754211" HGAP="36" ID="ID_996085388" MODIFIED="1515031584659" TEXT="Filter-Layer" VSHIFT="-1">
<node COLOR="#338800" CREATED="1510941754211" FOLDED="true" HGAP="36" ID="ID_996085388" MODIFIED="1515037586624" TEXT="Filter-Layer" VSHIFT="-1">
<icon BUILTIN="button_ok"/>
<node CREATED="1514747460122" ID="ID_1735380227" MODIFIED="1514908757875" TEXT="fischt nach tats&#xe4;chlichen L&#xf6;sungen">
<icon BUILTIN="button_ok"/>
@ -8690,8 +8691,8 @@
<icon BUILTIN="messagebox_warning"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1514829244384" ID="ID_174527898" MODIFIED="1515034463169" TEXT="API umstellen">
<icon BUILTIN="pencil"/>
<node COLOR="#338800" CREATED="1514829244384" ID="ID_174527898" MODIFIED="1515037521605" TEXT="API umstellen">
<icon BUILTIN="button_ok"/>
<node COLOR="#338800" CREATED="1514942071848" ID="ID_642968204" MODIFIED="1515034463169" TEXT="totale Coverage wird default">
<icon BUILTIN="button_ok"/>
</node>
@ -8717,8 +8718,8 @@
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1510941766817" HGAP="13" ID="ID_1117346518" MODIFIED="1514829215489" TEXT="Testf&#xe4;lle" VSHIFT="29">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1510941766817" HGAP="13" ID="ID_1117346518" MODIFIED="1515037517012" TEXT="Testf&#xe4;lle" VSHIFT="29">
<icon BUILTIN="pencil"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1513477873206" ID="ID_939423021" MODIFIED="1513477891813" TEXT="definieren was abzudecken ist...">
<icon BUILTIN="yes"/>
</node>
@ -8758,13 +8759,13 @@
<node CREATED="1514329328840" HGAP="35" ID="ID_1362494392" MODIFIED="1514748674978" TEXT="Abzudecken ist...." VSHIFT="4">
<linktarget COLOR="#715b79" DESTINATION="ID_1362494392" ENDARROW="Default" ENDINCLINATION="-578;-16;" ID="Arrow_ID_1072715196" SOURCE="ID_1751192686" STARTARROW="None" STARTINCLINATION="477;0;"/>
<icon BUILTIN="yes"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1514329411197" ID="ID_1637267494" MODIFIED="1514330059117" TEXT="Trivial-Fall: bestehenden Pfad finden">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1514329441136" ID="ID_359779455" MODIFIED="1514330060373" TEXT="mit unvollst&#xe4;ndiger Coverage">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1514329411197" ID="ID_1637267494" MODIFIED="1515037505754" TEXT="Trivial-Fall: bestehenden Pfad finden">
<icon BUILTIN="button_ok"/>
<node COLOR="#338800" CREATED="1514329441136" ID="ID_359779455" MODIFIED="1515037507798" TEXT="mit unvollst&#xe4;ndiger Coverage">
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1514329450807" ID="ID_211306404" MODIFIED="1514330068740" TEXT="mit &#xdc;berhang">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1514329450807" ID="ID_211306404" MODIFIED="1515037510040" TEXT="mit &#xdc;berhang">
<icon BUILTIN="button_ok"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1514329465117" ID="ID_1304144230" MODIFIED="1514330070372" TEXT="trailing Wildcards scheitern">