2018-04-07 01:00:25 +02:00
/*
ElementAccess ( Test ) - verify mechanics of low - level UI element access
Copyright ( C ) Lumiera . org
2018 , Hermann Vosseler < Ichthyostega @ web . de >
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation ; either version 2 of
the License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2018-04-07 02:28:29 +02:00
/** @file element-access-test.cpp
* * unit test \ ref ElementAccess_test
2018-04-07 01:00:25 +02:00
*/
# include "lib/test/run.hpp"
# include "lib/test/test-helper.hpp"
2018-04-07 02:28:29 +02:00
//#include "gui/interact/view-spec-dsl.hpp"
# include "test/test-element-access.hpp"
2018-04-07 01:00:25 +02:00
# include "gui/interact/ui-coord.hpp"
2018-04-07 02:28:29 +02:00
//#include "gen-node-location-query.hpp"
2018-04-07 01:00:25 +02:00
# include "lib/depend-inject.hpp"
# include "lib/format-cout.hpp"
//#include "lib/idi/entry-id.hpp"
//#include "lib/diff/gen-node.hpp"
2018-04-08 18:28:44 +02:00
# include "lib/util.hpp"
2018-04-07 01:00:25 +02:00
//#include <string>
//#include <vector>
2018-04-07 02:28:29 +02:00
//using std::string;
//using lib::diff::MakeRec;
//using lib::diff::Rec;
2018-04-07 01:00:25 +02:00
//using lib::idi::EntryID;
//using lib::diff::GenNode;
2018-04-08 18:28:44 +02:00
using util : : isSameObject ;
2018-04-07 01:00:25 +02:00
//using util::isnil;
namespace gui {
2018-04-07 02:28:29 +02:00
namespace model {
2018-04-07 01:00:25 +02:00
namespace test {
// using lumiera::error::LUMIERA_ERROR_WRONG_TYPE;
2018-04-07 02:28:29 +02:00
// using lib::test::showSizeof;
2018-04-08 18:28:44 +02:00
using interact : : UICoord ;
2018-04-07 01:00:25 +02:00
2018-04-07 02:28:29 +02:00
using MockAccess = lib : : DependInject < ElementAccess > : : Local < TestElementAccess > ;
2018-04-08 18:28:44 +02:00
using AccessAPI = lib : : Depend < ElementAccess > ;
2018-04-07 01:00:25 +02:00
namespace { //Test fixture...
2018-04-08 18:28:44 +02:00
class DummyWidget
: : : util : : NonCopyable
{
protected :
virtual ~ DummyWidget ( ) { } ///< is an interface
} ;
class DummyTab
: public DummyWidget
{ } ;
2018-04-07 01:00:25 +02:00
} //(End)Test fixture
/******************************************************************************/ /**
2018-04-07 02:28:29 +02:00
* @ test verify the usage pattern of low - level UI element access , based on a
* mock implementation of the accessor directory .
2018-04-08 18:28:44 +02:00
* @ 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 < GenNode > `
* rather than on the real UI topology .
* @ see GenNodeLocationQuery
2018-04-07 01:00:25 +02:00
*
* @ see id - scheme . hpp
* @ see ViewLocator
2018-04-07 02:28:29 +02:00
* @ see ViewSpecDSL_test
2018-04-07 01:00:25 +02:00
*/
class ElementAccess_test : public Test
{
virtual void
run ( Arg )
{
2018-04-08 18:28:44 +02:00
verify_simpleAccess ( ) ;
2018-04-07 01:00:25 +02:00
verify_standardUsage ( ) ;
verify_alternatives ( ) ;
verify_genericInvocation ( ) ;
}
2018-04-08 18:28:44 +02:00
/** @test simple access to an existing element designated by coordinates */
2018-04-07 01:00:25 +02:00
void
2018-04-08 18:28:44 +02:00
verify_simpleAccess ( )
2018-04-07 01:00:25 +02:00
{
2018-04-08 18:28:44 +02:00
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 < DummyWidget > ( location ) ;
CHECK ( answer . isValid ( ) ) ;
DummyWidget & widget = answer ;
CHECK ( INSTANCEOF ( DummyTab , & widget ) ) ;
CHECK ( isSameObject ( widget , dummyTab ) ) ;
2018-04-07 01:00:25 +02:00
}
void
verify_standardUsage ( )
{
}
void
verify_alternatives ( )
{
UNIMPLEMENTED ( " querying and selection of location alternatives " ) ;
}
void
verify_genericInvocation ( )
{
/////////////////////////////////////////////////////////////////////////////////////////TICKET 1134 : how to create ViewLocator mock without global context??
//-------------------------------------------------------------Test-Fixture
//--------------------------------------------------------------(End)Test-Fixture
// ErrorLogView errorLog = viwLocator.get<ErrorLogView>();
// TimelineView timeline = viwLocator.get<TimelineView>();
/////////////////////////////////////////////////////////////////////////////////////////TICKET 1134 : use an EventLog to verify the forwarded invocations??
}
} ;
/** Register this test class... */
2018-04-07 02:28:29 +02:00
LAUNCHER ( ElementAccess_test , " unit gui " ) ;
2018-04-07 01:00:25 +02:00
2018-04-07 02:28:29 +02:00
} } } // namespace gui::model::test