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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
96 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketCreateBad) { | |
97 scoped_refptr<extensions::SocketCreateFunction> socket_create_function( | |
98 new extensions::SocketCreateFunction()); | |
99 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); | |
100 | |
101 socket_create_function->set_extension(empty_extension.get()); | |
102 socket_create_function->set_has_callback(true); | |
103 | |
104 // TODO(miket): this test currently passes only because of artificial code | |
105 // that doesn't run in production. Fix this when we're able to. | |
106 utils::RunFunctionAndReturnError( | |
107 socket_create_function, | |
108 "[\"xxxx\"]", | |
109 browser(), utils::NONE); | |
110 } | |
111 | |
112 IN_PROC_BROWSER_TEST_F(SocketApiTest, GetNetworkList) { | 96 IN_PROC_BROWSER_TEST_F(SocketApiTest, GetNetworkList) { |
113 scoped_refptr<extensions::SocketGetNetworkListFunction> socket_function( | 97 scoped_refptr<extensions::SocketGetNetworkListFunction> socket_function( |
114 new extensions::SocketGetNetworkListFunction()); | 98 new extensions::SocketGetNetworkListFunction()); |
115 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); | 99 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); |
116 | 100 |
117 socket_function->set_extension(empty_extension.get()); | 101 socket_function->set_extension(empty_extension.get()); |
118 socket_function->set_has_callback(true); | 102 socket_function->set_has_callback(true); |
119 | 103 |
120 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( | 104 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( |
121 socket_function, "[]", browser(), utils::NONE)); | 105 socket_function, "[]", browser(), utils::NONE)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 157 |
174 ExtensionTestMessageListener listener("info_please", true); | 158 ExtensionTestMessageListener listener("info_please", true); |
175 | 159 |
176 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); | 160 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); |
177 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 161 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
178 listener.Reply( | 162 listener.Reply( |
179 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port)); | 163 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port)); |
180 | 164 |
181 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 165 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
182 } | 166 } |
OLD | NEW |