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

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

Issue 10694106: Added support for multiple parameters to Extension API callbacks. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Indentation fixes and comment. Created 8 years, 5 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
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/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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } // namespace 63 } // namespace
64 64
65 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPCreateGood) { 65 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPCreateGood) {
66 scoped_refptr<extensions::SocketCreateFunction> socket_create_function( 66 scoped_refptr<extensions::SocketCreateFunction> socket_create_function(
67 new extensions::SocketCreateFunction()); 67 new extensions::SocketCreateFunction());
68 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); 68 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension());
69 69
70 socket_create_function->set_extension(empty_extension.get()); 70 socket_create_function->set_extension(empty_extension.get());
71 socket_create_function->set_has_callback(true); 71 socket_create_function->set_has_callback(true);
72 72
73 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnResult( 73 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult(
74 socket_create_function, 74 socket_create_function,
75 GenerateCreateFunctionArgs("udp", kHostname, kPort), 75 GenerateCreateFunctionArgs("udp", kHostname, kPort),
76 browser(), utils::NONE)); 76 browser(), utils::NONE));
77 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); 77 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType());
78 DictionaryValue *value = static_cast<DictionaryValue*>(result.get()); 78 DictionaryValue *value = static_cast<DictionaryValue*>(result.get());
79 int socketId = -1; 79 int socketId = -1;
80 EXPECT_TRUE(value->GetInteger("socketId", &socketId)); 80 EXPECT_TRUE(value->GetInteger("socketId", &socketId));
81 EXPECT_TRUE(socketId > 0); 81 EXPECT_TRUE(socketId > 0);
82 } 82 }
83 83
84 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPCreateGood) { 84 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPCreateGood) {
85 scoped_refptr<extensions::SocketCreateFunction> socket_create_function( 85 scoped_refptr<extensions::SocketCreateFunction> socket_create_function(
86 new extensions::SocketCreateFunction()); 86 new extensions::SocketCreateFunction());
87 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); 87 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension());
88 88
89 socket_create_function->set_extension(empty_extension.get()); 89 socket_create_function->set_extension(empty_extension.get());
90 socket_create_function->set_has_callback(true); 90 socket_create_function->set_has_callback(true);
91 91
92 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnResult( 92 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult(
93 socket_create_function, 93 socket_create_function,
94 GenerateCreateFunctionArgs("udp", kHostname, kPort), 94 GenerateCreateFunctionArgs("udp", kHostname, kPort),
95 browser(), utils::NONE)); 95 browser(), utils::NONE));
96 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); 96 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType());
97 DictionaryValue *value = static_cast<DictionaryValue*>(result.get()); 97 DictionaryValue *value = static_cast<DictionaryValue*>(result.get());
98 int socketId = -1; 98 int socketId = -1;
99 EXPECT_TRUE(value->GetInteger("socketId", &socketId)); 99 EXPECT_TRUE(value->GetInteger("socketId", &socketId));
100 ASSERT_TRUE(socketId > 0); 100 ASSERT_TRUE(socketId > 0);
101 } 101 }
102 102
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 162
163 ExtensionTestMessageListener listener("info_please", true); 163 ExtensionTestMessageListener listener("info_please", true);
164 164
165 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); 165 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api")));
166 EXPECT_TRUE(listener.WaitUntilSatisfied()); 166 EXPECT_TRUE(listener.WaitUntilSatisfied());
167 listener.Reply( 167 listener.Reply(
168 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port)); 168 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port));
169 169
170 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 170 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
171 } 171 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698