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

Side by Side Diff: chrome/browser/extensions/extension_function_test_utils.cc

Issue 10701041: implement sign in dialog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 | 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 "chrome/browser/extensions/extension_function_test_utils.h" 5 #include "chrome/browser/extensions/extension_function_test_utils.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, 122 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function,
123 const std::string& args, 123 const std::string& args,
124 Browser* browser) { 124 Browser* browser) {
125 return RunFunctionAndReturnError(function, args, browser, NONE); 125 return RunFunctionAndReturnError(function, args, browser, NONE);
126 } 126 }
127 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, 127 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function,
128 const std::string& args, 128 const std::string& args,
129 Browser* browser, 129 Browser* browser,
130 RunFunctionFlags flags) { 130 RunFunctionFlags flags) {
131 scoped_refptr<ExtensionFunction> function_owner(function); 131 scoped_refptr<ExtensionFunction> function_owner(function);
132 // Without a callback the function will not generate a result.
133 function->set_has_callback(true);
132 RunFunction(function, args, browser, flags); 134 RunFunction(function, args, browser, flags);
133 EXPECT_FALSE(function->GetResultList()) << "Did not expect a result"; 135 EXPECT_FALSE(function->GetResultList()) << "Did not expect a result";
134 return function->GetError(); 136 return function->GetError();
135 } 137 }
136 138
137 base::Value* RunFunctionAndReturnSingleResult( 139 base::Value* RunFunctionAndReturnSingleResult(
138 UIThreadExtensionFunction* function, 140 UIThreadExtensionFunction* function,
139 const std::string& args, 141 const std::string& args,
140 Browser* browser) { 142 Browser* browser) {
141 return RunFunctionAndReturnSingleResult(function, args, browser, NONE); 143 return RunFunctionAndReturnSingleResult(function, args, browser, NONE);
142 } 144 }
143 base::Value* RunFunctionAndReturnSingleResult( 145 base::Value* RunFunctionAndReturnSingleResult(
144 UIThreadExtensionFunction* function, 146 UIThreadExtensionFunction* function,
145 const std::string& args, 147 const std::string& args,
146 Browser* browser, 148 Browser* browser,
147 RunFunctionFlags flags) { 149 RunFunctionFlags flags) {
148 scoped_refptr<ExtensionFunction> function_owner(function); 150 scoped_refptr<ExtensionFunction> function_owner(function);
151 // Without a callback the function will not generate a result.
152 function->set_has_callback(true);
149 RunFunction(function, args, browser, flags); 153 RunFunction(function, args, browser, flags);
150 EXPECT_TRUE(function->GetError().empty()) << "Unexpected error: " 154 EXPECT_TRUE(function->GetError().empty()) << "Unexpected error: "
151 << function->GetError(); 155 << function->GetError();
152 base::Value* single_result = NULL; 156 base::Value* single_result = NULL;
153 if (function->GetResultList() != NULL && 157 if (function->GetResultList() != NULL &&
154 function->GetResultList()->Get(0, &single_result)) { 158 function->GetResultList()->Get(0, &single_result)) {
155 return single_result->DeepCopy(); 159 return single_result->DeepCopy();
156 } 160 }
157 return NULL; 161 return NULL;
158 } 162 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 if (!response_delegate.HasResponse()) { 225 if (!response_delegate.HasResponse()) {
222 response_delegate.set_should_post_quit(true); 226 response_delegate.set_should_post_quit(true);
223 ui_test_utils::RunMessageLoop(); 227 ui_test_utils::RunMessageLoop();
224 } 228 }
225 229
226 EXPECT_TRUE(response_delegate.HasResponse()); 230 EXPECT_TRUE(response_delegate.HasResponse());
227 return response_delegate.GetResponse(); 231 return response_delegate.GetResponse();
228 } 232 }
229 233
230 } // namespace extension_function_test_utils 234 } // namespace extension_function_test_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698