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

Unified Diff: content/public/test/browser_test_utils.cc

Issue 818263004: Add a test that is a repro case for bug 444945. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@autofill_crash'
Patch Set: Nasko's fixes Created 6 years 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
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | content/public/test/content_browser_test_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/browser_test_utils.cc
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc
index a1949d3f38c9295b1ad286fb0cc6b66cf524917e..78d1f2b7dab688ce357702c8e40d028f5c575de5 100644
--- a/content/public/test/browser_test_utils.cc
+++ b/content/public/test/browser_test_utils.cc
@@ -15,6 +15,7 @@
#include "base/test/test_timeouts.h"
#include "base/values.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
+#include "content/browser/web_contents/web_contents_impl.h"
#include "content/browser/web_contents/web_contents_view.h"
#include "content/common/input/synthetic_web_input_event_builders.h"
#include "content/public/browser/browser_context.h"
@@ -840,4 +841,66 @@ bool DOMMessageQueue::WaitForMessage(std::string* message) {
return true;
}
+class WebContentsAddedObserver::RenderViewCreatedObserver
+ : public WebContentsObserver {
+ public:
+ explicit RenderViewCreatedObserver(WebContents* web_contents)
+ : WebContentsObserver(web_contents),
+ render_view_created_called_(false),
+ main_frame_created_called_(false) {}
+
+ // WebContentsObserver:
+ void RenderViewCreated(RenderViewHost* rvh) override {
+ render_view_created_called_ = true;
+ }
+
+ void RenderFrameCreated(RenderFrameHost* rfh) override {
+ if (rfh == web_contents()->GetMainFrame())
+ main_frame_created_called_ = true;
+ }
+
+ bool render_view_created_called_;
+ bool main_frame_created_called_;
+};
+
+WebContentsAddedObserver::WebContentsAddedObserver()
+ : web_contents_created_callback_(
+ base::Bind(&WebContentsAddedObserver::WebContentsCreated,
+ base::Unretained(this))),
+ web_contents_(NULL) {
+ WebContentsImpl::FriendZone::AddCreatedCallbackForTesting(
+ web_contents_created_callback_);
+}
+
+WebContentsAddedObserver::~WebContentsAddedObserver() {
+ WebContentsImpl::FriendZone::RemoveCreatedCallbackForTesting(
+ web_contents_created_callback_);
+}
+
+void WebContentsAddedObserver::WebContentsCreated(WebContents* web_contents) {
+ DCHECK(!web_contents_);
+ web_contents_ = web_contents;
+ child_observer_.reset(new RenderViewCreatedObserver(web_contents));
+
+ if (runner_.get())
+ runner_->QuitClosure().Run();
+}
+
+WebContents* WebContentsAddedObserver::GetWebContents() {
+ if (web_contents_)
+ return web_contents_;
+
+ runner_ = new MessageLoopRunner();
+ runner_->Run();
+ return web_contents_;
+}
+
+bool WebContentsAddedObserver::RenderViewCreatedCalled() {
+ if (child_observer_) {
+ return child_observer_->render_view_created_called_ &&
+ child_observer_->main_frame_created_called_;
+ }
+ return false;
+}
+
} // namespace content
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | content/public/test/content_browser_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698