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

Unified Diff: chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc

Issue 178843004: [wip] Add some more state to RenderViewHost's lifetime. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moar Created 6 years, 10 months 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 | « no previous file | content/browser/frame_host/navigation_entry_screenshot_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
diff --git a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
index 6d47d2b608808c7f73ffb7d3ef40b0532e2f5a38..6ff1ad82543f1d621ce808d9d914791a61279a1a 100644
--- a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
+++ b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
@@ -17,6 +17,7 @@
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/render_process_host_observer.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_iterator.h"
#include "content/public/browser/web_contents.h"
@@ -28,6 +29,42 @@ using content::WebContents;
namespace {
+class RenderProcessHostAliveObserver
+ : public content::RenderProcessHostObserver {
+ public:
+ explicit RenderProcessHostAliveObserver(content::RenderProcessHost* host)
+ : host_(host) {
+ host_->AddObserver(this);
+ }
+
+ virtual ~RenderProcessHostAliveObserver() {
+ CHECK(!host_);
+ }
+
+ void WaitUntilProcessDies() {
+ if (!host_)
+ return;
+ base::RunLoop run_loop;
+ quit_closure_ = run_loop.QuitClosure();
+ run_loop.Run();
+ }
+
+ private:
+ // content::RenderProcessHostObserver:
+ virtual void RenderProcessHostDestroyed(
+ content::RenderProcessHost* host) OVERRIDE {
+ CHECK_EQ(host_, host);
+ host_ = NULL;
+ if (!quit_closure_.is_null())
+ quit_closure_.Run();
+ }
+
+ content::RenderProcessHost* host_;
+ base::Closure quit_closure_;
+
+ DISALLOW_COPY_AND_ASSIGN(RenderProcessHostAliveObserver);
+};
+
int RenderProcessHostCount() {
content::RenderProcessHost::iterator hosts =
content::RenderProcessHost::AllHostsIterator();
@@ -111,9 +148,18 @@ class ChromeRenderProcessHostTest : public InProcessBrowserTest {
content::RenderProcessHost* rph2 = NULL;
content::RenderProcessHost* rph3 = NULL;
- // Change the first tab to be the omnibox page (TYPE_WEBUI).
+ EXPECT_EQ(host_count, RenderProcessHostCount());
+ ASSERT_EQ(tab_count, browser()->tab_strip_model()->count());
+
+ tab1 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1);
+ RenderProcessHostAliveObserver process_observer(
+ tab1->GetRenderProcessHost());
+
+ // Change the first tab to be the omnibox page (TYPE_WEBUI). The navigation
+ // should terminate the existing process.
GURL omnibox(chrome::kChromeUIOmniboxURL);
ui_test_utils::NavigateToURL(browser(), omnibox);
+ process_observer.WaitUntilProcessDies();
EXPECT_EQ(tab_count, browser()->tab_strip_model()->count());
tab1 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1);
rph1 = tab1->GetRenderProcessHost();
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_entry_screenshot_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698