Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Unified Diff: webrtc/base/physicalsocketserver_unittest.cc

Issue 2701253002: Don't attempt to use "network binder" for sockets bound to "ANY" IP. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/physicalsocketserver.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/physicalsocketserver_unittest.cc
diff --git a/webrtc/base/physicalsocketserver_unittest.cc b/webrtc/base/physicalsocketserver_unittest.cc
index d0083bdcfcfc5771b8c1d3268febdf1a3434ff6b..63d2f0d92c80a14fad1965ef77be2de851094ce6 100644
--- a/webrtc/base/physicalsocketserver_unittest.cc
+++ b/webrtc/base/physicalsocketserver_unittest.cc
@@ -89,13 +89,17 @@ class FakePhysicalSocketServer : public PhysicalSocketServer {
class FakeNetworkBinder : public NetworkBinderInterface {
public:
NetworkBindingResult BindSocketToNetwork(int, const IPAddress&) override {
+ ++num_binds_;
return result_;
}
void set_result(NetworkBindingResult result) { result_ = result; }
+ int num_binds() { return num_binds_; }
+
private:
NetworkBindingResult result_ = NetworkBindingResult::SUCCESS;
+ int num_binds_ = 0;
};
class PhysicalSocketTest : public SocketTest {
@@ -441,6 +445,18 @@ TEST_F(PhysicalSocketTest,
server_->set_network_binder(nullptr);
}
+// Network binder shouldn't be used if the socket is bound to the "any" IP.
+TEST_F(PhysicalSocketTest,
+ NetworkBinderIsNotUsedForAnyIp) {
+ FakeNetworkBinder fake_network_binder;
+ server_->set_network_binder(&fake_network_binder);
+ std::unique_ptr<AsyncSocket> socket(
+ server_->CreateAsyncSocket(AF_INET, SOCK_DGRAM));
+ EXPECT_EQ(0, socket->Bind(SocketAddress("0.0.0.0", 0)));
+ EXPECT_EQ(0, fake_network_binder.num_binds());
+ server_->set_network_binder(nullptr);
+}
+
// For a loopback interface, failures to bind to the interface should be
// tolerated.
TEST_F(PhysicalSocketTest,
« no previous file with comments | « webrtc/base/physicalsocketserver.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698