Feature #4024
closedNetworkMonitor: stub implementation
Added by Junxiao Shi over 8 years ago. Updated over 8 years ago.
100%
Description
In NetworkMonitor, allow getNetworkInterface and listNetworkInterfaces return value to be mocked in a test case.
Updated by Junxiao Shi over 8 years ago
- Blocks Feature #4021: FaceSystem: use NetworkMonitor::listNetworkInterfaces() added
Updated by Junxiao Shi over 8 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 8 years ago
- Related to Feature #4025: NetworkMonitor: empty impl on unsupported platform added
Updated by Junxiao Shi over 8 years ago
- Status changed from New to In Progress
- Assignee set to Junxiao Shi
Design:
- Pure virtual base class
NetworkMonitor::ImplBaseis introduced. It is a friend ofNetworkMonitor, and offers protected methods to modifyNetworkMonitordata structures or emit signals on it.ImplBasetype is public API. - Existing
Implclass inherit fromImplBase. It is not a friend ofNetworkMonitor, but accessesNetworkMonitordata structures and signals viaImplBaseprotected methods.Impltype is not public API. NetworkMonitorconstructor takesunique_ptr<NetworkMonitor::ImplBase>, which defaults tonullptr. Passingnullptrcauses the constructor to internally make anImplinstance.NetworkInterfacetype setters are made public.NetworkMonitorAPIs that returnNetworkInterfaceare changed to returnconst NetworkInterfaceinstead so that setters cannot be invoked by outsider.MockImplclass inherits fromImplBaseand exposes its protected methods as public. To make a mockNetworkMonitor, pass aMockImplinstance toNetworkMonitorconstructor.
Updated by Davide Pesavento over 8 years ago
Junxiao Shi wrote:
NetworkInterfacetype setters are made public.
I'd rather keep them private.
Updated by Junxiao Shi over 8 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 8 years ago
@Junxiao, are you still working on this?
Updated by Junxiao Shi over 8 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 8 years ago
- Blocked by Feature #3817: NetworkMonitor fine-grained signals for macOS added
Updated by Davide Pesavento over 8 years ago
- Blocked by deleted (Feature #3817: NetworkMonitor fine-grained signals for macOS)
Updated by Davide Pesavento over 8 years ago
Updated by Junxiao Shi over 8 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 8 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 8 years ago
- Status changed from In Progress to Code review
- % Done changed from 40 to 100
Updated by Alex Afanasyev over 8 years ago
- Status changed from Code review to Closed
Updated by Davide Pesavento over 8 years ago
- Subject changed from NetworkMonitor: mock impl to NetworkMonitor: stub implementation