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

Unified Diff: chrome/browser/extensions/extension_function_test_utils.cc

Issue 8588067: Refactor to allow same code to test both sync and async functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_function_test_utils.cc
diff --git a/chrome/browser/extensions/extension_function_test_utils.cc b/chrome/browser/extensions/extension_function_test_utils.cc
index e68bf5efdbce7e3f0e6fa062cfbe78ddfa0541c1..6e951ff61c895e17f14cf9fe9916cefa839cef01 100644
--- a/chrome/browser/extensions/extension_function_test_utils.cc
+++ b/chrome/browser/extensions/extension_function_test_utils.cc
@@ -119,7 +119,7 @@ std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function,
Browser* browser,
RunFunctionFlags flags) {
scoped_refptr<ExtensionFunction> function_owner(function);
- RunFunction(function, args, browser, flags);
+ RunAsyncFunction(function, args, browser, flags);
EXPECT_FALSE(function->GetResultValue()) << "Unexpected function result " <<
function->GetResult();
return function->GetError();
@@ -135,7 +135,7 @@ base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function,
Browser* browser,
RunFunctionFlags flags) {
scoped_refptr<ExtensionFunction> function_owner(function);
- RunFunction(function, args, browser, flags);
+ RunAsyncFunction(function, args, browser, flags);
EXPECT_TRUE(function->GetError().empty()) << "Unexpected error: "
<< function->GetError();
EXPECT_TRUE(function->GetResultValue()) << "No result value found";
@@ -163,7 +163,8 @@ void RunFunction(UIThreadExtensionFunction* function,
// This helps us be able to wait until an AsyncExtensionFunction calls
// SendResponse.
-class SendResponseDelegate : public AsyncExtensionFunction::DelegateForTests {
+class SendResponseDelegate
+ : public UIThreadExtensionFunction::DelegateForTests {
public:
SendResponseDelegate() : should_post_quit_(false) {}
@@ -182,7 +183,8 @@ class SendResponseDelegate : public AsyncExtensionFunction::DelegateForTests {
return *response_.get();
}
- virtual void OnSendResponse(AsyncExtensionFunction* function, bool success) {
+ virtual void OnSendResponse(UIThreadExtensionFunction* function,
+ bool success) {
ASSERT_FALSE(HasResponse());
response_.reset(new bool);
*response_ = success;
@@ -196,7 +198,7 @@ class SendResponseDelegate : public AsyncExtensionFunction::DelegateForTests {
bool should_post_quit_;
};
-bool RunAsyncFunction(AsyncExtensionFunction* function,
+bool RunAsyncFunction(UIThreadExtensionFunction* function,
const std::string& args,
Browser* browser,
RunFunctionFlags flags) {

Powered by Google App Engine
This is Rietveld 408576698