Commit 3d03cc70 authored by Wez's avatar Wez Committed by Commit Bot

Fix NetworkChangeNotifierFuchsiaTest for Netstack API changes.

TBR=rch

Change-Id: Ic149856ad452e82c1eafc69057b01865ac98335e
Reviewed-on: https://chromium-review.googlesource.com/1162741Reviewed-by: default avatarWez <wez@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580898}
parent 68f6bc09
...@@ -96,7 +96,11 @@ fuchsia::netstack::NetInterface CreateNetInterface( ...@@ -96,7 +96,11 @@ fuchsia::netstack::NetInterface CreateNetInterface(
// which aren't handled well by GMock. // which aren't handled well by GMock.
class FakeNetstack : public fuchsia::netstack::Netstack { class FakeNetstack : public fuchsia::netstack::Netstack {
public: public:
FakeNetstack() = default; explicit FakeNetstack(
fidl::InterfaceRequest<fuchsia::netstack::Netstack> netstack_request)
: binding_(this) {
CHECK_EQ(ZX_OK, binding_.Bind(std::move(netstack_request)));
}
~FakeNetstack() override = default; ~FakeNetstack() override = default;
// Adds |interface| to the interface query response list. // Adds |interface| to the interface query response list.
...@@ -108,20 +112,20 @@ class FakeNetstack : public fuchsia::netstack::Netstack { ...@@ -108,20 +112,20 @@ class FakeNetstack : public fuchsia::netstack::Netstack {
route_table_->push_back(std::move(interface)); route_table_->push_back(std::move(interface));
} }
// Sends the accumulated list of |interfaces_| to |listener_|. // Sends the accumulated |interfaces_| to the OnInterfacesChanged event.
void NotifyInterfaces() { void NotifyInterfaces() {
if (listener_) { binding_.events().OnInterfacesChanged(std::move(interfaces_));
listener_->OnInterfacesChanged(std::move(interfaces_)); interfaces_ = fidl::VectorPtr<fuchsia::netstack::NetInterface>::New(0);
interfaces_ = fidl::VectorPtr<fuchsia::netstack::NetInterface>::New(0);
}
} }
fidl::Binding<fuchsia::netstack::Netstack>& binding() { return binding_; }
private: private:
// fuchsia::netstack::Netstack implementation. // fuchsia::netstack::Netstack implementation.
void RegisterListener( void RegisterListener(
::fidl::InterfaceHandle<fuchsia::netstack::NotificationListener> listener) ::fidl::InterfaceHandle<fuchsia::netstack::NotificationListener> listener)
override { override {
listener_ = listener.BindSync(); NOTREACHED();
} }
void GetInterfaces(GetInterfacesCallback callback) override { void GetInterfaces(GetInterfacesCallback callback) override {
...@@ -164,12 +168,13 @@ class FakeNetstack : public fuchsia::netstack::Netstack { ...@@ -164,12 +168,13 @@ class FakeNetstack : public fuchsia::netstack::Netstack {
SetFilterStatusCallback callback) override {} SetFilterStatusCallback callback) override {}
void GetFilterStatus(GetFilterStatusCallback callback) override {} void GetFilterStatus(GetFilterStatusCallback callback) override {}
fuchsia::netstack::NotificationListenerSyncPtr listener_;
::fidl::VectorPtr<fuchsia::netstack::NetInterface> interfaces_ = ::fidl::VectorPtr<fuchsia::netstack::NetInterface> interfaces_ =
fidl::VectorPtr<fuchsia::netstack::NetInterface>::New(0); fidl::VectorPtr<fuchsia::netstack::NetInterface>::New(0);
::fidl::VectorPtr<fuchsia::netstack::RouteTableEntry> route_table_ = ::fidl::VectorPtr<fuchsia::netstack::RouteTableEntry> route_table_ =
fidl::VectorPtr<fuchsia::netstack::RouteTableEntry>::New(0); fidl::VectorPtr<fuchsia::netstack::RouteTableEntry>::New(0);
fidl::Binding<fuchsia::netstack::Netstack> binding_;
DISALLOW_COPY_AND_ASSIGN(FakeNetstack); DISALLOW_COPY_AND_ASSIGN(FakeNetstack);
}; };
...@@ -183,9 +188,7 @@ class MockNetworkChangeObserver ...@@ -183,9 +188,7 @@ class MockNetworkChangeObserver
class NetworkChangeNotifierFuchsiaTest : public testing::Test { class NetworkChangeNotifierFuchsiaTest : public testing::Test {
public: public:
NetworkChangeNotifierFuchsiaTest() : netstack_binding_(&netstack_) { NetworkChangeNotifierFuchsiaTest() : netstack_(netstack_ptr_.NewRequest()) {}
CHECK_EQ(ZX_OK, netstack_binding_.Bind(netstack_ptr_.NewRequest()));
}
~NetworkChangeNotifierFuchsiaTest() override {} ~NetworkChangeNotifierFuchsiaTest() override {}
...@@ -205,9 +208,8 @@ class NetworkChangeNotifierFuchsiaTest : public testing::Test { ...@@ -205,9 +208,8 @@ class NetworkChangeNotifierFuchsiaTest : public testing::Test {
protected: protected:
base::MessageLoopForIO message_loop_; base::MessageLoopForIO message_loop_;
testing::StrictMock<MockNetworkChangeObserver> observer_; testing::StrictMock<MockNetworkChangeObserver> observer_;
FakeNetstack netstack_;
fuchsia::netstack::NetstackPtr netstack_ptr_; fuchsia::netstack::NetstackPtr netstack_ptr_;
fidl::Binding<fuchsia::netstack::Netstack> netstack_binding_; FakeNetstack netstack_;
// Allows us to allocate our own NetworkChangeNotifier for unit testing. // Allows us to allocate our own NetworkChangeNotifier for unit testing.
NetworkChangeNotifier::DisableForTest disable_for_test_; NetworkChangeNotifier::DisableForTest disable_for_test_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment