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

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

Issue 1411253008: WebRTC should generate default private address even when adapter enumeration is disabled. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: after rebase on master Created 5 years, 1 month 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') | webrtc/p2p/base/port_unittest.cc » ('j') | 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
11 #include "webrtc/base/network.h" 11 #include "webrtc/base/network.h"
12 12
13 #include "webrtc/base/nethelpers.h"
13 #include "webrtc/base/networkmonitor.h" 14 #include "webrtc/base/networkmonitor.h"
14 #include <vector> 15 #include <vector>
15 #if defined(WEBRTC_POSIX) 16 #if defined(WEBRTC_POSIX)
16 #include <sys/types.h> 17 #include <sys/types.h>
17 #if !defined(WEBRTC_ANDROID) 18 #if !defined(WEBRTC_ANDROID)
18 #include <ifaddrs.h> 19 #include <ifaddrs.h>
19 #else 20 #else
20 #include "webrtc/base/ifaddrs-android.h" 21 #include "webrtc/base/ifaddrs-android.h"
21 #endif 22 #endif
22 #endif 23 #endif
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 bool include_ignored, 90 bool include_ignored,
90 NetworkManager::NetworkList* networks) { 91 NetworkManager::NetworkList* networks) {
91 network_manager.ConvertIfAddrs(interfaces, include_ignored, networks); 92 network_manager.ConvertIfAddrs(interfaces, include_ignored, networks);
92 } 93 }
93 #endif // defined(WEBRTC_POSIX) 94 #endif // defined(WEBRTC_POSIX)
94 95
95 protected: 96 protected:
96 bool callback_called_; 97 bool callback_called_;
97 }; 98 };
98 99
100 class TestBasicNetworkManager : public BasicNetworkManager {
101 public:
102 using BasicNetworkManager::QueryDefaultLocalAddress;
103 };
104
99 // Test that the Network ctor works properly. 105 // Test that the Network ctor works properly.
100 TEST_F(NetworkTest, TestNetworkConstruct) { 106 TEST_F(NetworkTest, TestNetworkConstruct) {
101 Network ipv4_network1("test_eth0", "Test Network Adapter 1", 107 Network ipv4_network1("test_eth0", "Test Network Adapter 1",
102 IPAddress(0x12345600U), 24); 108 IPAddress(0x12345600U), 24);
103 EXPECT_EQ("test_eth0", ipv4_network1.name()); 109 EXPECT_EQ("test_eth0", ipv4_network1.name());
104 EXPECT_EQ("Test Network Adapter 1", ipv4_network1.description()); 110 EXPECT_EQ("Test Network Adapter 1", ipv4_network1.description());
105 EXPECT_EQ(IPAddress(0x12345600U), ipv4_network1.prefix()); 111 EXPECT_EQ(IPAddress(0x12345600U), ipv4_network1.prefix());
106 EXPECT_EQ(24, ipv4_network1.prefix_length()); 112 EXPECT_EQ(24, ipv4_network1.prefix_length());
107 EXPECT_FALSE(ipv4_network1.ignored()); 113 EXPECT_FALSE(ipv4_network1.ignored());
108 } 114 }
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 network_monitor->OnNetworksChanged(); 841 network_monitor->OnNetworksChanged();
836 EXPECT_TRUE_WAIT(callback_called_, 1000); 842 EXPECT_TRUE_WAIT(callback_called_, 1000);
837 843
838 // Network manager is stopped; the network monitor is removed. 844 // Network manager is stopped; the network monitor is removed.
839 manager.StopUpdating(); 845 manager.StopUpdating();
840 EXPECT_TRUE(GetNetworkMonitor(manager) == nullptr); 846 EXPECT_TRUE(GetNetworkMonitor(manager) == nullptr);
841 847
842 NetworkMonitorFactory::ReleaseFactory(factory); 848 NetworkMonitorFactory::ReleaseFactory(factory);
843 } 849 }
844 850
851 TEST_F(NetworkTest, DefaultPrivateAddress) {
852 TestBasicNetworkManager manager;
853 manager.StartUpdating();
854 std::vector<Network*> networks;
855 manager.GetNetworks(&networks);
856 for (auto& network : networks) {
857 if (network->GetBestIP().family() == AF_INET) {
858 EXPECT_TRUE(manager.QueryDefaultLocalAddress(AF_INET) != IPAddress());
859 } else if (network->GetBestIP().family() == AF_INET6) {
860 EXPECT_TRUE(manager.QueryDefaultLocalAddress(AF_INET6) != IPAddress());
861 }
862 }
863 manager.StopUpdating();
864 }
865
845 } // namespace rtc 866 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/network.cc ('k') | webrtc/p2p/base/port_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698