summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorerikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-16 00:43:23 +0000
committererikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-16 00:43:23 +0000
commitb6e38ef007bf29a33a35dc96d21a5499d42428a3 (patch)
tree2f1dbc46075e8a0e204cf290cf34e1a3061ead39 /chrome/test
parentf2330fe08ed5e92b52c6c90d2230fe678e07eb17 (diff)
downloadchromium_src-b6e38ef007bf29a33a35dc96d21a5499d42428a3.zip
chromium_src-b6e38ef007bf29a33a35dc96d21a5499d42428a3.tar.gz
chromium_src-b6e38ef007bf29a33a35dc96d21a5499d42428a3.tar.bz2
Close all browsers during InProcessBrowserTest cleanup, not just the main one.
BUG=none TEST=ExtensionViewTest.Incognito Review URL: http://codereview.chromium.org/126175 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18466 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/in_process_browser_test.cc26
-rw-r--r--chrome/test/in_process_browser_test.h13
2 files changed, 6 insertions, 33 deletions
diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc
index d79a02e..ed03bbbe 100644
--- a/chrome/test/in_process_browser_test.cc
+++ b/chrome/test/in_process_browser_test.cc
@@ -9,6 +9,7 @@
#include "base/file_util.h"
#include "base/path_service.h"
#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/browser_window.h"
@@ -143,17 +144,6 @@ void InProcessBrowserTest::TearDown() {
RenderProcessHost::set_run_renderer_in_process(original_single_process_);
}
-void InProcessBrowserTest::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- if (type == NotificationType::BROWSER_CLOSED) {
- DCHECK(Source<Browser>(source).ptr() == browser_);
- browser_ = NULL;
- } else {
- NOTREACHED();
- }
-}
-
HTTPTestServer* InProcessBrowserTest::StartHTTPServer() {
// The HTTPServer must run on the IO thread.
DCHECK(!http_server_.get());
@@ -199,18 +189,12 @@ void InProcessBrowserTest::RunTestOnMainThreadLoop() {
browser_ = CreateBrowser(profile);
- registrar_.Add(this,
- NotificationType::BROWSER_CLOSED,
- Source<Browser>(browser_));
-
RunTestOnMainThread();
- if (browser_)
- browser_->CloseAllTabs();
-
- // Remove all registered notifications, otherwise by the time the
- // destructor is run the NotificationService is dead.
- registrar_.RemoveAll();
+ BrowserList::const_reverse_iterator browser =
+ BrowserList::begin_last_active();
+ for (; browser != BrowserList::end_last_active(); ++browser)
+ (*browser)->CloseAllTabs();
// Stop the HTTP server.
http_server_ = NULL;
diff --git a/chrome/test/in_process_browser_test.h b/chrome/test/in_process_browser_test.h
index 25e18a4..7795c8a 100644
--- a/chrome/test/in_process_browser_test.h
+++ b/chrome/test/in_process_browser_test.h
@@ -5,8 +5,6 @@
#ifndef CHROME_TEST_IN_PROCESS_BROWSER_TEST_H_
#define CHROME_TEST_IN_PROCESS_BROWSER_TEST_H_
-#include "chrome/common/notification_registrar.h"
-#include "chrome/common/notification_observer.h"
#include "net/url_request/url_request_unittest.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -39,7 +37,7 @@ class RuleBasedHostMapper;
// InProcessBrowserTest disables the sandbox when running.
//
// See ui_test_utils for a handful of methods designed for use with this class.
-class InProcessBrowserTest : public testing::Test, public NotificationObserver {
+class InProcessBrowserTest : public testing::Test {
public:
InProcessBrowserTest();
@@ -54,12 +52,6 @@ class InProcessBrowserTest : public testing::Test, public NotificationObserver {
// Restores state configured in SetUp.
virtual void TearDown();
- // Used to track when the browser_ is destroyed. Resets the |browser_| field
- // to NULL.
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
protected:
// Returns the browser created by CreateBrowser.
Browser* browser() const { return browser_; }
@@ -98,9 +90,6 @@ class InProcessBrowserTest : public testing::Test, public NotificationObserver {
// Browser created from CreateBrowser.
Browser* browser_;
- // Used to track when the browser is deleted.
- NotificationRegistrar registrar_;
-
// HTTPServer, created when StartHTTPServer is invoked.
scoped_refptr<HTTPTestServer> http_server_;