OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "chrome/browser/extensions/api/dns/host_resolver_wrapper.h" | 8 #include "chrome/browser/extensions/api/dns/host_resolver_wrapper.h" |
9 #include "chrome/browser/extensions/api/dns/mock_host_resolver_creator.h" | 9 #include "chrome/browser/extensions/api/dns/mock_host_resolver_creator.h" |
10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 EXPECT_TRUE(value->GetInteger("socketId", &socketId)); | 82 EXPECT_TRUE(value->GetInteger("socketId", &socketId)); |
83 ASSERT_TRUE(socketId > 0); | 83 ASSERT_TRUE(socketId > 0); |
84 } | 84 } |
85 | 85 |
86 IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketTcpExtension) { | 86 IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketTcpExtension) { |
87 scoped_ptr<net::SpawnedTestServer> test_server( | 87 scoped_ptr<net::SpawnedTestServer> test_server( |
88 new net::SpawnedTestServer( | 88 new net::SpawnedTestServer( |
89 net::SpawnedTestServer::TYPE_TCP_ECHO, | 89 net::SpawnedTestServer::TYPE_TCP_ECHO, |
90 net::SpawnedTestServer::kLocalhost, | 90 net::SpawnedTestServer::kLocalhost, |
91 base::FilePath(FILE_PATH_LITERAL("net/data")))); | 91 base::FilePath(FILE_PATH_LITERAL("net/data")))); |
92 EXPECT_TRUE(test_server->Start()); | 92 |
93 // Start them in parallel. | |
94 EXPECT_TRUE(test_server->StartInBackground()); | |
95 EXPECT_TRUE(test_server->BlockUntilStarted()); | |
93 | 96 |
94 net::HostPortPair host_port_pair = test_server->host_port_pair(); | 97 net::HostPortPair host_port_pair = test_server->host_port_pair(); |
95 int port = host_port_pair.port(); | 98 int port = host_port_pair.port(); |
96 ASSERT_TRUE(port > 0); | 99 ASSERT_TRUE(port > 0); |
97 | 100 |
98 // Test that connect() is properly resolving hostnames. | 101 // Test that connect() is properly resolving hostnames. |
99 host_port_pair.set_host("lOcAlHoSt"); | 102 host_port_pair.set_host("lOcAlHoSt"); |
100 | 103 |
101 ResultCatcher catcher; | 104 ResultCatcher catcher; |
102 catcher.RestrictToProfile(browser()->profile()); | 105 catcher.RestrictToProfile(browser()->profile()); |
103 | 106 |
104 ExtensionTestMessageListener listener("info_please", true); | 107 ExtensionTestMessageListener listener("info_please", true); |
105 | 108 |
106 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_tcp/api"))); | 109 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_tcp/api"))); |
107 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 110 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
108 listener.Reply( | 111 listener.Reply( |
109 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port)); | 112 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port)); |
110 | 113 |
111 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 114 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
112 } | 115 } |
116 | |
117 IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketTcpExtensionTLS) { | |
118 scoped_ptr<net::SpawnedTestServer> test_https_server( | |
119 new net::SpawnedTestServer( | |
120 net::SpawnedTestServer::TYPE_HTTPS, | |
121 net::BaseTestServer::SSLOptions(), | |
122 base::FilePath(FILE_PATH_LITERAL("net/data")))); | |
123 // Start the servers in parallel. | |
Ryan Sleevi
2014/03/26 19:57:40
You say "servers", except you're only starting a s
lally
2014/03/28 16:22:51
The prior version of this test loaded up both stoc
| |
124 EXPECT_TRUE(test_https_server->StartInBackground()); | |
125 EXPECT_TRUE(test_https_server->BlockUntilStarted()); | |
126 | |
127 net::HostPortPair https_host_port_pair = test_https_server->host_port_pair(); | |
128 int https_port = https_host_port_pair.port(); | |
129 ASSERT_TRUE(https_port > 0); | |
130 | |
131 ResultCatcher catcher; | |
132 catcher.RestrictToProfile(browser()->profile()); | |
133 | |
134 ExtensionTestMessageListener listener("info_please", true); | |
135 | |
136 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_tcp/api"))); | |
137 EXPECT_TRUE(listener.WaitUntilSatisfied()); | |
138 listener.Reply(base::StringPrintf("https:%s:%d", | |
139 https_host_port_pair.host().c_str(), | |
140 https_port)); | |
141 | |
142 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | |
143 } | |
OLD | NEW |