OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/stringprintf.h" | 6 #include "base/stringprintf.h" |
7 #include "chrome/browser/extensions/api/dns/host_resolver_wrapper.h" | 7 #include "chrome/browser/extensions/api/dns/host_resolver_wrapper.h" |
8 #include "chrome/browser/extensions/api/dns/mock_host_resolver_creator.h" | 8 #include "chrome/browser/extensions/api/dns/mock_host_resolver_creator.h" |
9 #include "chrome/browser/extensions/api/socket/socket_api.h" | 9 #include "chrome/browser/extensions/api/socket/socket_api.h" |
10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } // namespace | 56 } // namespace |
57 | 57 |
58 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPCreateGood) { | 58 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPCreateGood) { |
59 scoped_refptr<extensions::SocketCreateFunction> socket_create_function( | 59 scoped_refptr<extensions::SocketCreateFunction> socket_create_function( |
60 new extensions::SocketCreateFunction()); | 60 new extensions::SocketCreateFunction()); |
61 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); | 61 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); |
62 | 62 |
63 socket_create_function->set_extension(empty_extension.get()); | 63 socket_create_function->set_extension(empty_extension.get()); |
64 socket_create_function->set_has_callback(true); | 64 socket_create_function->set_has_callback(true); |
65 | 65 |
66 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnResult( | 66 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( |
67 socket_create_function, | 67 socket_create_function, |
68 "[\"udp\"]", | 68 "[\"udp\"]", |
69 browser(), utils::NONE)); | 69 browser(), utils::NONE)); |
70 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); | 70 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); |
71 DictionaryValue *value = static_cast<DictionaryValue*>(result.get()); | 71 DictionaryValue *value = static_cast<DictionaryValue*>(result.get()); |
72 int socketId = -1; | 72 int socketId = -1; |
73 EXPECT_TRUE(value->GetInteger("socketId", &socketId)); | 73 EXPECT_TRUE(value->GetInteger("socketId", &socketId)); |
74 EXPECT_TRUE(socketId > 0); | 74 EXPECT_TRUE(socketId > 0); |
75 } | 75 } |
76 | 76 |
77 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPCreateGood) { | 77 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPCreateGood) { |
78 scoped_refptr<extensions::SocketCreateFunction> socket_create_function( | 78 scoped_refptr<extensions::SocketCreateFunction> socket_create_function( |
79 new extensions::SocketCreateFunction()); | 79 new extensions::SocketCreateFunction()); |
80 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); | 80 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); |
81 | 81 |
82 socket_create_function->set_extension(empty_extension.get()); | 82 socket_create_function->set_extension(empty_extension.get()); |
83 socket_create_function->set_has_callback(true); | 83 socket_create_function->set_has_callback(true); |
84 | 84 |
85 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnResult( | 85 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( |
86 socket_create_function, | 86 socket_create_function, |
87 "[\"tcp\"]", | 87 "[\"tcp\"]", |
88 browser(), utils::NONE)); | 88 browser(), utils::NONE)); |
89 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); | 89 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); |
90 DictionaryValue *value = static_cast<DictionaryValue*>(result.get()); | 90 DictionaryValue *value = static_cast<DictionaryValue*>(result.get()); |
91 int socketId = -1; | 91 int socketId = -1; |
92 EXPECT_TRUE(value->GetInteger("socketId", &socketId)); | 92 EXPECT_TRUE(value->GetInteger("socketId", &socketId)); |
93 ASSERT_TRUE(socketId > 0); | 93 ASSERT_TRUE(socketId > 0); |
94 } | 94 } |
95 | 95 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 155 |
156 ExtensionTestMessageListener listener("info_please", true); | 156 ExtensionTestMessageListener listener("info_please", true); |
157 | 157 |
158 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); | 158 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); |
159 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 159 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
160 listener.Reply( | 160 listener.Reply( |
161 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port)); | 161 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port)); |
162 | 162 |
163 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 163 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
164 } | 164 } |
OLD | NEW |