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

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

Issue 8488012: Fix for management API related to escalated permissions disabled extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased again 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 c6990e8a5ed2b2c992156375563cfd6a8c733eb3..e68bf5efdbce7e3f0e6fa062cfbe78ddfa0541c1 100644
--- a/chrome/browser/extensions/extension_function_test_utils.cc
+++ b/chrome/browser/extensions/extension_function_test_utils.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/extensions/extension_function_dispatcher.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/extensions/extension.h"
+#include "chrome/test/base/ui_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -160,4 +161,58 @@ void RunFunction(UIThreadExtensionFunction* function,
function->Run();
}
+// This helps us be able to wait until an AsyncExtensionFunction calls
+// SendResponse.
+class SendResponseDelegate : public AsyncExtensionFunction::DelegateForTests {
+ public:
+ SendResponseDelegate() : should_post_quit_(false) {}
+
+ virtual ~SendResponseDelegate() {}
+
+ void set_should_post_quit(bool should_quit) {
+ should_post_quit_ = should_quit;
+ }
+
+ bool HasResponse() {
+ return response_.get() != NULL;
+ }
+
+ bool GetResponse() {
+ EXPECT_TRUE(HasResponse());
+ return *response_.get();
+ }
+
+ virtual void OnSendResponse(AsyncExtensionFunction* function, bool success) {
+ ASSERT_FALSE(HasResponse());
+ response_.reset(new bool);
+ *response_ = success;
+ if (should_post_quit_) {
+ MessageLoopForUI::current()->Quit();
+ }
+ }
+
+ private:
+ scoped_ptr<bool> response_;
+ bool should_post_quit_;
+};
+
+bool RunAsyncFunction(AsyncExtensionFunction* function,
+ const std::string& args,
+ Browser* browser,
+ RunFunctionFlags flags) {
+ SendResponseDelegate response_delegate;
+ function->set_test_delegate(&response_delegate);
+ RunFunction(function, args, browser, flags);
+
+ // If the RunImpl of |function| didn't already call SendResponse, run the
+ // message loop until they do.
+ if (!response_delegate.HasResponse()) {
+ response_delegate.set_should_post_quit(true);
+ ui_test_utils::RunMessageLoop();
+ }
+
+ EXPECT_TRUE(response_delegate.HasResponse());
+ return response_delegate.GetResponse();
+}
+
} // namespace extension_function_test_utils
« no previous file with comments | « chrome/browser/extensions/extension_function_test_utils.h ('k') | chrome/browser/extensions/extension_install_dialog.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698