61#ifndef VAULT_GEAR_TEST_ACTIVITY_DETECTOR_H
62#define VAULT_GEAR_TEST_ACTIVITY_DETECTOR_H
120 class ActivityDetector;
147 operator bool()
const {
return _Parent::operator bool(); }
160 template<
typename...ARGS>
164 return delegate (&EventMatch::arg<ARGS...>, args...);
193 return delegate (&EventMatch::argPos<Time const&>,
size_t(JOB_ARG_POS_TIME),
time);
203 template<
typename...ARGS>
208 (this->*fun) (forward<ARGS> (args)...));
232 template<
typename RET,
typename...ARGS>
248 ,
seqNr_{&invocationSeqNr}
256 template<
typename VAL>
260 retVal_ = std::forward<VAL> (riggedResponse);
261 return std::move (*
this);
269 implFun_ = std::forward<FUN> (customImpl);
270 return std::move (*
this);
285 operator string()
const
292 template<
typename SIG>
361 return unConst(
this)->target();
416 return "Probe("+
string{
log_}+
")";
422 ,
log_{id, masterLog, invocationSeqNr}
426 :
Activity{*this, reinterpret_cast<size_t> (&subject)}
427 ,
log_{id, masterLog, invocationSeqNr}
460 :
eventLog_{
"ActivityDetector" + (isnil (id)? string{}:
"("+id+
")")}
464 operator string()
const
472 return "\n____Event-Log___________________________\n"
474 +
"\n────╼━━━━━━━━╾──────────────────────────"
509 template<
typename SIG>
521 buildDiagnosticFun<SIG_JobDiagnostic> (
id));
526 ,
Time nominal = lib::test::randTime()
527 ,
size_t extra = rani())
531 invoKey.
part.t = _raw(nominal);
586 struct FakeExecutionCtx;
615 operator string()
const {
return "≺test::CTX≻"; }
Descriptor for a piece of operational logic performed by the scheduler.
Helper to log and verify the occurrence of events.
EventLog & addAttrib(string const &key, X &&initialiser, ARGS &&...args)
Qualify the latest entry: set further attribute(s)
EventLog & event(string text)
log some text as event
EventLog & clear()
purge log contents while retaining just the original Header-ID
EventMatch verifyCall(string match) const
start a query to match especially a function call
EventMatch verifyEvent(string match) const
start a query to match for some event.
EventMatch ensureNot(string match) const
start a query to ensure the given expression does not match.
EventLog & call(string target, string function)
Log occurrence of a function call with no arguments.
EventMatch & beforeEvent(string match)
find a match for an "event" after the current point of reference
EventMatch & locateCall(string match)
basic search for some specific function invocation
EventMatch & afterEvent(string match)
EventMatch & attrib(string key, string valueMatch)
refine filter to additionally match on a specific attribute
Offset measures a distance in time.
basic constant internal time value.
a mutable time value, behaving like a plain number, allowing copy and re-accessing
Lumiera's internal time value datatype.
static const Time NEVER
border condition marker value. NEVER >= any time value
static const Time ANYTIME
border condition marker value. ANYTIME <= any time value
ItemWrapper & defaultInit()
implant a default-initialised instance of the payload type
Any copy and copy construction prohibited.
Record to describe an Activity, to happen within the Scheduler's control flow.
bool is(Activity::Verb expectedVerb) const
activity::Proc activate(Time now, EXE &executionCtx)
Core Operation: Activate and perform this Activity.
Activity * next
Activities are organised into chains to represent relations based on verbs.
activity::Proc dispatch(Time now, EXE &executionCtx)
Entrance point for an activation, which has been dispatched indirectly through the dispatch and/or pr...
std::string showVerb() const
@ HOOK
invoke an extension point through the activity::Hook interface
@ GATE
probe window + count-down; activate next Activity, else re-schedule
Interface of the closure for frame rendering jobs.
Individual frame rendering task, forwarding to a closure.
Stub/Test implementation of the JobFunctor interface for a render job to do nothing at all
Extension point to invoke a callback from Activity activation.
operator std::string() const
A rigged CALLBACK-Activity to watch passing of activations.
Activity const * target() const
static Time lastInvoked(Activity const *act)
Time getDeadline() const override
ActivityProbe(Activity const &subject, string id, EventLog &masterLog, uint const &invocationSeqNr)
activity::Proc activation(Activity &thisHook, Time now, void *executionCtx) override
Callback on activation of the corresponding HOOK-Activity.
std::string diagnostic() const override
activity::Proc notify(Activity &thisHook, Time now, void *executionCtx) override
Callback when dispatching a NOTIFY-Activity to thisHook.
ActivityProbe(string id, EventLog &masterLog, uint const &invocationSeqNr)
A Mock functor, logging all invocations into the EventLog.
DiagnosticFun && implementedAs(FUN &&customImpl)
use the given λ to provide (optional) implementation logic
std::function< RET(ARGS...)> ImplFun
DiagnosticFun(string id, EventLog &masterLog, uint const &invocationSeqNr)
DiagnosticFun && returning(VAL &&riggedResponse)
prepare a response value to return from the mock invocation
RET operator()(ARGS ...args) const
mock function call operator: logs all invocations
A Mocked job operation to detect any actual invocation.
JobKind getJobKind() const
string diagnostic() const override
void invokeJobOperation(JobParameter param) override
rigged diagnostic implementation of job invocation
_DiagnosticFun< SIG_JobDiagnostic >::Type MockOp
MockJobFunctor(MockOp mockedJobOperation)
Diagnostic context to record and evaluate activations within the Scheduler.
activity::Proc(Time) SIG_tick
bool wasInvoked(Activity const &hook)
ActivityMatch verifySeqIncrement(uint seqNr)
bool wasInvoked(Activity const *hook)
RebindVariadic< DiagnosticFun, SigTypes >::Type Type
auto buildDiagnosticFun(string id)
Generic testing helper: build a λ-mock, logging all invocations.
std::deque< MockJobFunctor > mockOps_
lib::meta::_Fun< SIG >::Args Args
_DiagnosticFun< void(string)>::Type Logger
JobClosure & buildMockJobFunctor(string id)
ActivityMatch ensureNoInvocation(string fun)
Activity & buildActivationProbe(string id)
build a rigged HOOK-Activity to record each invocation
FakeExecutionCtx executionCtx
Time invokeTime(Activity const &hook)
Activity & insertActivationTap(Activity *&wiring, string id="")
build ActivationProbe to record each activation before passing it to the subject
void(Time, size_t) SIG_done
activity::Proc(Time, Time, Activity *, FakeExecutionCtx &) SIG_post
void(Time, size_t) SIG_work
lib::meta::Prepend< Ret, Args >::Seq SigTypes
ActivityDetector(string id="")
Time invokeTime(Activity const *hook)
Job buildMockJob(string id="", Time nominal=lib::test::randTime(), size_t extra=rani())
Activity & watchGate(Activity *&wiring, string id="")
Activity & buildGateWatcher(Activity &gate, string id="")
Activity & buildActivationTap(Activity const &subject, string id="")
build ActivationProbe to record each activation before passing it to the subject
ActivityMatch verifyInvocation(string fun)
lib::meta::_Fun< SIG >::Ret Ret
std::deque< ActivityProbe > mockActs_
uint incrementSeq()
increment the internal invocation sequence number
ActivityMatch & arg(ARGS const &...args)
qualifier: additionally match the function arguments
ActivityMatch & afterSeqIncrement(uint seqNr)
ActivityMatch(lib::test::EventMatch &&matcher)
ActivityMatch & afterInvocation(string match)
ActivityMatch & beforeInvocation(string match)
ActivityMatch & delegate(_Parent &(_Parent::*fun)(ARGS...), ARGS &&...args)
ActivityMatch & beforeSeqIncrement(uint seqNr)
special query to match an increment of the sequence number
ActivityMatch & seq(uint seqNr)
qualifier: additionally require the indicated sequence number
ActivityMatch & timeArg(Time const &time)
qualifier: additionally match the nominal time argument of JobFunctor invocation
Support for verifying the occurrence of events from unit tests.
Metaprogramming tools for detecting and transforming function types.
Adapter to store and hold an element of arbitrary type in local storage.
Definition of a render job.
@ TEST_JOB
test and diagnostic and research
struct InvocationInstanceID::@62 part
opaque ID attached to each individual job invocation.
const_LList llist_cmpfn void * extra
boost::rational< int64_t > FSecs
rational representation of fractional seconds
int rani(uint bound=_iBOUND())
Test runner and basic definitions for tests.
ostream & showAdr(ostream &stream, void const *addr)
preconfigured format for pretty-printing of addresses
std::string toString(TY const &val) noexcept
get some string representation of any object, reliably.
OBJ * unConst(const OBJ *)
shortcut to save some typing when having to define const and non-const variants of member functions
string join(COLL &&coll, string const &delim=", ")
enumerate a collection's contents, separated by delimiter.
bool isnil(lib::time::Duration const &dur)
Proc
Result instruction from Activity activation.
@ PASS
pass on the activation down the chain
void(Time, int32_t) SIG_JobDiagnostic
const size_t JOB_ARG_POS_TIME
Time SCHED_TIME_MARKER
marker value for "current scheduler time" used in tests
lumiera_jobParameter const & JobParameter
Vault-Layer implementation namespace root.
Generic implementation of a JobFunctor to perform no calculations.
Generating (pseudo) random numbers with controlled seed.
Mock setup of the execution context for Activity activation.
_DiagnosticFun< SIG_post >::Type post
FakeExecutionCtx(ActivityDetector &detector)
_DiagnosticFun< SIG_tick >::Type tick
function< Time()> getSchedTime
_DiagnosticFun< SIG_done >::Type done
_DiagnosticFun< SIG_work >::Type work
A collection of frequently used helper functions to support unit testing.
a family of time value like entities and their relationships.
Some basic facilities for manipulating type sequences.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Metaprogramming support to rebuild and rebind variadic templates.
Basic set of definitions and includes commonly used together (Vault).