From ef04ebfb1750d8ff34a3779055d4fe2a0f848d29 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 13 Feb 2016 01:27:22 +0100 Subject: [PATCH] add skeleton of a mock implementation within test::Nexus --- .../interact/presentation-state-manager.hpp | 13 ++- tests/gui/test/test-nexus.cpp | 92 ++++++++++++++++++- tests/gui/test/test-nexus.hpp | 2 +- 3 files changed, 99 insertions(+), 8 deletions(-) diff --git a/src/gui/interact/presentation-state-manager.hpp b/src/gui/interact/presentation-state-manager.hpp index d7160025a..b4019ceb3 100644 --- a/src/gui/interact/presentation-state-manager.hpp +++ b/src/gui/interact/presentation-state-manager.hpp @@ -83,19 +83,22 @@ namespace interact { virtual lib::diff::GenNode const& - currentState (string elementSymbol, string propertyID) =0; + currentState (string elementSymbol, string propertyID) const =0; virtual void - replayState (string elementSymbol, string propertyID) =0; + replayState (string elementSymbol, string propertyID) =0; virtual void - replayAllState () =0; + replayAllState() =0; virtual void - replayAllState (string propertyID) =0; + replayAllState (string propertyID) =0; virtual void - replayAllProperties (string elementSymbol) =0; + replayAllProperties (string elementSymbol) =0; + + virtual void + clearState() =0; private: }; diff --git a/tests/gui/test/test-nexus.cpp b/tests/gui/test/test-nexus.cpp index b9455a498..2f3af6d43 100644 --- a/tests/gui/test/test-nexus.cpp +++ b/tests/gui/test/test-nexus.cpp @@ -74,6 +74,7 @@ using lib::diff::DataValues; using lib::idi::instanceTypeID; using lib::test::EventLog; using gui::ctrl::BusTerm; +using gui::interact::PresentationStateManager; using proc::control::Command; using proc::control::CommandImpl; using proc::control::HandlingPattern; @@ -547,20 +548,107 @@ namespace test{ + namespace { // install a diagnostic dummy-command-handler + + using ID = lib::idi::BareEntryID; + + class SimulatedStateManager + : public PresentationStateManager + { + + /* === PresentationStateManager interface === */ + + virtual lib::diff::GenNode const& + currentState (string elementSymbol, string propertyID) const override + { + UNIMPLEMENTED ("retrieve captured state"); + } + + + virtual void + replayState (string elementSymbol, string propertyID) override + { + UNIMPLEMENTED ("retrieve captured state"); + } + + + virtual void + replayAllState() override + { + UNIMPLEMENTED ("retrieve captured state"); + } + + + virtual void + replayAllState (string propertyID) override + { + UNIMPLEMENTED ("retrieve captured state"); + } + + + virtual void + replayAllProperties (string elementSymbol) override + { + UNIMPLEMENTED ("retrieve captured state"); + } + + + public: + + virtual void + clearState() override + { + UNIMPLEMENTED ("discard all stored state information"); + } + + void + record (ID const& elementID, lib::diff::GenNode const& stateMark) + { + UNIMPLEMENTED ("handle and record a state mark message"); + } + }; + + lib::Depend stateManager; + + }//(End)diagnostic mock-state-manager + + + /** + * install a standard handler for state mark messages, + * which is actually backed by a mock implementation of the + * PresentationStateManager interface. This mock is based on + * the same implementation techniques as the full fledged + * state manager in the Lumiera GTK UI; any state mark + * notification messages appearing after that point + * at the test-UI-Bus will be accounted for. + */ interact::PresentationStateManager& Nexus::useMockStateManager() { - UNIMPLEMENTED("install a presentation manager mock and state mark handler"); + // discard possible leftover + // from previous test installations + stateManager().clearState(); + + testNexus().installStateMarkHandler( + [&](ID const& elementID, lib::diff::GenNode const& stateMark) + { + stateManager().record (elementID, stateMark); + }); + + return getMockStateManager(); } interact::PresentationStateManager& Nexus::getMockStateManager() { - UNIMPLEMENTED("access installed Mock presentation manager"); + return stateManager(); } + + + /** * @return a defunct BusTerm with up-link to [ZombieNexus] * @remarks useful to create zombie mock UI-Elements for testing. diff --git a/tests/gui/test/test-nexus.hpp b/tests/gui/test/test-nexus.hpp index b18d98be1..8b0909241 100644 --- a/tests/gui/test/test-nexus.hpp +++ b/tests/gui/test/test-nexus.hpp @@ -91,7 +91,7 @@ namespace test{ /* == allow to set custom handlers for commands and state changes == */ using CommandHandler = std::function; - using StateMarkHandler = std::function; + using StateMarkHandler = std::function; static void setCommandHandler (CommandHandler =CommandHandler()); static void setStateMarkHandler (StateMarkHandler =StateMarkHandler());