From 4c273d902cd10b94c1069c39bce5f0accb1efcac Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 14 Apr 2018 00:37:30 +0200 Subject: [PATCH] ElementAccess: add very simplistic mock implementation --- tests/gui/ctrl/element-access-test.cpp | 24 ++------- tests/gui/test/test-element-access.hpp | 74 ++++++++++++-------------- wiki/thinkPad.ichthyo.mm | 26 ++++++--- 3 files changed, 58 insertions(+), 66 deletions(-) diff --git a/tests/gui/ctrl/element-access-test.cpp b/tests/gui/ctrl/element-access-test.cpp index d283af9be..363bd03ab 100644 --- a/tests/gui/ctrl/element-access-test.cpp +++ b/tests/gui/ctrl/element-access-test.cpp @@ -30,7 +30,6 @@ //#include "gui/interact/view-spec-dsl.hpp" #include "test/test-element-access.hpp" #include "gui/interact/ui-coord.hpp" -#include "test/mock-elm.hpp" //#include "gen-node-location-query.hpp" #include "lib/depend-inject.hpp" #include "lib/format-cout.hpp" @@ -52,33 +51,19 @@ using util::isSameObject; namespace gui { -namespace model { +namespace model{ namespace test { // using lumiera::error::LUMIERA_ERROR_WRONG_TYPE; // using lib::test::showSizeof; using interact::UICoord; + using gui::test::TestElementAccess; + using gui::test::DummyWidget; + using gui::test::DummyTab; using MockAccess = lib::DependInject::Local; using AccessAPI = lib::Depend; - namespace { //Test fixture... - - class DummyWidget - : public gui::test::MockElm - { - protected: - virtual ~DummyWidget() { } ///< is an interface - DummyWidget() - : MockElm("DummyWidget") - { } - }; - - class DummyTab - : public DummyWidget - { }; - - }//(End)Test fixture /******************************************************************************//** @@ -93,6 +78,7 @@ namespace test { * rather than on the real UI topology. * @see GenNodeLocationQuery * + * @see [Mock testing support](test-element-access.hpp) * @see id-scheme.hpp * @see ViewLocator * @see ViewSpecDSL_test diff --git a/tests/gui/test/test-element-access.hpp b/tests/gui/test/test-element-access.hpp index 000385722..3709ad709 100644 --- a/tests/gui/test/test-element-access.hpp +++ b/tests/gui/test/test-element-access.hpp @@ -22,29 +22,25 @@ /** @file test-element-access.hpp - ** Generic building block in the Lumiera GUI model. - ** A model::Element has a unique identifier, which is tied to the - ** identification scheme used in the "real" model in Proc-Layer. - ** Model elements can be addressed receive mutations caused by changes - ** and rebuilding of elements within the Session; moreover, a generic - ** representation of attributes is provided. + ** Unit test helper for access to UI elements without actually running an UI. ** ** @note as of 1/2015 this is a first draft and WIP-WIP-WIP ** @todo WIP ///////////////////////TICKET #1134 ** - ** @see ////TODO_test usage example - ** @see element.cpp implementation + ** @see ElementAccess_test usage example + ** @see elem-access-dir.hpp real implementation ** */ -#ifndef GUI_MODEL_TEST_ELEMENT_ACCESS_H -#define GUI_MODEL_TEST_ELEMENT_ACCESS_H +#ifndef GUI_TEST_ELEMENT_ACCESS_H +#define GUI_TEST_ELEMENT_ACCESS_H #include "lib/error.hpp" #include "gui/model/element-access.hpp" #include "gui/interact/ui-coord.hpp" +#include "test/mock-elm.hpp" //#include "lib/symbol.hpp" //#include "lib/util.hpp" @@ -52,22 +48,38 @@ -namespace gui { -namespace model { +namespace gui { +namespace test { // using util::isnil; // using std::string; using interact::UICoord; + /* === Dummy Widgets for Unit testing === */ + + class DummyWidget + : public MockElm + { + protected: + virtual ~DummyWidget() { } ///< is an interface + DummyWidget() + : MockElm("DummyWidget") + { } + }; + + class DummyTab + : public DummyWidget + { }; + + + /** - * Basic (abstracted) view of... - * - * @see SomeSystem - * @see NA_test + * Mock implementation of the model::ElementAccess interface for testing without actual UI. + * @see ElementAccess_test */ class TestElementAccess - : public ElementAccess + : public model::ElementAccess { public: @@ -82,15 +94,16 @@ namespace model { UICoord expectedQuery; /** ...and if acceptable, the next query will answer with this object */ - void* expectedAnswer; + model::Tangible* expectedAnswer; /* == ElementAccess interface == */ RawResult - performAccessTo (UICoord, size_t limitCreation) override + performAccessTo (UICoord target, size_t limitCreation) override { - UNIMPLEMENTED ("internal access function"); + CHECK (target == expectedQuery); + return expectedAnswer; } @@ -100,22 +113,5 @@ namespace model { - - - /** @internal in case - */ -#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1134 - template - inline void - ElementAccess::maybe () const - { - UNIMPLEMENTED ("tbw"); - } -#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1134 - - - - - -}} // namespace gui::model -#endif /*GUI_MODEL_TEST_ELEMENT_ACCESS_H*/ +}} // namespace gui::test +#endif /*GUI_TEST_ELEMENT_ACCESS_H*/ diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 935d6abbb..c3cb059bf 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -12872,12 +12872,14 @@ - - + + - - + + + + @@ -12903,13 +12905,21 @@ - - + + + + + + + - + + + + @@ -12920,7 +12930,7 @@ - +