2015-11-26 22:23:43 +01:00
|
|
|
/*
|
|
|
|
|
AbstractTangible(Test) - cover the operations of any tangible UI element
|
|
|
|
|
|
|
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2015, 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 02139, USA.
|
|
|
|
|
|
|
|
|
|
* *****************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @file abstract-tangible-test.cpp
|
|
|
|
|
* Verify the common base shared by all interface elements of relevance.
|
|
|
|
|
** This test is not so much a test, than a test of the test support for testing
|
|
|
|
|
** [primary elements][gui::model::Tangible] of the Lumiera GTK UI. Any such element
|
|
|
|
|
** is connected to the [UI-Bus][gui::UiBus] and responds to some generic actions and
|
|
|
|
|
** interaction patterns. This is the foundation of any presentation state recording
|
|
|
|
|
** and restoration, and it serves to invoke any persistent action on the
|
|
|
|
|
** [Session] through a single channel and access point.
|
|
|
|
|
**
|
|
|
|
|
** What is covered here is actually a **test mock**. Which in turn enables us
|
|
|
|
|
** to cover interface interactions and behaviour in a generic fashion, without
|
|
|
|
|
** actually having to operate the interface.
|
|
|
|
|
**
|
|
|
|
|
** @note as of 11/2015 this is a draft into the blue...
|
|
|
|
|
** @todo WIP ///////////////////////TICKET #959
|
|
|
|
|
** @todo WIP ///////////////////////TICKET #956
|
|
|
|
|
** @todo WIP ///////////////////////TICKET #975
|
|
|
|
|
** @todo WIP ///////////////////////TICKET #961 : tests to pass...
|
|
|
|
|
**
|
|
|
|
|
** @see gui::UiBus
|
|
|
|
|
**
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "lib/test/run.hpp"
|
2015-11-27 02:38:23 +01:00
|
|
|
#include "lib/test/test-helper.hpp"
|
2015-11-28 23:50:56 +01:00
|
|
|
#include "lib/test/event-log.hpp"
|
2015-11-28 21:43:09 +01:00
|
|
|
#include "test/mock-elm.hpp"
|
2015-11-28 23:50:56 +01:00
|
|
|
#include "lib/idi/entry-id.hpp"
|
2015-11-28 20:55:28 +01:00
|
|
|
#include "lib/error.hpp"
|
2015-11-26 22:23:43 +01:00
|
|
|
//#include "gui/model/session-facade.hpp"
|
|
|
|
|
//#include "gui/model/diagnostics.hpp"
|
|
|
|
|
//#include "lib/util.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//#include <boost/lexical_cast.hpp>
|
|
|
|
|
//#include <iostream>
|
|
|
|
|
//#include <string>
|
|
|
|
|
//#include <map>
|
|
|
|
|
|
2015-11-28 23:50:56 +01:00
|
|
|
using gui::test::MockElm;
|
|
|
|
|
using lib::test::EventLog;
|
|
|
|
|
using lib::idi::EntryID;
|
2015-11-26 22:23:43 +01:00
|
|
|
//using boost::lexical_cast;
|
|
|
|
|
//using util::contains;
|
|
|
|
|
//using std::string;
|
|
|
|
|
//using std::cout;
|
|
|
|
|
//using std::endl;
|
|
|
|
|
|
2015-11-27 02:38:23 +01:00
|
|
|
|
2015-11-26 22:23:43 +01:00
|
|
|
|
|
|
|
|
namespace gui {
|
|
|
|
|
namespace model{
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
|
|
namespace { // test fixture...
|
|
|
|
|
|
|
|
|
|
}//(End) test fixture
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************//**
|
|
|
|
|
* @test cover the basic operations of any tangible UI element,
|
|
|
|
|
* with the help of a mock UI element.
|
|
|
|
|
* - creation
|
|
|
|
|
* - destruction
|
|
|
|
|
* - command invocation
|
|
|
|
|
* - state mark
|
|
|
|
|
* - state mark replay
|
|
|
|
|
* - message casting
|
|
|
|
|
* - error state indication
|
|
|
|
|
*
|
|
|
|
|
* @see SessionElementQuery_test
|
|
|
|
|
* @see gui::model::SessionFacade
|
|
|
|
|
*/
|
|
|
|
|
class AbstractTangible_test : public Test
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
|
run (Arg)
|
|
|
|
|
{
|
|
|
|
|
verify_mockManipulation();
|
|
|
|
|
invokeCommand();
|
|
|
|
|
markState();
|
|
|
|
|
notify();
|
|
|
|
|
mutate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-12-16 02:16:53 +01:00
|
|
|
/** @test verify the UI widget unit test support framework.
|
|
|
|
|
* The generic backbone of the Lumiera UI offers a mock UI element,
|
|
|
|
|
* with the ability to stand-in for actual elements present in the real GUI.
|
|
|
|
|
* This allows us to rig a emulated test user interface to cover interactions
|
|
|
|
|
* involving some communication from or to interface elements. After setting up
|
|
|
|
|
* a [MockElm] with a suitable name / ID, we're able to operate this element
|
|
|
|
|
* programmatically and to send messages and responses from the core "up"
|
|
|
|
|
* to this mocked interface. And since this mock element embodies an
|
|
|
|
|
* [event log][EventLog], the unit test code can verify the occurrence
|
|
|
|
|
* of expected events, invocations and responses.
|
2015-11-26 22:23:43 +01:00
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
verify_mockManipulation ()
|
|
|
|
|
{
|
2015-11-27 02:38:23 +01:00
|
|
|
MockElm mock("dummy");
|
2015-11-28 23:50:56 +01:00
|
|
|
|
2015-12-16 02:16:53 +01:00
|
|
|
CHECK (mock.verify("ctor"));
|
2015-12-16 23:24:11 +01:00
|
|
|
CHECK (mock.verifyEvent("create","dummy"));
|
|
|
|
|
CHECK (mock.verify("ctor").arg("dummy").on(&mock));
|
2015-11-27 02:38:23 +01:00
|
|
|
|
|
|
|
|
CHECK ("dummy" == mock.getID().getSym());
|
2015-11-28 23:50:56 +01:00
|
|
|
CHECK (EntryID<MockElm>("dummy") == mock.getID());
|
2015-11-27 02:38:23 +01:00
|
|
|
|
2015-12-16 02:16:53 +01:00
|
|
|
CHECK (!mock.verifyCall("reset"));
|
2015-11-27 02:38:23 +01:00
|
|
|
|
|
|
|
|
mock.reset();
|
2015-12-16 02:16:53 +01:00
|
|
|
CHECK (mock.verify("reset"));
|
|
|
|
|
CHECK (mock.verifyCall("reset"));
|
|
|
|
|
CHECK (mock.verifyCall("reset").on("dummy"));
|
|
|
|
|
CHECK (mock.verifyEvent("reset"));
|
|
|
|
|
CHECK (mock.verify("reset").after("ctor"));
|
|
|
|
|
CHECK (mock.verify("ctor").before("reset"));
|
|
|
|
|
CHECK (mock.ensureNot("reset").before("ctor"));
|
|
|
|
|
CHECK (mock.ensureNot("ctor").after("reset"));
|
2015-11-27 02:38:23 +01:00
|
|
|
|
2015-12-16 02:16:53 +01:00
|
|
|
CHECK (mock.verify("reset").beforeEvent("reset"));
|
|
|
|
|
CHECK (mock.verifyCall("reset").beforeEvent("reset"));
|
|
|
|
|
CHECK (!mock.verifyCall("reset").afterEvent("reset"));
|
2015-11-27 02:38:23 +01:00
|
|
|
|
|
|
|
|
CHECK (!mock.isTouched());
|
|
|
|
|
CHECK (!mock.isExpanded());
|
|
|
|
|
|
2015-12-16 02:16:53 +01:00
|
|
|
mock.markMsg("dolorem ipsum quia dolor sit amet consectetur adipisci velit.");
|
|
|
|
|
CHECK (mock.verifyNote("Msg"));
|
|
|
|
|
CHECK (mock.verifyCall("noteMsg"));
|
|
|
|
|
CHECK (mock.verifyCall("noteMsg").arg("lorem ipsum"));
|
|
|
|
|
CHECK (mock.verifyCall("noteMsg").argMatch("dolor.+dolor\\s+"));
|
|
|
|
|
CHECK (mock.verifyMatch("Rec\\(note.+kind = Msg.+msg = dolorem ipsum"));
|
2015-11-27 02:38:23 +01:00
|
|
|
|
|
|
|
|
EventLog log = mock.getLog();
|
|
|
|
|
log.verify("ctor")
|
|
|
|
|
.before("reset")
|
|
|
|
|
.before("lorem ipsum");
|
|
|
|
|
|
2015-11-28 23:50:56 +01:00
|
|
|
MockElm foo("foo"), bar("bar");
|
2015-11-27 02:38:23 +01:00
|
|
|
foo.verify("ctor").arg("foo");
|
2015-12-16 02:16:53 +01:00
|
|
|
bar.verify("ctor").arg("bar");
|
2015-11-27 02:38:23 +01:00
|
|
|
|
|
|
|
|
bar.ensureNot("foo");
|
|
|
|
|
log.ensureNot("foo");
|
|
|
|
|
mock.ensureNot("foo");
|
2015-12-16 02:16:53 +01:00
|
|
|
CHECK (!foo.ensureNot("foo"));
|
2015-11-27 02:38:23 +01:00
|
|
|
|
2015-12-06 04:30:39 +01:00
|
|
|
bar.joinLog(mock);
|
|
|
|
|
foo.joinLog(mock);
|
2015-12-16 02:16:53 +01:00
|
|
|
CHECK (log.verifyEvent("logJoin").arg("bar")
|
|
|
|
|
.beforeEvent("logJoin").arg("foo"));
|
2015-11-27 02:38:23 +01:00
|
|
|
|
2015-12-16 02:16:53 +01:00
|
|
|
CHECK (mock.verifyEvent("logJoin").arg("bar")
|
|
|
|
|
.beforeEvent("logJoin").arg("foo"));
|
|
|
|
|
CHECK (mock.verify("ctor").arg("foo"));
|
|
|
|
|
CHECK (log.verify("ctor").arg("foo"));
|
|
|
|
|
CHECK (log.verify("ctor").arg("dummy")
|
|
|
|
|
.before("ctor").arg("bar")
|
|
|
|
|
.before("ctor").arg("foo"));
|
2015-11-27 02:38:23 +01:00
|
|
|
|
|
|
|
|
mock.kill();
|
2015-12-16 02:16:53 +01:00
|
|
|
foo.markMsg("dummy killed");
|
|
|
|
|
CHECK (log.verifyEvent("dtor").on("dummy")
|
|
|
|
|
.beforeCall("noteMsg").on("foo"));
|
2015-11-26 22:23:43 +01:00
|
|
|
}
|
|
|
|
|
|
2015-11-27 02:38:23 +01:00
|
|
|
|
2015-11-26 22:23:43 +01:00
|
|
|
void
|
|
|
|
|
invokeCommand ()
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("invoke an action, pass arguments");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
markState ()
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("mark interface state");
|
2015-11-27 02:38:23 +01:00
|
|
|
|
|
|
|
|
TODO ("be sure also to cover signal diagnostics here");
|
2015-11-26 22:23:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
notify ()
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("receive various kinds of notifications");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
mutate ()
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("mutate the element by diff message");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Register this test class... */
|
|
|
|
|
LAUNCHER (AbstractTangible_test, "unit gui");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}}} // namespace gui::model::test
|