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/api/sockets_tcp/sockets_tcp_api.h" | |
11 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
12 #include "chrome/browser/extensions/extension_function_test_utils.h" | 11 #include "chrome/browser/extensions/extension_function_test_utils.h" |
13 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
14 #include "chrome/browser/extensions/extension_test_message_listener.h" | 13 #include "chrome/browser/extensions/extension_test_message_listener.h" |
15 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/extensions/application_launch.h" | 15 #include "chrome/browser/ui/extensions/application_launch.h" |
17 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
19 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
| 19 #include "extensions/browser/api/sockets_tcp/sockets_tcp_api.h" |
20 #include "net/dns/mock_host_resolver.h" | 20 #include "net/dns/mock_host_resolver.h" |
21 #include "net/test/spawned_test_server/spawned_test_server.h" | 21 #include "net/test/spawned_test_server/spawned_test_server.h" |
22 | 22 |
23 using extensions::Extension; | 23 using extensions::Extension; |
24 | 24 |
25 namespace utils = extension_function_test_utils; | 25 namespace utils = extension_function_test_utils; |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 // TODO(jschuh): Hanging plugin tests. crbug.com/244653 | 29 // TODO(jschuh): Hanging plugin tests. crbug.com/244653 |
(...skipping 28 matching lines...) Expand all Loading... |
58 | 58 |
59 // The MockHostResolver asserts that it's used on the same thread on which | 59 // The MockHostResolver asserts that it's used on the same thread on which |
60 // it's created, which is actually a stronger rule than its real counterpart. | 60 // it's created, which is actually a stronger rule than its real counterpart. |
61 // But that's fine; it's good practice. | 61 // But that's fine; it's good practice. |
62 scoped_refptr<extensions::MockHostResolverCreator> resolver_creator_; | 62 scoped_refptr<extensions::MockHostResolverCreator> resolver_creator_; |
63 }; | 63 }; |
64 | 64 |
65 } // namespace | 65 } // namespace |
66 | 66 |
67 IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketsTcpCreateGood) { | 67 IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketsTcpCreateGood) { |
68 scoped_refptr<extensions::api::SocketsTcpCreateFunction> | 68 scoped_refptr<extensions::core_api::SocketsTcpCreateFunction> |
69 socket_create_function(new extensions::api::SocketsTcpCreateFunction()); | 69 socket_create_function( |
| 70 new extensions::core_api::SocketsTcpCreateFunction()); |
70 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); | 71 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); |
71 | 72 |
72 socket_create_function->set_extension(empty_extension.get()); | 73 socket_create_function->set_extension(empty_extension.get()); |
73 socket_create_function->set_has_callback(true); | 74 socket_create_function->set_has_callback(true); |
74 | 75 |
75 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( | 76 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( |
76 socket_create_function.get(), "[]", browser(), utils::NONE)); | 77 socket_create_function.get(), "[]", browser(), utils::NONE)); |
77 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); | 78 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); |
78 base::DictionaryValue *value = | 79 base::DictionaryValue *value = |
79 static_cast<base::DictionaryValue*>(result.get()); | 80 static_cast<base::DictionaryValue*>(result.get()); |
(...skipping 22 matching lines...) Expand all Loading... |
102 | 103 |
103 ExtensionTestMessageListener listener("info_please", true); | 104 ExtensionTestMessageListener listener("info_please", true); |
104 | 105 |
105 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_tcp/api"))); | 106 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_tcp/api"))); |
106 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 107 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
107 listener.Reply( | 108 listener.Reply( |
108 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port)); | 109 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port)); |
109 | 110 |
110 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 111 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
111 } | 112 } |
OLD | NEW |