Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(443)

Side by Side Diff: chrome/browser/extensions/api/socket/socket_apitest.cc

Issue 16915006: Convert most of extensions and some other random stuff to using the base namespace for Values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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/socket/socket_api.h" 10 #include "chrome/browser/extensions/api/socket/socket_api.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 scoped_refptr<extensions::SocketCreateFunction> socket_create_function( 118 scoped_refptr<extensions::SocketCreateFunction> socket_create_function(
119 new extensions::SocketCreateFunction()); 119 new extensions::SocketCreateFunction());
120 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); 120 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension());
121 121
122 socket_create_function->set_extension(empty_extension.get()); 122 socket_create_function->set_extension(empty_extension.get());
123 socket_create_function->set_has_callback(true); 123 socket_create_function->set_has_callback(true);
124 124
125 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( 125 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult(
126 socket_create_function.get(), "[\"udp\"]", browser(), utils::NONE)); 126 socket_create_function.get(), "[\"udp\"]", browser(), utils::NONE));
127 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); 127 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType());
128 DictionaryValue *value = static_cast<DictionaryValue*>(result.get()); 128 base::DictionaryValue *value =
129 static_cast<base::DictionaryValue*>(result.get());
129 int socketId = -1; 130 int socketId = -1;
130 EXPECT_TRUE(value->GetInteger("socketId", &socketId)); 131 EXPECT_TRUE(value->GetInteger("socketId", &socketId));
131 EXPECT_TRUE(socketId > 0); 132 EXPECT_TRUE(socketId > 0);
132 } 133 }
133 134
134 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPCreateGood) { 135 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPCreateGood) {
135 scoped_refptr<extensions::SocketCreateFunction> socket_create_function( 136 scoped_refptr<extensions::SocketCreateFunction> socket_create_function(
136 new extensions::SocketCreateFunction()); 137 new extensions::SocketCreateFunction());
137 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); 138 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension());
138 139
139 socket_create_function->set_extension(empty_extension.get()); 140 socket_create_function->set_extension(empty_extension.get());
140 socket_create_function->set_has_callback(true); 141 socket_create_function->set_has_callback(true);
141 142
142 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( 143 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult(
143 socket_create_function.get(), "[\"tcp\"]", browser(), utils::NONE)); 144 socket_create_function.get(), "[\"tcp\"]", browser(), utils::NONE));
144 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); 145 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType());
145 DictionaryValue *value = static_cast<DictionaryValue*>(result.get()); 146 base::DictionaryValue *value =
147 static_cast<base::DictionaryValue*>(result.get());
146 int socketId = -1; 148 int socketId = -1;
147 EXPECT_TRUE(value->GetInteger("socketId", &socketId)); 149 EXPECT_TRUE(value->GetInteger("socketId", &socketId));
148 ASSERT_TRUE(socketId > 0); 150 ASSERT_TRUE(socketId > 0);
149 } 151 }
150 152
151 IN_PROC_BROWSER_TEST_F(SocketApiTest, GetNetworkList) { 153 IN_PROC_BROWSER_TEST_F(SocketApiTest, GetNetworkList) {
152 scoped_refptr<extensions::SocketGetNetworkListFunction> socket_function( 154 scoped_refptr<extensions::SocketGetNetworkListFunction> socket_function(
153 new extensions::SocketGetNetworkListFunction()); 155 new extensions::SocketGetNetworkListFunction());
154 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); 156 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension());
155 157
156 socket_function->set_extension(empty_extension.get()); 158 socket_function->set_extension(empty_extension.get());
157 socket_function->set_has_callback(true); 159 socket_function->set_has_callback(true);
158 160
159 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( 161 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult(
160 socket_function.get(), "[]", browser(), utils::NONE)); 162 socket_function.get(), "[]", browser(), utils::NONE));
161 ASSERT_EQ(base::Value::TYPE_LIST, result->GetType()); 163 ASSERT_EQ(base::Value::TYPE_LIST, result->GetType());
162 164
163 // If we're invoking socket tests, all we can confirm is that we have at 165 // If we're invoking socket tests, all we can confirm is that we have at
164 // least one address, but not what it is. 166 // least one address, but not what it is.
165 ListValue *value = static_cast<ListValue*>(result.get()); 167 base::ListValue *value = static_cast<base::ListValue*>(result.get());
166 ASSERT_TRUE(value->GetSize() > 0); 168 ASSERT_TRUE(value->GetSize() > 0);
167 } 169 }
168 170
169 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPExtension) { 171 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPExtension) {
170 scoped_ptr<net::SpawnedTestServer> test_server( 172 scoped_ptr<net::SpawnedTestServer> test_server(
171 new net::SpawnedTestServer( 173 new net::SpawnedTestServer(
172 net::SpawnedTestServer::TYPE_UDP_ECHO, 174 net::SpawnedTestServer::TYPE_UDP_ECHO,
173 net::SpawnedTestServer::kLocalhost, 175 net::SpawnedTestServer::kLocalhost,
174 base::FilePath(FILE_PATH_LITERAL("net/data")))); 176 base::FilePath(FILE_PATH_LITERAL("net/data"))));
175 EXPECT_TRUE(test_server->Start()); 177 EXPECT_TRUE(test_server->Start());
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 342
341 LaunchTestingApp(); 343 LaunchTestingApp();
342 344
343 EXPECT_TRUE(listener.WaitUntilSatisfied()); 345 EXPECT_TRUE(listener.WaitUntilSatisfied());
344 listener.Reply( 346 listener.Reply(
345 base::StringPrintf("multicast:%s:%d", kHostname.c_str(), kPort)); 347 base::StringPrintf("multicast:%s:%d", kHostname.c_str(), kPort));
346 348
347 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 349 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
348 } 350 }
349 #endif 351 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698