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

Side by Side Diff: webrtc/base/network_unittest.cc

Issue 1592763003: fix bug 5430 (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « webrtc/base/network.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 EXPECT_TRUE_WAIT(callback_called_, 1000); 933 EXPECT_TRUE_WAIT(callback_called_, 1000);
934 934
935 // Network manager is stopped; the network monitor is removed. 935 // Network manager is stopped; the network monitor is removed.
936 manager.StopUpdating(); 936 manager.StopUpdating();
937 EXPECT_TRUE(GetNetworkMonitor(manager) == nullptr); 937 EXPECT_TRUE(GetNetworkMonitor(manager) == nullptr);
938 938
939 NetworkMonitorFactory::ReleaseFactory(factory); 939 NetworkMonitorFactory::ReleaseFactory(factory);
940 } 940 }
941 941
942 TEST_F(NetworkTest, DefaultLocalAddress) { 942 TEST_F(NetworkTest, DefaultLocalAddress) {
943 IPAddress ip;
943 TestBasicNetworkManager manager; 944 TestBasicNetworkManager manager;
945 manager.SignalNetworksChanged.connect(static_cast<NetworkTest*>(this),
946 &NetworkTest::OnNetworksChanged);
947 FakeNetworkMonitorFactory* factory = new FakeNetworkMonitorFactory();
948 NetworkMonitorFactory::SetFactory(factory);
944 manager.StartUpdating(); 949 manager.StartUpdating();
945 IPAddress ip; 950 EXPECT_TRUE_WAIT(callback_called_, 1000);
946
947 // GetDefaultLocalAddress should return false when not set.
948 EXPECT_FALSE(manager.GetDefaultLocalAddress(AF_INET, &ip));
949 EXPECT_FALSE(manager.GetDefaultLocalAddress(AF_INET6, &ip));
950 951
951 // Make sure we can query default local address when an address for such 952 // Make sure we can query default local address when an address for such
952 // address family exists. 953 // address family exists.
953 std::vector<Network*> networks; 954 std::vector<Network*> networks;
pthatcher1 2016/01/15 19:30:52 Should we EXPECT_TRUE(!networks.empty()) ?
954 manager.GetNetworks(&networks); 955 manager.GetNetworks(&networks);
955 for (auto& network : networks) { 956 for (auto& network : networks) {
956 if (network->GetBestIP().family() == AF_INET) { 957 if (network->GetBestIP().family() == AF_INET) {
957 EXPECT_TRUE(manager.QueryDefaultLocalAddress(AF_INET) != IPAddress()); 958 EXPECT_TRUE(manager.QueryDefaultLocalAddress(AF_INET) != IPAddress());
958 } else if (network->GetBestIP().family() == AF_INET6) { 959 } else if (network->GetBestIP().family() == AF_INET6) {
959 EXPECT_TRUE(manager.QueryDefaultLocalAddress(AF_INET6) != IPAddress()); 960 EXPECT_TRUE(manager.QueryDefaultLocalAddress(AF_INET6) != IPAddress());
960 } 961 }
961 } 962 }
962 963
963 // GetDefaultLocalAddress should return the valid default address after set. 964 // GetDefaultLocalAddress should return the valid default address after set.
964 manager.set_default_local_addresses(GetLoopbackIP(AF_INET), 965 manager.set_default_local_addresses(GetLoopbackIP(AF_INET),
965 GetLoopbackIP(AF_INET6)); 966 GetLoopbackIP(AF_INET6));
966 EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET, &ip)); 967 EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET, &ip));
967 EXPECT_EQ(ip, GetLoopbackIP(AF_INET)); 968 EXPECT_EQ(ip, GetLoopbackIP(AF_INET));
968 EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET6, &ip)); 969 EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET6, &ip));
969 EXPECT_EQ(ip, GetLoopbackIP(AF_INET6)); 970 EXPECT_EQ(ip, GetLoopbackIP(AF_INET6));
970 manager.StopUpdating(); 971 manager.StopUpdating();
971 } 972 }
972 973
973 } // namespace rtc 974 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/network.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698