[Extensions] Remove extension_function_test_utils::RunFunctionFlags
There exist two files for running extension API functions in testing:
extension_function_test_utils (at the //chrome layer) and api_test_utils
(at the //extensions layer). Ideally, we'd combine these more than they
are.
One piece of low-hanging fruit is that each defines an enum
RunFunctionFlags with the exact same values (and the //chrome version
static-casts the values to the //extensions version). Remove the
//chrome (extension_function_test_utils) version, and update callers to
use the //extensions (api_test_utils) version.
Bug: 394840
[email protected] (c/b/apps)
Change-Id: I5cf8e7ac44eb7c2ff059c52d5d4bd728349a3c7e
Reviewed-on: https://chromium-review.googlesource.com/916743
Commit-Queue: Devlin <[email protected]>
Reviewed-by: Istiaque Ahmed <[email protected]>
Cr-Commit-Position: refs/heads/master@{#536561}diff --git a/chrome/browser/extensions/extension_function_test_utils.cc b/chrome/browser/extensions/extension_function_test_utils.cc
index b22aeb7d..f7ef1c35 100644
--- a/chrome/browser/extensions/extension_function_test_utils.cc
+++ b/chrome/browser/extensions/extension_function_test_utils.cc
@@ -81,12 +81,14 @@
std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function,
const std::string& args,
Browser* browser) {
- return RunFunctionAndReturnError(function, args, browser, NONE);
+ return RunFunctionAndReturnError(function, args, browser,
+ extensions::api_test_utils::NONE);
}
-std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function,
- const std::string& args,
- Browser* browser,
- RunFunctionFlags flags) {
+std::string RunFunctionAndReturnError(
+ UIThreadExtensionFunction* function,
+ const std::string& args,
+ Browser* browser,
+ extensions::api_test_utils::RunFunctionFlags flags) {
scoped_refptr<ExtensionFunction> function_owner(function);
RunFunction(function, args, browser, flags);
// When sending a response, the function will set an empty list value if there
@@ -103,13 +105,14 @@
UIThreadExtensionFunction* function,
const std::string& args,
Browser* browser) {
- return RunFunctionAndReturnSingleResult(function, args, browser, NONE);
+ return RunFunctionAndReturnSingleResult(function, args, browser,
+ extensions::api_test_utils::NONE);
}
base::Value* RunFunctionAndReturnSingleResult(
UIThreadExtensionFunction* function,
const std::string& args,
Browser* browser,
- RunFunctionFlags flags) {
+ extensions::api_test_utils::RunFunctionFlags flags) {
scoped_refptr<ExtensionFunction> function_owner(function);
RunFunction(function, args, browser, flags);
EXPECT_TRUE(function->GetError().empty()) << "Unexpected error: "
@@ -125,7 +128,7 @@
bool RunFunction(UIThreadExtensionFunction* function,
const std::string& args,
Browser* browser,
- RunFunctionFlags flags) {
+ extensions::api_test_utils::RunFunctionFlags flags) {
std::unique_ptr<base::ListValue> parsed_args(ParseList(args));
EXPECT_TRUE(parsed_args.get())
<< "Could not parse extension function arguments: " << args;
@@ -135,16 +138,14 @@
bool RunFunction(UIThreadExtensionFunction* function,
std::unique_ptr<base::ListValue> args,
Browser* browser,
- RunFunctionFlags flags) {
+ extensions::api_test_utils::RunFunctionFlags flags) {
TestFunctionDispatcherDelegate dispatcher_delegate(browser);
std::unique_ptr<extensions::ExtensionFunctionDispatcher> dispatcher(
new extensions::ExtensionFunctionDispatcher(browser->profile()));
dispatcher->set_delegate(&dispatcher_delegate);
- // TODO(yoz): The cast is a hack; these flags should be defined in
- // only one place. See crbug.com/394840.
- return extensions::api_test_utils::RunFunction(
- function, std::move(args), browser->profile(), std::move(dispatcher),
- static_cast<extensions::api_test_utils::RunFunctionFlags>(flags));
+ return extensions::api_test_utils::RunFunction(function, std::move(args),
+ browser->profile(),
+ std::move(dispatcher), flags);
}
} // namespace extension_function_test_utils