Feature #3769
closed
DummyClientFace::processEvents works with UnitTestTimeFixture
Added by Junxiao Shi over 8 years ago.
Updated over 8 years ago.
Description
When a test case is written with UnitTestTimeFixture
, Face::processEvents
cannot be used because it calls io_service::run()
but does not advance clocks and may be blocked forever.
Instead, the test case must call UnitTestTimeFixture::advanceClocks
.
This can cause complexity when a component needs to be usable in both normal case and in UnitTestTimeFixture
, and cause confusion during test development.
DummyClientFace
should allow overriding Face::processEvents
so that the test case can always call face.processEvents()
even within UnitTestTimeFixture
.
The API should avoid dependency on UnitTestTimeFixture
which differs per project.
API design A
- mark
Face::processEvents
as virtual
- in each project's
UnitTestTimeFixture
, provide a subclass of DummyClientFace
that integrates with the specific UnitTestTimeFixture
UnitTestTimeFixture::createDummyClientFace
creates a DummyClientFace subclass that integrates with this UnitTestTimeFixture
Benefit: minimal changes in ndn-cxx
Drawback: each project has a different subclass which increases maintenance cost
API design B
- mark
Face::processEvents
as virtual
- in
DummyClientFace::Options
, add a function<void(time::nanoseconds)> processEventsOverride
field
- in
DummyClientFace::processEvents
, if options.processEventsOverride
is not empty, call that function; otherwise, call Face::processEvents
UnitTestTimeFixture::getProcessEventsOverride
makes a function object that can be used as DummyClientFace::Options::processEventsOverride
Benefit: uniform interface among projects
Drawback: more complexity in ndn-cxx
- Status changed from New to In Progress
- Assignee set to Junxiao Shi
- Status changed from In Progress to Closed
- % Done changed from 0 to 100
Also available in: Atom
PDF