| 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" | |
| 6 #include "content/renderer/p2p/ipc_network_manager.h" | 5 #include "content/renderer/p2p/ipc_network_manager.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 7 #include "content/renderer/p2p/network_list_manager.h" | 9 #include "content/renderer/p2p/network_list_manager.h" |
| 8 #include "net/base/ip_address.h" | 10 #include "net/base/ip_address.h" |
| 9 #include "net/base/network_change_notifier.h" | 11 #include "net/base/network_change_notifier.h" |
| 10 #include "net/base/network_interfaces.h" | 12 #include "net/base/network_interfaces.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 14 |
| 13 namespace content { | 15 namespace content { |
| 14 | 16 |
| 15 namespace { | 17 namespace { |
| 16 | 18 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 34 "2401:fa00:4:1000:be30:5b30:50e5:c4"; | 36 "2401:fa00:4:1000:be30:5b30:50e5:c4"; |
| 35 static const char kIPv4MappedAddrString[] = "::ffff:38.32.0.0"; | 37 static const char kIPv4MappedAddrString[] = "::ffff:38.32.0.0"; |
| 36 | 38 |
| 37 class IpcNetworkManagerTest : public testing::Test { | 39 class IpcNetworkManagerTest : public testing::Test { |
| 38 public: | 40 public: |
| 39 IpcNetworkManagerTest() | 41 IpcNetworkManagerTest() |
| 40 : network_list_manager_(new MockP2PSocketDispatcher()), | 42 : network_list_manager_(new MockP2PSocketDispatcher()), |
| 41 network_manager_(new IpcNetworkManager(network_list_manager_.get())) {} | 43 network_manager_(new IpcNetworkManager(network_list_manager_.get())) {} |
| 42 | 44 |
| 43 protected: | 45 protected: |
| 44 scoped_ptr<MockP2PSocketDispatcher> network_list_manager_; | 46 std::unique_ptr<MockP2PSocketDispatcher> network_list_manager_; |
| 45 scoped_ptr<IpcNetworkManager> network_manager_; | 47 std::unique_ptr<IpcNetworkManager> network_manager_; |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 // Test overall logic of IpcNetworkManager on OnNetworkListChanged | 50 // Test overall logic of IpcNetworkManager on OnNetworkListChanged |
| 49 // that it should group addresses with the same network key under | 51 // that it should group addresses with the same network key under |
| 50 // single Network class. This also tests the logic inside | 52 // single Network class. This also tests the logic inside |
| 51 // IpcNetworkManager in addition to MergeNetworkList. | 53 // IpcNetworkManager in addition to MergeNetworkList. |
| 52 // TODO(guoweis): disable this test case for now until fix for webrtc | 54 // TODO(guoweis): disable this test case for now until fix for webrtc |
| 53 // issue 19249005 integrated into chromium | 55 // issue 19249005 integrated into chromium |
| 54 TEST_F(IpcNetworkManagerTest, TestMergeNetworkList) { | 56 TEST_F(IpcNetworkManagerTest, TestMergeNetworkList) { |
| 55 net::NetworkInterfaceList list; | 57 net::NetworkInterfaceList list; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 EXPECT_TRUE(rtc::IPFromString(kIPv6PublicAddrString2, &ip_address)); | 102 EXPECT_TRUE(rtc::IPFromString(kIPv6PublicAddrString2, &ip_address)); |
| 101 EXPECT_EQ(networks[1]->GetIPs()[1], ip_address); | 103 EXPECT_EQ(networks[1]->GetIPs()[1], ip_address); |
| 102 // Verify the network with prefix length of 48 has 2 IP addresses. | 104 // Verify the network with prefix length of 48 has 2 IP addresses. |
| 103 EXPECT_EQ(48, networks[0]->prefix_length()); | 105 EXPECT_EQ(48, networks[0]->prefix_length()); |
| 104 EXPECT_EQ(1uL, networks[0]->GetIPs().size()); | 106 EXPECT_EQ(1uL, networks[0]->GetIPs().size()); |
| 105 EXPECT_TRUE(rtc::IPFromString(kIPv6PublicAddrString2, &ip_address)); | 107 EXPECT_TRUE(rtc::IPFromString(kIPv6PublicAddrString2, &ip_address)); |
| 106 EXPECT_EQ(networks[0]->GetIPs()[0], ip_address); | 108 EXPECT_EQ(networks[0]->GetIPs()[0], ip_address); |
| 107 } | 109 } |
| 108 | 110 |
| 109 } // namespace content | 111 } // namespace content |
| OLD | NEW |