extend unit test verification on UI command invocation

This commit is contained in:
Fischlurch 2016-01-15 02:29:33 +01:00
parent 5a5beebd15
commit 0b21eeae2f
2 changed files with 16 additions and 1 deletions

View file

@ -60,6 +60,7 @@
using lib::Symbol;
using util::toString;
using gui::test::MockElm;
using lib::test::EventLog;
using lib::idi::EntryID;
@ -325,15 +326,27 @@ namespace test {
int prevState = dummyState;
int concreteParam = 1 +rand() % 100;
// on bus no traces from this command yet...
CHECK (nexusLog.ensureNot(string(DUMMY_CMD_ID)));
// now the ongoing interaction picks up parameter data
mock.prepareCommand (invTrail, lib::diff::Rec({concreteParam}));
CHECK (nexusLog.verifyCall("act").arg("«int»|" +toString(concreteParam))
.beforeEvent("binding for command \""+DUMMY_CMD_ID));
CHECK (dummyState == prevState); // command was not yet invoked
CHECK (nexusLog.ensureNot("invoke command \""+DUMMY_CMD_ID));
// finally the command gets triggered
mock.issueCommand (invTrail);
CHECK (dummyState == concreteParam); // command was indeed invoked
CHECK (nexusLog.verifyCall("act").arg("«int»|" +toString(concreteParam))
.beforeCall("act").arg("DataCap|«int»|"));
CHECK (nexusLog.verifyEvent("binding for command \""+DUMMY_CMD_ID)
.beforeEvent("invoke command \""+DUMMY_CMD_ID));
// verify proper binding, including UNDO state capture

View file

@ -22,6 +22,7 @@
#include "lib/test/run.hpp"
#include "lib/test/test-helper.hpp"
#include "test/test-nexus.hpp"
#include "test/mock-elm.hpp"
#include "lib/idi/entry-id.hpp"
@ -103,6 +104,7 @@ namespace test {
void
attachNewBusTerm ()
{
MARK_TEST_FUN;
// our dummy will be linked with this identity
BareEntryID elmID = EntryID<MockElm>{"zeitgeist"};
@ -128,7 +130,7 @@ namespace test {
// invoke action on element to cause upstream message (with a "state mark")
mock.slotCollapse();
CHECK (elmLog.verifyEvent("collapsed"));
CHECK (nexusLog.verifyCall("note").on("TestNexus").arg(elmID, "GenNode-ID(\"expand\")-DataCap|«bool»|0"));
CHECK (nexusLog.verifyCall("note").on("TestNexus").arg(elmID, "GenNode-ID(\"expand\")-DataCap|«bool»|false"));
// send a state mark down to the mock element
gui::test::Nexus::testUI().mark (elmID, GenNode("Flash", 23));