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/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/extension_test_message_listener.h" | 10 #include "chrome/browser/extensions/extension_test_message_listener.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/extensions/application_launch.h" | 12 #include "chrome/browser/ui/extensions/application_launch.h" |
13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
14 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
15 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
16 #include "extensions/browser/api/dns/host_resolver_wrapper.h" | 16 #include "extensions/browser/api/dns/host_resolver_wrapper.h" |
17 #include "extensions/browser/api/dns/mock_host_resolver_creator.h" | 17 #include "extensions/browser/api/dns/mock_host_resolver_creator.h" |
18 #include "extensions/browser/api/sockets_tcp/sockets_tcp_api.h" | 18 #include "extensions/browser/api/sockets_tcp/sockets_tcp_api.h" |
| 19 #include "extensions/test/result_catcher.h" |
19 #include "net/dns/mock_host_resolver.h" | 20 #include "net/dns/mock_host_resolver.h" |
20 #include "net/test/spawned_test_server/spawned_test_server.h" | 21 #include "net/test/spawned_test_server/spawned_test_server.h" |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 // TODO(jschuh): Hanging plugin tests. crbug.com/244653 | 25 // TODO(jschuh): Hanging plugin tests. crbug.com/244653 |
25 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) | 26 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) |
26 #define MAYBE(x) DISABLED_##x | 27 #define MAYBE(x) DISABLED_##x |
27 #else | 28 #else |
28 #define MAYBE(x) x | 29 #define MAYBE(x) x |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 base::FilePath(FILE_PATH_LITERAL("net/data")))); | 68 base::FilePath(FILE_PATH_LITERAL("net/data")))); |
68 EXPECT_TRUE(test_server->Start()); | 69 EXPECT_TRUE(test_server->Start()); |
69 | 70 |
70 net::HostPortPair host_port_pair = test_server->host_port_pair(); | 71 net::HostPortPair host_port_pair = test_server->host_port_pair(); |
71 int port = host_port_pair.port(); | 72 int port = host_port_pair.port(); |
72 ASSERT_TRUE(port > 0); | 73 ASSERT_TRUE(port > 0); |
73 | 74 |
74 // Test that connect() is properly resolving hostnames. | 75 // Test that connect() is properly resolving hostnames. |
75 host_port_pair.set_host("lOcAlHoSt"); | 76 host_port_pair.set_host("lOcAlHoSt"); |
76 | 77 |
77 ResultCatcher catcher; | 78 extensions::ResultCatcher catcher; |
78 catcher.RestrictToProfile(browser()->profile()); | 79 catcher.RestrictToBrowserContext(browser()->profile()); |
79 | 80 |
80 ExtensionTestMessageListener listener("info_please", true); | 81 ExtensionTestMessageListener listener("info_please", true); |
81 | 82 |
82 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_tcp/api"))); | 83 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_tcp/api"))); |
83 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 84 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
84 listener.Reply( | 85 listener.Reply( |
85 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port)); | 86 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port)); |
86 | 87 |
87 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 88 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
88 } | 89 } |
89 | 90 |
90 IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketTcpExtensionTLS) { | 91 IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketTcpExtensionTLS) { |
91 scoped_ptr<net::SpawnedTestServer> test_https_server( | 92 scoped_ptr<net::SpawnedTestServer> test_https_server( |
92 new net::SpawnedTestServer( | 93 new net::SpawnedTestServer( |
93 net::SpawnedTestServer::TYPE_HTTPS, | 94 net::SpawnedTestServer::TYPE_HTTPS, |
94 net::BaseTestServer::SSLOptions(), | 95 net::BaseTestServer::SSLOptions(), |
95 base::FilePath(FILE_PATH_LITERAL("net/data")))); | 96 base::FilePath(FILE_PATH_LITERAL("net/data")))); |
96 EXPECT_TRUE(test_https_server->Start()); | 97 EXPECT_TRUE(test_https_server->Start()); |
97 | 98 |
98 net::HostPortPair https_host_port_pair = test_https_server->host_port_pair(); | 99 net::HostPortPair https_host_port_pair = test_https_server->host_port_pair(); |
99 int https_port = https_host_port_pair.port(); | 100 int https_port = https_host_port_pair.port(); |
100 ASSERT_GT(https_port, 0); | 101 ASSERT_GT(https_port, 0); |
101 | 102 |
102 ResultCatcher catcher; | 103 extensions::ResultCatcher catcher; |
103 catcher.RestrictToProfile(browser()->profile()); | 104 catcher.RestrictToBrowserContext(browser()->profile()); |
104 | 105 |
105 ExtensionTestMessageListener listener("info_please", true); | 106 ExtensionTestMessageListener listener("info_please", true); |
106 | 107 |
107 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_tcp/api"))); | 108 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_tcp/api"))); |
108 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 109 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
109 listener.Reply(base::StringPrintf( | 110 listener.Reply(base::StringPrintf( |
110 "https:%s:%d", https_host_port_pair.host().c_str(), https_port)); | 111 "https:%s:%d", https_host_port_pair.host().c_str(), https_port)); |
111 | 112 |
112 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 113 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
113 } | 114 } |
OLD | NEW |