Feature #3769
closedDummyClientFace::processEvents works with UnitTestTimeFixture
100%
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.
Updated by Junxiao Shi about 9 years ago
API design A
- mark
Face::processEventsasvirtual - in each project's
UnitTestTimeFixture, provide a subclass ofDummyClientFacethat integrates with the specificUnitTestTimeFixture UnitTestTimeFixture::createDummyClientFacecreates a DummyClientFace subclass that integrates with thisUnitTestTimeFixture
Benefit: minimal changes in ndn-cxx
Drawback: each project has a different subclass which increases maintenance cost
API design B
- mark
Face::processEventsasvirtual - in
DummyClientFace::Options, add afunction<void(time::nanoseconds)> processEventsOverridefield - in
DummyClientFace::processEvents, ifoptions.processEventsOverrideis not empty, call that function; otherwise, callFace::processEvents UnitTestTimeFixture::getProcessEventsOverridemakes a function object that can be used asDummyClientFace::Options::processEventsOverride
Benefit: uniform interface among projects
Drawback: more complexity in ndn-cxx
Updated by Junxiao Shi about 9 years ago
- Status changed from New to In Progress
- Assignee set to Junxiao Shi
Updated by Junxiao Shi about 9 years ago
https://gerrit.named-data.net/3217 allows DummyClientFace to override processEvents.
Note that Face::processEvents itself is not virtual, but it calls virtual function Face::doProcessEvents.
Rationale: 1. public virtual violates single responsibility principle 2. default arguments appear once.
Updated by Junxiao Shi almost 9 years ago
- Status changed from In Progress to Closed
- % Done changed from 0 to 100