From e99ad7a3e6a141a94303f8fce8a90a3ae656a95e Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 8 Apr 2018 18:28:44 +0200 Subject: [PATCH] ElementAccess: draft simple lookup interface --- tests/gui/ctrl/element-access-test.cpp | 48 ++++++-- tests/gui/test/test-element-access.hpp | 11 +- wiki/thinkPad.ichthyo.mm | 153 +++++++++++++++++++++++-- 3 files changed, 193 insertions(+), 19 deletions(-) diff --git a/tests/gui/ctrl/element-access-test.cpp b/tests/gui/ctrl/element-access-test.cpp index c30b6ec47..1cb9fbf93 100644 --- a/tests/gui/ctrl/element-access-test.cpp +++ b/tests/gui/ctrl/element-access-test.cpp @@ -35,7 +35,7 @@ #include "lib/format-cout.hpp" //#include "lib/idi/entry-id.hpp" //#include "lib/diff/gen-node.hpp" -//#include "lib/util.hpp" +#include "lib/util.hpp" //#include //#include @@ -46,7 +46,7 @@ //using lib::diff::Rec; //using lib::idi::EntryID; //using lib::diff::GenNode; -//using util::isSameObject; +using util::isSameObject; //using util::isnil; @@ -56,17 +56,38 @@ namespace test { // using lumiera::error::LUMIERA_ERROR_WRONG_TYPE; // using lib::test::showSizeof; + using interact::UICoord; using MockAccess = lib::DependInject::Local; + using AccessAPI = lib::Depend; namespace { //Test fixture... + class DummyWidget + : ::util::NonCopyable + { + protected: + virtual ~DummyWidget() { } ///< is an interface + }; + + class DummyTab + : public DummyWidget + { }; + }//(End)Test fixture /******************************************************************************//** * @test verify the usage pattern of low-level UI element access, based on a * mock implementation of the accessor directory. + * @todo 4/2018 in the course of establishing an UI backbone, it is sufficient + * just to _have_ that abstraction interface; so the test focuses merely + * on the invocation, and documents how the mock be used. Which is a + * prerequisite to get the ViewSpecDSL_test finished. The intention is + * to elaborate the mock in a second step later and use it to build a + * draft of the implementation mechanics, but based on `Rec` + * rather than on the real UI topology. + * @see GenNodeLocationQuery * * @see id-scheme.hpp * @see ViewLocator @@ -78,9 +99,7 @@ namespace test { virtual void run (Arg) { - MockAccess fakeDirectory; - -// verify_basicProperties(); + verify_simpleAccess(); verify_standardUsage(); verify_alternatives(); @@ -88,10 +107,25 @@ namespace test { } + /** @test simple access to an existing element designated by coordinates */ void - verify_basicProperties() + verify_simpleAccess() { - UNIMPLEMENTED ("basic properties of the view spec DSL"); + MockAccess fakeDirectory; + + auto location = UICoord{"win-1","persp-A","thePanel","someView","tab#5"}; + DummyTab dummyTab; + + fakeDirectory->expectedQuery = location; + fakeDirectory->expectedAnswer = &dummyTab; + + AccessAPI accessAPI; + auto answer = accessAPI().access (location); + + CHECK (answer.isValid()); + DummyWidget& widget = answer; + CHECK (INSTANCEOF (DummyTab, &widget)); + CHECK (isSameObject (widget, dummyTab)); } diff --git a/tests/gui/test/test-element-access.hpp b/tests/gui/test/test-element-access.hpp index 8e21915ae..158c98fec 100644 --- a/tests/gui/test/test-element-access.hpp +++ b/tests/gui/test/test-element-access.hpp @@ -44,6 +44,7 @@ #include "lib/error.hpp" #include "gui/model/element-access.hpp" +#include "gui/interact/ui-coord.hpp" //#include "lib/symbol.hpp" //#include "lib/util.hpp" @@ -56,6 +57,7 @@ namespace model { // using util::isnil; // using std::string; + using interact::UICoord; /** @@ -74,9 +76,16 @@ namespace model { { } + /* == Test/Diagnostics interface == */ + + /** the next query will fail unless it presents this Path */ + UICoord expectedQuery; + + /** ...and if acceptable, the next query will answer with this object */ + void* expectedAnswer; - /* == Adapter interface for == */ + /* == ElementAccess interface == */ diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 35ee4230b..e67abd2a1 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -9335,6 +9335,35 @@ + + + + + + +

+ Ein Lookup-Vorgang ist schon ehr aufwendig, +

+

+ jedoch harmlos im Vergleich zu einer einzigen Frame-Berechnung. +

+
    +
  • + im ersten Schritt machen wir eine Tiefensuche potentiell über die ganze UI-Topologie +
  • +
  • + im zweiten Schritt wiederholen wir noch mal den Abstiegspfad zur Lösung des ersten Schrittes +
  • +
+

+ Grundsätzlich gilt hier die Einschätzung: Klarheit der Schnittstelle hat Vorrang +

+ + +
+ + +
@@ -11110,6 +11139,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ klassischer Fall von »premature optimisation« +

+ + +
+
+
@@ -11127,7 +11214,7 @@ - + @@ -11141,6 +11228,7 @@

+
@@ -11148,15 +11236,16 @@ - - + + - + - + + @@ -11189,8 +11278,8 @@ - - + + @@ -11962,8 +12051,8 @@ - - + + @@ -12616,6 +12705,10 @@ + + + + @@ -12658,11 +12751,49 @@ + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +