OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 // The MockHostResolver asserts that it's used on the same thread on which | 49 // The MockHostResolver asserts that it's used on the same thread on which |
50 // it's created, which is actually a stronger rule than its real counterpart. | 50 // it's created, which is actually a stronger rule than its real counterpart. |
51 // But that's fine; it's good practice. | 51 // But that's fine; it's good practice. |
52 scoped_refptr<extensions::MockHostResolverCreator> resolver_creator_; | 52 scoped_refptr<extensions::MockHostResolverCreator> resolver_creator_; |
53 }; | 53 }; |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPExtension) { | 57 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPExtension) { |
58 scoped_ptr<net::SpawnedTestServer> test_server( | 58 std::unique_ptr<net::SpawnedTestServer> test_server( |
59 new net::SpawnedTestServer( | 59 new net::SpawnedTestServer( |
60 net::SpawnedTestServer::TYPE_UDP_ECHO, | 60 net::SpawnedTestServer::TYPE_UDP_ECHO, |
61 net::SpawnedTestServer::kLocalhost, | 61 net::SpawnedTestServer::kLocalhost, |
62 base::FilePath(FILE_PATH_LITERAL("net/data")))); | 62 base::FilePath(FILE_PATH_LITERAL("net/data")))); |
63 EXPECT_TRUE(test_server->Start()); | 63 EXPECT_TRUE(test_server->Start()); |
64 | 64 |
65 net::HostPortPair host_port_pair = test_server->host_port_pair(); | 65 net::HostPortPair host_port_pair = test_server->host_port_pair(); |
66 int port = host_port_pair.port(); | 66 int port = host_port_pair.port(); |
67 ASSERT_GT(port, 0); | 67 ASSERT_GT(port, 0); |
68 | 68 |
69 // Test that sendTo() is properly resolving hostnames. | 69 // Test that sendTo() is properly resolving hostnames. |
70 host_port_pair.set_host("LOCALhost"); | 70 host_port_pair.set_host("LOCALhost"); |
71 | 71 |
72 ResultCatcher catcher; | 72 ResultCatcher catcher; |
73 catcher.RestrictToBrowserContext(browser()->profile()); | 73 catcher.RestrictToBrowserContext(browser()->profile()); |
74 | 74 |
75 ExtensionTestMessageListener listener("info_please", true); | 75 ExtensionTestMessageListener listener("info_please", true); |
76 | 76 |
77 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); | 77 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); |
78 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 78 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
79 listener.Reply( | 79 listener.Reply( |
80 base::StringPrintf("udp:%s:%d", host_port_pair.host().c_str(), port)); | 80 base::StringPrintf("udp:%s:%d", host_port_pair.host().c_str(), port)); |
81 | 81 |
82 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 82 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
83 } | 83 } |
84 | 84 |
85 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPExtension) { | 85 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPExtension) { |
86 scoped_ptr<net::SpawnedTestServer> test_server( | 86 std::unique_ptr<net::SpawnedTestServer> test_server( |
87 new net::SpawnedTestServer( | 87 new net::SpawnedTestServer( |
88 net::SpawnedTestServer::TYPE_TCP_ECHO, | 88 net::SpawnedTestServer::TYPE_TCP_ECHO, |
89 net::SpawnedTestServer::kLocalhost, | 89 net::SpawnedTestServer::kLocalhost, |
90 base::FilePath(FILE_PATH_LITERAL("net/data")))); | 90 base::FilePath(FILE_PATH_LITERAL("net/data")))); |
91 EXPECT_TRUE(test_server->Start()); | 91 EXPECT_TRUE(test_server->Start()); |
92 | 92 |
93 net::HostPortPair host_port_pair = test_server->host_port_pair(); | 93 net::HostPortPair host_port_pair = test_server->host_port_pair(); |
94 int port = host_port_pair.port(); | 94 int port = host_port_pair.port(); |
95 ASSERT_GT(port, 0); | 95 ASSERT_GT(port, 0); |
96 | 96 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 ResultCatcher catcher; | 140 ResultCatcher catcher; |
141 catcher.RestrictToBrowserContext(browser()->profile()); | 141 catcher.RestrictToBrowserContext(browser()->profile()); |
142 ExtensionTestMessageListener listener("info_please", true); | 142 ExtensionTestMessageListener listener("info_please", true); |
143 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); | 143 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); |
144 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 144 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
145 listener.Reply( | 145 listener.Reply( |
146 base::StringPrintf("multicast:%s:%d", kHostname.c_str(), kPort)); | 146 base::StringPrintf("multicast:%s:%d", kHostname.c_str(), kPort)); |
147 | 147 |
148 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 148 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
149 } | 149 } |
OLD | NEW |