Feature #4024
closedNetworkMonitor: stub implementation
100%
Description
In NetworkMonitor
, allow getNetworkInterface
and listNetworkInterfaces
return value to be mocked in a test case.
Updated by Junxiao Shi over 7 years ago
- Blocks Feature #4021: FaceSystem: use NetworkMonitor::listNetworkInterfaces() added
Updated by Junxiao Shi over 7 years ago
- Blocked by Feature #3353: NetworkMonitor: emit fine-grained signals when the state of a network interface changes added
Updated by Junxiao Shi over 7 years ago
- Related to Feature #4025: NetworkMonitor: empty impl on unsupported platform added
Updated by Junxiao Shi over 7 years ago
- Status changed from New to In Progress
- Assignee set to Junxiao Shi
Design:
- Pure virtual base class
NetworkMonitor::ImplBase
is introduced. It is a friend ofNetworkMonitor
, and offers protected methods to modifyNetworkMonitor
data structures or emit signals on it.ImplBase
type is public API. - Existing
Impl
class inherit fromImplBase
. It is not a friend ofNetworkMonitor
, but accessesNetworkMonitor
data structures and signals viaImplBase
protected methods.Impl
type is not public API. NetworkMonitor
constructor takesunique_ptr<NetworkMonitor::ImplBase>
, which defaults tonullptr
. Passingnullptr
causes the constructor to internally make anImpl
instance.NetworkInterface
type setters are made public.NetworkMonitor
APIs that returnNetworkInterface
are changed to returnconst NetworkInterface
instead so that setters cannot be invoked by outsider.MockImpl
class inherits fromImplBase
and exposes its protected methods as public. To make a mockNetworkMonitor
, pass aMockImpl
instance toNetworkMonitor
constructor.
Updated by Davide Pesavento over 7 years ago
Junxiao Shi wrote:
NetworkInterface
type setters are made public.
I'd rather keep them private.
Updated by Junxiao Shi over 7 years ago
Reply to note-5:
How would you propose to let a test case create and update a NetworkInterface
?
What's the harm of making the setters public? If someone uses const_cast
, it's their problem. Testability is more important than absolute protection.
Updated by Davide Pesavento over 7 years ago
@Junxiao, are you still working on this?
Updated by Junxiao Shi over 7 years ago
I'm waiting for the design discussion to be resolved.
For coding, I'm waiting for #3817 to close in order to avoid conflicts.
Updated by Davide Pesavento over 7 years ago
- Blocked by Feature #3817: NetworkMonitor fine-grained signals for macOS added
Updated by Davide Pesavento over 7 years ago
- Blocked by deleted (Feature #3817: NetworkMonitor fine-grained signals for macOS)
Updated by Davide Pesavento over 7 years ago
Updated by Junxiao Shi over 7 years ago
- % Done changed from 0 to 20
- Estimated time set to 5.00 h
https://gerrit.named-data.net/3978 patchset1 illustrates some of the API changes. I've skipped macOS variant for now. It also does not include MockImpl
yet.
Updated by Junxiao Shi over 7 years ago
- % Done changed from 20 to 40
https://gerrit.named-data.net/3978 patchset2 brings the public API design of MockNetworkMonitor
. It's structured as a subclass of NetworkMonitor
rather than an Impl, because the Impl is passed by unique_ptr to NetworkMonitor
and thus is solely owned by NetworkMonitor
, so it's unsafe for the caller to keep a reference to an Impl. Instead, MockNetworkMonitor
can internally manage an Impl and forward calls to it.
Updated by Junxiao Shi over 7 years ago
- Status changed from In Progress to Code review
- % Done changed from 40 to 100
Updated by Alex Afanasyev over 7 years ago
- Status changed from Code review to Closed
Updated by Davide Pesavento over 7 years ago
- Subject changed from NetworkMonitor: mock impl to NetworkMonitor: stub implementation