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_udp/sockets_udp_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/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
20 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
| 20 #include "extensions/browser/api/sockets_udp/sockets_udp_api.h" |
21 #include "net/dns/mock_host_resolver.h" | 21 #include "net/dns/mock_host_resolver.h" |
22 #include "net/test/spawned_test_server/spawned_test_server.h" | 22 #include "net/test/spawned_test_server/spawned_test_server.h" |
23 | 23 |
24 using extensions::Extension; | 24 using extensions::Extension; |
25 | 25 |
26 namespace utils = extension_function_test_utils; | 26 namespace utils = extension_function_test_utils; |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 // TODO(jschuh): Hanging plugin tests. crbug.com/244653 | 30 // TODO(jschuh): Hanging plugin tests. crbug.com/244653 |
(...skipping 29 matching lines...) Expand all Loading... |
60 | 60 |
61 // The MockHostResolver asserts that it's used on the same thread on which | 61 // The MockHostResolver asserts that it's used on the same thread on which |
62 // it's created, which is actually a stronger rule than its real counterpart. | 62 // it's created, which is actually a stronger rule than its real counterpart. |
63 // But that's fine; it's good practice. | 63 // But that's fine; it's good practice. |
64 scoped_refptr<extensions::MockHostResolverCreator> resolver_creator_; | 64 scoped_refptr<extensions::MockHostResolverCreator> resolver_creator_; |
65 }; | 65 }; |
66 | 66 |
67 } // namespace | 67 } // namespace |
68 | 68 |
69 IN_PROC_BROWSER_TEST_F(SocketsUdpApiTest, SocketsUdpCreateGood) { | 69 IN_PROC_BROWSER_TEST_F(SocketsUdpApiTest, SocketsUdpCreateGood) { |
70 scoped_refptr<extensions::api::SocketsUdpCreateFunction> | 70 scoped_refptr<extensions::core_api::SocketsUdpCreateFunction> |
71 socket_create_function(new extensions::api::SocketsUdpCreateFunction()); | 71 socket_create_function( |
| 72 new extensions::core_api::SocketsUdpCreateFunction()); |
72 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); | 73 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); |
73 | 74 |
74 socket_create_function->set_extension(empty_extension.get()); | 75 socket_create_function->set_extension(empty_extension.get()); |
75 socket_create_function->set_has_callback(true); | 76 socket_create_function->set_has_callback(true); |
76 | 77 |
77 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( | 78 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( |
78 socket_create_function.get(), "[]", browser(), utils::NONE)); | 79 socket_create_function.get(), "[]", browser(), utils::NONE)); |
79 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); | 80 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); |
80 base::DictionaryValue *value = | 81 base::DictionaryValue *value = |
81 static_cast<base::DictionaryValue*>(result.get()); | 82 static_cast<base::DictionaryValue*>(result.get()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 ResultCatcher catcher; | 117 ResultCatcher catcher; |
117 catcher.RestrictToProfile(browser()->profile()); | 118 catcher.RestrictToProfile(browser()->profile()); |
118 ExtensionTestMessageListener listener("info_please", true); | 119 ExtensionTestMessageListener listener("info_please", true); |
119 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_udp/api"))); | 120 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_udp/api"))); |
120 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 121 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
121 listener.Reply( | 122 listener.Reply( |
122 base::StringPrintf("multicast:%s:%d", kHostname.c_str(), kPort)); | 123 base::StringPrintf("multicast:%s:%d", kHostname.c_str(), kPort)); |
123 | 124 |
124 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 125 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
125 } | 126 } |
OLD | NEW |