2015-01-06 14:37:26 +01:00
|
|
|
/*
|
2018-04-07 01:00:25 +02:00
|
|
|
TEST-ELEMENT-ACCESS.hpp - fake access directory to handle generic UI entities for test
|
2015-01-06 14:37:26 +01:00
|
|
|
|
|
|
|
|
Copyright (C) Lumiera.org
|
2018-04-07 01:00:25 +02:00
|
|
|
2018, Hermann Vosseler <Ichthyostega@web.de>
|
2015-01-06 14:37:26 +01:00
|
|
|
|
|
|
|
|
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 02139, USA.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2018-04-07 01:00:25 +02:00
|
|
|
/** @file test-element-access.hpp
|
2018-04-14 00:37:30 +02:00
|
|
|
** Unit test helper for access to UI elements without actually running an UI.
|
2015-01-06 14:37:26 +01:00
|
|
|
**
|
|
|
|
|
** @note as of 1/2015 this is a first draft and WIP-WIP-WIP
|
2018-04-07 01:00:25 +02:00
|
|
|
** @todo WIP ///////////////////////TICKET #1134
|
2015-01-06 14:37:26 +01:00
|
|
|
**
|
2018-04-14 00:37:30 +02:00
|
|
|
** @see ElementAccess_test usage example
|
|
|
|
|
** @see elem-access-dir.hpp real implementation
|
2015-01-06 14:37:26 +01:00
|
|
|
**
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2018-04-14 00:37:30 +02:00
|
|
|
#ifndef GUI_TEST_ELEMENT_ACCESS_H
|
|
|
|
|
#define GUI_TEST_ELEMENT_ACCESS_H
|
2015-01-06 14:37:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "lib/error.hpp"
|
2018-04-07 01:00:25 +02:00
|
|
|
#include "gui/model/element-access.hpp"
|
2018-04-08 18:28:44 +02:00
|
|
|
#include "gui/interact/ui-coord.hpp"
|
2018-04-14 00:37:30 +02:00
|
|
|
#include "test/mock-elm.hpp"
|
2015-01-06 14:37:26 +01:00
|
|
|
//#include "lib/symbol.hpp"
|
2018-04-07 02:28:29 +02:00
|
|
|
//#include "lib/util.hpp"
|
2015-01-06 14:37:26 +01:00
|
|
|
|
2018-04-07 02:28:29 +02:00
|
|
|
//#include <string>
|
2015-01-06 14:37:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-04-14 00:37:30 +02:00
|
|
|
namespace gui {
|
|
|
|
|
namespace test {
|
2015-01-06 14:37:26 +01:00
|
|
|
|
2018-04-07 02:28:29 +02:00
|
|
|
// using util::isnil;
|
|
|
|
|
// using std::string;
|
2018-04-08 18:28:44 +02:00
|
|
|
using interact::UICoord;
|
2015-01-06 14:37:26 +01:00
|
|
|
|
|
|
|
|
|
2018-04-14 00:37:30 +02:00
|
|
|
/* === Dummy Widgets for Unit testing === */
|
|
|
|
|
|
|
|
|
|
class DummyWidget
|
|
|
|
|
: public MockElm
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual ~DummyWidget() { } ///< is an interface
|
|
|
|
|
DummyWidget()
|
|
|
|
|
: MockElm("DummyWidget")
|
|
|
|
|
{ }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class DummyTab
|
|
|
|
|
: public DummyWidget
|
|
|
|
|
{ };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-01-06 14:37:26 +01:00
|
|
|
/**
|
2018-04-14 00:37:30 +02:00
|
|
|
* Mock implementation of the model::ElementAccess interface for testing without actual UI.
|
|
|
|
|
* @see ElementAccess_test
|
2015-01-06 14:37:26 +01:00
|
|
|
*/
|
2018-04-07 02:28:29 +02:00
|
|
|
class TestElementAccess
|
2018-04-14 00:37:30 +02:00
|
|
|
: public model::ElementAccess
|
2015-01-06 14:37:26 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit
|
2018-04-07 02:28:29 +02:00
|
|
|
TestElementAccess ()
|
2015-01-06 14:37:26 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
2018-04-08 18:28:44 +02:00
|
|
|
/* == Test/Diagnostics interface == */
|
2015-01-06 14:37:26 +01:00
|
|
|
|
2018-04-08 18:28:44 +02:00
|
|
|
/** the next query will fail unless it presents this Path */
|
|
|
|
|
UICoord expectedQuery;
|
2015-01-06 14:37:26 +01:00
|
|
|
|
2018-04-08 18:28:44 +02:00
|
|
|
/** ...and if acceptable, the next query will answer with this object */
|
2018-04-14 00:37:30 +02:00
|
|
|
model::Tangible* expectedAnswer;
|
2018-04-08 18:28:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/* == ElementAccess interface == */
|
2015-01-06 14:37:26 +01:00
|
|
|
|
2018-04-09 01:14:12 +02:00
|
|
|
RawResult
|
2018-04-14 01:59:41 +02:00
|
|
|
performAccessTo (UICoord const& target, size_t limitCreation) override
|
2018-04-09 00:51:24 +02:00
|
|
|
{
|
2018-04-14 00:37:30 +02:00
|
|
|
CHECK (target == expectedQuery);
|
|
|
|
|
return expectedAnswer;
|
2018-04-09 00:51:24 +02:00
|
|
|
}
|
2015-01-06 14:37:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-04-14 00:37:30 +02:00
|
|
|
}} // namespace gui::test
|
|
|
|
|
#endif /*GUI_TEST_ELEMENT_ACCESS_H*/
|