Navigator: finish coverage of path extension
This commit is contained in:
parent
2d66293c32
commit
722c49e5ff
2 changed files with 24 additions and 13 deletions
|
|
@ -379,14 +379,14 @@ namespace interact {
|
||||||
REQUIRE (res_.isResolved);
|
REQUIRE (res_.isResolved);
|
||||||
size_t coverable = res_.covfefe? res_.covfefe->size() : res_.depth;
|
size_t coverable = res_.covfefe? res_.covfefe->size() : res_.depth;
|
||||||
auto newContent = partialExtensionSpec.begin();
|
auto newContent = partialExtensionSpec.begin();
|
||||||
size_t extensionPos = newContent? partialExtensionSpec.indexOf(*newContent) : 0;
|
size_t extensionPos = newContent? partialExtensionSpec.indexOf(*newContent) : coverable;
|
||||||
if (coverable >= extensionPos)
|
if (coverable > extensionPos)
|
||||||
throw error::Invalid (util::_Fmt{"Attempt to extend covered path %s with %s "
|
throw error::Invalid (util::_Fmt{"Attempt to extend covered path %s with %s "
|
||||||
"would overwrite positions %d to %d (incl)"}
|
"would overwrite positions %d to %d (incl)"}
|
||||||
% (res_.covfefe? *res_.covfefe : UICoord{uic_.rebuild().truncateTo(res_.depth)})
|
% (res_.covfefe? *res_.covfefe : UICoord{uic_.rebuild().truncateTo(res_.depth)})
|
||||||
% partialExtensionSpec
|
% partialExtensionSpec
|
||||||
% extensionPos
|
% extensionPos
|
||||||
% coverable);
|
% (coverable-1));
|
||||||
cover();
|
cover();
|
||||||
for ( ; newContent; ++newContent, ++extensionPos )
|
for ( ; newContent; ++newContent, ++extensionPos )
|
||||||
overwrite (extensionPos, *newContent);
|
overwrite (extensionPos, *newContent);
|
||||||
|
|
|
||||||
|
|
@ -634,25 +634,36 @@ namespace test {
|
||||||
|
|
||||||
/* === extend fully covered explicit path === */
|
/* === extend fully covered explicit path === */
|
||||||
UICoordResolver r1 {UICoord{"window-2","persp-B","panelY"}, tree};
|
UICoordResolver r1 {UICoord{"window-2","persp-B","panelY"}, tree};
|
||||||
r1.extend (UICoord().path("gappy").tab(2));
|
CHECK ("UI:window-2[persp-B]-panelY" == string(r1));
|
||||||
cout << string(r1)<<endl;
|
CHECK (r1.isCovered());
|
||||||
r1.extend ("seamless");
|
r1.extend (UICoord().path("gappy").tab(2)); // can extend with partially defined UI coordinates
|
||||||
cout << string(r1)<<endl;
|
CHECK ("UI:window-2[persp-B]-panelY.*.#2/gappy" == string(r1)); // ...the resulting UI path is unresolved, yet can be partially covered
|
||||||
|
r1.extend ("seamless"); // ...and this partial coverage is used as base for further extension
|
||||||
|
CHECK ("UI:window-2[persp-B]-panelY.thirdView.#2/seamless" ==string(r1));
|
||||||
|
|
||||||
/* === extend partially covered path === */
|
/* === extend partially covered path === */
|
||||||
UICoordResolver r2 {UICoord().view("thirdView").append("some/where"), tree};
|
UICoordResolver r2 {UICoord().view("thirdView").append("some/where"), tree};
|
||||||
|
CHECK ("UI:?.thirdView.some/where" ==string(r2)); // "thirdView" is covered, "some/where" is not
|
||||||
r2.extend ("no/where");
|
r2.extend ("no/where");
|
||||||
cout << string(r2)<<endl;
|
CHECK ("UI:window-2[persp-B]-panelY.thirdView.no/where" ==string(r2)); // ...and thus the extension is attached behind "thirdView"
|
||||||
VERIFY_ERROR (INVALID, r2.extend(UICoord().persp("fisheye")));
|
CHECK (r2.isCoveredPartially());
|
||||||
cout << string(r2)<<endl;
|
|
||||||
|
/* === impossible extensions rejected === */ // since r2 already specifies a perspective ("persp-B")....
|
||||||
|
VERIFY_ERROR (INVALID, r2.extend(UICoord().persp("fisheye"))); // ...overwriting with another perspective is rejected as extension
|
||||||
|
CHECK ("UI:window-2[persp-B]-panelY.thirdView.no/where" ==string(r2)); // ...and the existing state is unaffected from this error
|
||||||
|
VERIFY_ERROR (INVALID, r2.extend(UICoord().view("alternative"))); // Likewise, extending with a conflicting view spec is rejected
|
||||||
|
r2.extend(UICoord().tab("nada")); // But a tab is not yet covered and thus acceptable as extension
|
||||||
|
CHECK ("UI:window-2[persp-B]-panelY.thirdView.nada" ==string(r2));
|
||||||
|
r2.extend(UICoord());
|
||||||
|
CHECK ("UI:window-2[persp-B]-panelY.thirdView" ==string(r2)); // empty coordinates implicitly attached behind the covered part
|
||||||
|
|
||||||
/* === unsolvable: truncate, extend, recalculate coverage === */
|
/* === unsolvable: truncate, extend, recalculate coverage === */
|
||||||
UICoordResolver r3 {UICoord().persp("awesome"), tree};
|
UICoordResolver r3 {UICoord().persp("awesome"), tree};
|
||||||
CHECK (not r3.canCover());
|
CHECK (not r3.canCover());
|
||||||
CHECK (0 == r3.coverDepth());
|
CHECK (0 == r3.coverDepth());
|
||||||
r3.extend (UICoord::currentWindow().tab(1));
|
r3.extend (UICoord::currentWindow().tab(1)); // Extension implies covering, which effectively truncates the path
|
||||||
CHECK (1 == r3.coverDepth());
|
CHECK (1 == r3.coverDepth()); // ...and "currentWindow" can even be covered, thus the coverage increases
|
||||||
cout << string(r3)<<endl;
|
CHECK ("UI:currentWindow[*]-*.*.#1" ==string(r3)); // note coverage calculated internally, not made explicit
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue