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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "extensions/browser/api/dns/host_resolver_wrapper.h" | 9 #include "extensions/browser/api/dns/host_resolver_wrapper.h" |
10 #include "extensions/browser/api/dns/mock_host_resolver_creator.h" | 10 #include "extensions/browser/api/dns/mock_host_resolver_creator.h" |
11 #include "extensions/browser/api/sockets_tcp/sockets_tcp_api.h" | 11 #include "extensions/browser/api/sockets_tcp/sockets_tcp_api.h" |
12 #include "extensions/browser/api_test_utils.h" | 12 #include "extensions/browser/api_test_utils.h" |
13 #include "extensions/common/extension.h" | 13 #include "extensions/common/extension.h" |
14 #include "extensions/common/test_util.h" | 14 #include "extensions/common/test_util.h" |
15 #include "extensions/shell/test/shell_apitest.h" | 15 #include "extensions/shell/test/shell_apitest.h" |
16 #include "extensions/shell/test/shell_test.h" | 16 #include "extensions/shell/test/shell_test.h" |
17 #include "extensions/test/extension_test_message_listener.h" | 17 #include "extensions/test/extension_test_message_listener.h" |
18 #include "extensions/test/result_catcher.h" | 18 #include "extensions/test/result_catcher.h" |
19 #include "net/dns/mock_host_resolver.h" | 19 #include "net/dns/mock_host_resolver.h" |
20 #include "net/test/spawned_test_server/spawned_test_server.h" | 20 #include "net/test/spawned_test_server/spawned_test_server.h" |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 | 23 |
24 const std::string kHostname = "127.0.0.1"; | 24 const std::string kHostname = "127.0.0.1"; |
25 | 25 |
26 class SocketsTcpApiTest : public ShellApiTest { | 26 class SocketsTcpApiTest : public ShellApiTest { |
27 public: | 27 public: |
28 SocketsTcpApiTest() | 28 SocketsTcpApiTest() |
29 : resolver_event_(true, false), | 29 : resolver_event_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 30 base::WaitableEvent::InitialState::NOT_SIGNALED), |
30 resolver_creator_(new MockHostResolverCreator()) {} | 31 resolver_creator_(new MockHostResolverCreator()) {} |
31 | 32 |
32 void SetUpOnMainThread() override { | 33 void SetUpOnMainThread() override { |
33 ShellApiTest::SetUpOnMainThread(); | 34 ShellApiTest::SetUpOnMainThread(); |
34 | 35 |
35 HostResolverWrapper::GetInstance()->SetHostResolverForTesting( | 36 HostResolverWrapper::GetInstance()->SetHostResolverForTesting( |
36 resolver_creator_->CreateMockHostResolver()); | 37 resolver_creator_->CreateMockHostResolver()); |
37 } | 38 } |
38 | 39 |
39 void TearDownOnMainThread() override { | 40 void TearDownOnMainThread() override { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 119 |
119 ASSERT_TRUE(LoadApp("sockets_tcp/api")); | 120 ASSERT_TRUE(LoadApp("sockets_tcp/api")); |
120 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 121 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
121 listener.Reply(base::StringPrintf( | 122 listener.Reply(base::StringPrintf( |
122 "https:%s:%d", https_host_port_pair.host().c_str(), https_port)); | 123 "https:%s:%d", https_host_port_pair.host().c_str(), https_port)); |
123 | 124 |
124 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 125 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
125 } | 126 } |
126 | 127 |
127 } // namespace extensions | 128 } // namespace extensions |
OLD | NEW |