Project

General

Profile

Actions

Feature #3769

closed

DummyClientFace::processEvents works with UnitTestTimeFixture

Added by Junxiao Shi over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Utils
Target version:
Start date:
09/07/2016
Due date:
% Done:

100%

Estimated time:
3.00 h

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.

Actions #1

Updated by Junxiao Shi over 7 years ago

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

Actions #2

Updated by Junxiao Shi over 7 years ago

  • Status changed from New to In Progress
  • Assignee set to Junxiao Shi
Actions #3

Updated by Junxiao Shi over 7 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.

Actions #4

Updated by Junxiao Shi over 7 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF