diff --git a/tests/gui/interact/ui-coord-test.cpp b/tests/gui/interact/ui-coord-test.cpp index d107eb9e2..f5a6a5352 100644 --- a/tests/gui/interact/ui-coord-test.cpp +++ b/tests/gui/interact/ui-coord-test.cpp @@ -26,11 +26,13 @@ #include "lib/test/run.hpp" -//#include "lib/test/test-helper.hpp" +#include "lib/test/test-helper.hpp" #include "gui/interact/ui-coord.hpp" +#include "lib/format-cout.hpp" +#include "lib/format-util.hpp" //#include "lib/idi/entry-id.hpp" //#include "lib/diff/gen-node.hpp" -//#include "lib/util.hpp" +#include "lib/util.hpp" //#include @@ -39,7 +41,9 @@ //using lib::idi::EntryID; //using lib::diff::GenNode; //using util::isSameObject; -//using util::isnil; +using util::isnil; +using util::join; + namespace gui { @@ -47,6 +51,8 @@ namespace interact { namespace test { // using lumiera::error::LUMIERA_ERROR_WRONG_TYPE; + using lumiera::error::LUMIERA_ERROR_INDEX_BOUNDS; + using lumiera::error::LUMIERA_ERROR_LOGIC; namespace { //Test fixture... @@ -82,13 +88,104 @@ namespace test { void verify_basics() { - UNIMPLEMENTED ("define basic properties of UI coordinates"); + UICoord undef; + CHECK (isnil (undef)); + + UICoord uic{"Γ","Δ","Θ","Ξ","Σ","Ψ","Φ","Ω"}; + CHECK (not isnil (uic)); + CHECK (8 == uic.size()); + // path is iterable + CHECK ("ΓΔΘΞΣΨΦΩ" == join(uic,"")); + + // indexed access + CHECK ("Γ" == uic[UIC_WINDOW]); + CHECK ("Δ" == uic[UIC_PERSP]); + CHECK ("Θ" == uic[UIC_PANEL]); + CHECK ("Ξ" == uic[UIC_VIEW]); + CHECK ("Σ" == uic[UIC_TAB]); + CHECK ("Ψ" == uic[UIC_PART]); + CHECK ("Φ" == uic[UIC_PART+1]); + CHECK ("Ω" == uic[UIC_PART+2]); + + // iteration matches index order + uint i=0; + for (UICoord::iterator ii = uic.begin(); ii; ++ii, ++i) + CHECK (uic[i] == *ii); + CHECK (8 == i); + + VERIFY_ERROR (INDEX_BOUNDS, uic[8]); + + // string representation + CHECK ("UI:Γ[Δ]-Θ.Ξ.Σ/Ψ/Φ/Ω" == string(uic)); + CHECK ("Γ[Δ]-Θ.Ξ.Σ" == uic.getComp()); + CHECK ("Ψ/Φ/Ω" == uic.getPath()); + + // new value can be assigned, but not altered in place + uic = UICoord{nullptr,nullptr,"Θ",nullptr,nullptr,nullptr,"Φ"}; + CHECK (7 == uic.size()); + + // representation is trimmed and filled + CHECK ("UI:Θ.*.*/*/Φ" == string(uic)); + CHECK (NULL == uic[UIC_WINDOW]); + CHECK (NULL == uic[UIC_PERSP]); + CHECK ("Θ" == uic[UIC_PANEL]); + CHECK ("*" == uic[UIC_VIEW]); + CHECK ("*" == uic[UIC_TAB]); + CHECK ("*" == uic[UIC_PART]); + CHECK ("Φ" == uic[UIC_PART+1]); + VERIFY_ERROR (INDEX_BOUNDS, uic[UIC_PART+2]); } void verify_builder() { + UICoord uic1 = UICoord::window("window"); + UICoord uic2 = uic2.view("view"); + CHECK ("UI:window" == string(uic1)); + CHECK ("UI:window[*]-*.view" == string(uic2)); + CHECK (1 == uic1.size()); + CHECK (4 == uic2.size()); + + // fault-tolerant accessors for the generic part + CHECK ("window" == uic1.getWindow()); + CHECK ("window" == uic2.getWindow()); + CHECK ("" == uic1.getPersp()); + CHECK ("*" == uic2.getPersp()); + CHECK ("" == uic1.getPanel()); + CHECK ("*" == uic2.getPanel()); + CHECK ("" == uic1.getView()); + CHECK ("view" == uic2.getView()); + CHECK ("" == uic1.getTab()); + CHECK ("" == uic2.getTab()); + CHECK ("" == uic1.getPath()); + CHECK ("" == uic2.getPath()); + CHECK ("window" == uic1.getComp()); + CHECK ("window[*]-*.view" == uic2.getComp()); + + VERIFY_ERROR (INDEX_BOUNDS, uic1[UIC_PERSP]); + VERIFY_ERROR (INDEX_BOUNDS, uic2[UIC_TAB]); + + UICoord uic3 = UICoord::view("view"); + CHECK (4 == uic3.size()); + CHECK ("UI:?.view" == string(uic3)); + CHECK ("" == uic3.getWindow()); + CHECK ("" == uic3.getPersp()); + CHECK ("" == uic3.getPanel()); + CHECK ("view" == uic3.getView()); + + UICoord uic4 = uic3.persp("persp"); + CHECK (4 == uic4.size()); + CHECK ("UI:?[persp]-*.view" == string(uic4)); + + uic4 = uic3.append("tab"); + CHECK (5 == uic4.size()); + CHECK ("UI:?.view.tab" == string(uic4)); + uic4 = uic3.prepend("panel"); + CHECK (4 == uic4.size()); + CHECK ("UI:?-panel.view" == string(uic4)); + VERIFY_ERROR(LOGIC, uic1.prepend("root")); + UNIMPLEMENTED ("verify the UI coordinate builder DSL"); } diff --git a/wiki/renderengine.html b/wiki/renderengine.html index 460408f4b..73de26ea0 100644 --- a/wiki/renderengine.html +++ b/wiki/renderengine.html @@ -2747,7 +2747,7 @@ Command instances are like prototypes -- thus each additional level of different see the description in → CommandSetup -
+
//A view within the UI, featuring some component of relevance to »the model«.//
 While any UI is comprised of numerous widgets acting as //view of something,// only some of those views play the prominent role to act as //building block component// of the user interface.
 Such UI component views exhibit some substantial traits
@@ -2794,32 +2794,32 @@ locate = panel(timeline)
 {{{
 alloc = onlyOne
 locate = external(beamer)
-                or perspective(mediaView).panel(viewer)
-                or existingPanel(viewer)
-                or firstWindow().panel(viewer)
+          or perspective(mediaView).panel(viewer)
+          or existingPanel(viewer)
+          or firstWindow().panel(viewer)
 }}}
 :* allow two viewer panels (the standard layout of editing applications)
 {{{
 alloc = limitPerWindow(2)
 locate = perspective(edit).existingPanel(viewer)
-                or currentWindow().existingPanel(viewer)
-                or existingPanel(viewer)
-                or panel(viewer)
+          or currentWindow().existingPanel(viewer)
+          or existingPanel(viewer)
+          or panel(viewer)
 }}}
 ;(Asset)Bin
 :within the dedicated asset panel, add to the appropriate group for the kind of asset
 {{{
 alloc = unlimited
 locate = currentWindow().perspective(edit).existingPanel(asset).existingGroup()
-                or perspective(asset).panel(asset)
-                or firstWindow().panel(asset)
+          or perspective(asset).panel(asset)
+          or firstWindow().panel(asset)
 }}}
 ;~Error-Log
 :use the current {{{InfoBoxPanel}}} if such exists, fall back to using a single view on the primary window
 {{{
 alloc = limitPerWindow(1)
 locate = currentWindow().existingPanel(infobox)
-                or firstWindow().panel(infobox)
+          or firstWindow().panel(infobox)
 }}}
 ;Playcontrol
 ://not determined yet what we'll need here....//