Chromium Code Reviews| Index: extensions/browser/api_test_utils.cc |
| diff --git a/extensions/browser/api_test_utils.cc b/extensions/browser/api_test_utils.cc |
| index b18b249e58dd560a405d6e61a9753faae0c4e366..829e18540e017460c6040f3e2205b9dd9a623f25 100644 |
| --- a/extensions/browser/api_test_utils.cc |
| +++ b/extensions/browser/api_test_utils.cc |
| @@ -132,6 +132,27 @@ base::Value* RunFunctionAndReturnSingleResult( |
| function, args, context, dispatcher.Pass(), flags); |
| } |
| +std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, |
|
James Cook
2014/08/13 16:11:36
What's the plan for the copy of this code in chrom
Yoyo Zhou
2014/08/13 22:53:43
I'd rather not spend time on refactoring it when t
|
| + const std::string& args, |
| + content::BrowserContext* context) { |
| + return RunFunctionAndReturnError(function, args, context, NONE); |
| +} |
| + |
| +std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, |
| + const std::string& args, |
| + content::BrowserContext* context, |
| + RunFunctionFlags flags) { |
| + TestFunctionDispatcherDelegate delegate; |
| + scoped_ptr<ExtensionFunctionDispatcher> dispatcher( |
| + new ExtensionFunctionDispatcher(context, &delegate)); |
| + scoped_refptr<ExtensionFunction> function_owner(function); |
| + // Without a callback the function will not generate a result. |
| + function->set_has_callback(true); |
| + RunFunction(function, args, context, dispatcher.Pass(), flags); |
| + EXPECT_FALSE(function->GetResultList()) << "Did not expect a result"; |
| + return function->GetError(); |
| +} |
| + |
| bool RunFunction(UIThreadExtensionFunction* function, |
| const std::string& args, |
| content::BrowserContext* context, |