| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" | 
| 6 #include "content/renderer/p2p/ipc_network_manager.h" | 6 #include "content/renderer/p2p/ipc_network_manager.h" | 
| 7 #include "content/renderer/p2p/network_list_manager.h" | 7 #include "content/renderer/p2p/network_list_manager.h" | 
| 8 #include "net/base/ip_address_number.h" | 8 #include "net/base/ip_address_number.h" | 
| 9 #include "net/base/net_util.h" | 9 #include "net/base/net_util.h" | 
| 10 #include "net/base/network_change_notifier.h" | 10 #include "net/base/network_change_notifier.h" | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 71   EXPECT_TRUE(net::ParseIPLiteralToNumber(kIPv6PublicAddrString2, &ip_number)); | 71   EXPECT_TRUE(net::ParseIPLiteralToNumber(kIPv6PublicAddrString2, &ip_number)); | 
| 72   list.push_back( | 72   list.push_back( | 
| 73       net::NetworkInterface("em1", | 73       net::NetworkInterface("em1", | 
| 74                             "em1", | 74                             "em1", | 
| 75                             0, | 75                             0, | 
| 76                             net::NetworkChangeNotifier::CONNECTION_UNKNOWN, | 76                             net::NetworkChangeNotifier::CONNECTION_UNKNOWN, | 
| 77                             ip_number, | 77                             ip_number, | 
| 78                             64, | 78                             64, | 
| 79                             net::IP_ADDRESS_ATTRIBUTE_NONE)); | 79                             net::IP_ADDRESS_ATTRIBUTE_NONE)); | 
| 80 | 80 | 
| 81   network_manager_->OnNetworkListChanged(list); | 81   network_manager_->OnNetworkListChanged(list, net::IPEndPoint(), | 
|  | 82                                          net::IPEndPoint()); | 
| 82   network_manager_->GetNetworks(&networks); | 83   network_manager_->GetNetworks(&networks); | 
| 83   EXPECT_EQ(1uL, networks.size()); | 84   EXPECT_EQ(1uL, networks.size()); | 
| 84   EXPECT_EQ(2uL, networks[0]->GetIPs().size()); | 85   EXPECT_EQ(2uL, networks[0]->GetIPs().size()); | 
| 85 | 86 | 
| 86   // Add another network with different prefix length, should result in | 87   // Add another network with different prefix length, should result in | 
| 87   // a different network. | 88   // a different network. | 
| 88   networks.clear(); | 89   networks.clear(); | 
| 89   list.push_back( | 90   list.push_back( | 
| 90       net::NetworkInterface("em1", | 91       net::NetworkInterface("em1", | 
| 91                             "em1", | 92                             "em1", | 
| 92                             0, | 93                             0, | 
| 93                             net::NetworkChangeNotifier::CONNECTION_UNKNOWN, | 94                             net::NetworkChangeNotifier::CONNECTION_UNKNOWN, | 
| 94                             ip_number, | 95                             ip_number, | 
| 95                             48, | 96                             48, | 
| 96                             net::IP_ADDRESS_ATTRIBUTE_NONE)); | 97                             net::IP_ADDRESS_ATTRIBUTE_NONE)); | 
| 97 | 98 | 
| 98   network_manager_->OnNetworkListChanged(list); | 99   network_manager_->OnNetworkListChanged(list, net::IPEndPoint(), | 
|  | 100                                          net::IPEndPoint()); | 
| 99 | 101 | 
| 100   network_manager_->GetNetworks(&networks); | 102   network_manager_->GetNetworks(&networks); | 
| 101 | 103 | 
| 102   // Verify we have 2 networks now. | 104   // Verify we have 2 networks now. | 
| 103   EXPECT_EQ(2uL, networks.size()); | 105   EXPECT_EQ(2uL, networks.size()); | 
| 104   // Verify the network with prefix length of 64 has 2 IP addresses. | 106   // Verify the network with prefix length of 64 has 2 IP addresses. | 
| 105   EXPECT_EQ(64, networks[1]->prefix_length()); | 107   EXPECT_EQ(64, networks[1]->prefix_length()); | 
| 106   EXPECT_EQ(2uL, networks[1]->GetIPs().size()); | 108   EXPECT_EQ(2uL, networks[1]->GetIPs().size()); | 
| 107   EXPECT_TRUE(rtc::IPFromString(kIPv6PublicAddrString1, &ip_address)); | 109   EXPECT_TRUE(rtc::IPFromString(kIPv6PublicAddrString1, &ip_address)); | 
| 108   EXPECT_EQ(networks[1]->GetIPs()[0], ip_address); | 110   EXPECT_EQ(networks[1]->GetIPs()[0], ip_address); | 
| 109   EXPECT_TRUE(rtc::IPFromString(kIPv6PublicAddrString2, &ip_address)); | 111   EXPECT_TRUE(rtc::IPFromString(kIPv6PublicAddrString2, &ip_address)); | 
| 110   EXPECT_EQ(networks[1]->GetIPs()[1], ip_address); | 112   EXPECT_EQ(networks[1]->GetIPs()[1], ip_address); | 
| 111   // Verify the network with prefix length of 48 has 2 IP addresses. | 113   // Verify the network with prefix length of 48 has 2 IP addresses. | 
| 112   EXPECT_EQ(48, networks[0]->prefix_length()); | 114   EXPECT_EQ(48, networks[0]->prefix_length()); | 
| 113   EXPECT_EQ(1uL, networks[0]->GetIPs().size()); | 115   EXPECT_EQ(1uL, networks[0]->GetIPs().size()); | 
| 114   EXPECT_TRUE(rtc::IPFromString(kIPv6PublicAddrString2, &ip_address)); | 116   EXPECT_TRUE(rtc::IPFromString(kIPv6PublicAddrString2, &ip_address)); | 
| 115   EXPECT_EQ(networks[0]->GetIPs()[0], ip_address); | 117   EXPECT_EQ(networks[0]->GetIPs()[0], ip_address); | 
| 116 } | 118 } | 
| 117 | 119 | 
| 118 }  // namespace content | 120 }  // namespace content | 
| OLD | NEW | 
|---|