NetworkMonitor: stub implementation
listNetworkInterfaces return value to be mocked in a test case.
Updated by Junxiao Shi over 4 years ago
- Status changed from New to In Progress
- Assignee set to Junxiao Shi
- Pure virtual base class
NetworkMonitor::ImplBaseis introduced. It is a friend of
NetworkMonitor, and offers protected methods to modify
NetworkMonitordata structures or emit signals on it.
ImplBasetype is public API.
Implclass inherit from
ImplBase. It is not a friend of
NetworkMonitor, but accesses
NetworkMonitordata structures and signals via
Impltype is not public API.
unique_ptr<NetworkMonitor::ImplBase>, which defaults to
nullptrcauses the constructor to internally make an
NetworkInterfacetype setters are made public.
NetworkMonitorAPIs that return
NetworkInterfaceare changed to return
const NetworkInterfaceinstead so that setters cannot be invoked by outsider.
MockImplclass inherits from
ImplBaseand exposes its protected methods as public. To make a mock
NetworkMonitor, pass a
Updated by Junxiao Shi about 4 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.