From bdfc03ebd9af014a7f633a9dcb1575b599b907f0 Mon Sep 17 00:00:00 2001 From: "miket@chromium.org" Date: Tue, 22 Nov 2011 00:20:33 +0000 Subject: Refactor to allow same code to test both sync and async functions. BUG=none TEST=none Review URL: http://codereview.chromium.org/8588067 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111050 0039d316-1c4b-4281-b951-d872f2087c98 --- .../extensions/extension_function_test_utils.h | 24 ++++++++-------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'chrome/browser/extensions/extension_function_test_utils.h') diff --git a/chrome/browser/extensions/extension_function_test_utils.h b/chrome/browser/extensions/extension_function_test_utils.h index ef005a4..e248ec3 100644 --- a/chrome/browser/extensions/extension_function_test_utils.h +++ b/chrome/browser/extensions/extension_function_test_utils.h @@ -49,8 +49,7 @@ enum RunFunctionFlags { }; // Run |function| with |args| and return the resulting error. Adds an error to -// the current test if |function| returns a result. The caller releases -// ownership of |function|. +// the current test if |function| returns a result. std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, const std::string& args, Browser* browser, @@ -60,8 +59,8 @@ std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, Browser* browser); // Run |function| with |args| and return the result. Adds an error to the -// current test if |function| returns an error. The caller releases ownership of -// |function|. the caller takes ownership of the result. +// current test if |function| returns an error. The caller takes ownership of +// the result. base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function, const std::string& args, Browser* browser, @@ -70,28 +69,21 @@ base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function, const std::string& args, Browser* browser); -// Create and run |function| with |args|. The caller retains ownership of -// |function|. +// Create and run |function| with |args|. Works with both synchronous and async +// functions. // // TODO(aa): It would be nice if |args| could be validated against the schema // that |function| expects. That way, we know that we are testing something // close to what the bindings would actually send. // // TODO(aa): I'm concerned that this style won't scale to all the bits and bobs -// we're going to need to frob for all the different extension functions. But we -// can refactor when we see what is needed. -void RunFunction(UIThreadExtensionFunction* function, +// we're going to need to frob for all the different extension functions. But +// we can refactor when we see what is needed. +bool RunFunction(UIThreadExtensionFunction* function, const std::string& args, Browser* browser, RunFunctionFlags flags); -// Similar to RunFunction, but doesn't return until |function| calls -// SendResponse. Returns the value |function| passed to SendResponse. -bool RunAsyncFunction(AsyncExtensionFunction* function, - const std::string& args, - Browser* browser, - RunFunctionFlags flags); - } // namespace extension_function_test_utils #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ -- cgit v1.1