From 0b21eeae2f12463a0cecdb80a1b183cbc1e5a344 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 15 Jan 2016 02:29:33 +0100 Subject: [PATCH] extend unit test verification on UI command invocation --- tests/gui/abstract-tangible-test.cpp | 13 +++++++++++++ tests/gui/bus-term-test.cpp | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/gui/abstract-tangible-test.cpp b/tests/gui/abstract-tangible-test.cpp index 11feafa8b..20d6b24c7 100644 --- a/tests/gui/abstract-tangible-test.cpp +++ b/tests/gui/abstract-tangible-test.cpp @@ -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 diff --git a/tests/gui/bus-term-test.cpp b/tests/gui/bus-term-test.cpp index 98e2b69a4..345abef1a 100644 --- a/tests/gui/bus-term-test.cpp +++ b/tests/gui/bus-term-test.cpp @@ -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{"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));