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

Unified Diff: chrome/test/base/in_process_browser_test.cc

Issue 1228723002: Extract duplicated code in browser_tests for closing a browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/WithoutWaiting/Asynchronously Created 5 years, 5 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 | « chrome/test/base/in_process_browser_test.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/in_process_browser_test.cc
diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc
index 2ee8c81231817fb77b3bafcb5c6bce35426edf8f..96f521b12bfb8a73f2b18e500d480eca98ad2eb3 100644
--- a/chrome/test/base/in_process_browser_test.cc
+++ b/chrome/test/base/in_process_browser_test.cc
@@ -19,6 +19,7 @@
#include "base/thread_task_runner_handle.h"
#include "base/threading/non_thread_safe.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/net/net_error_tab_helper.h"
#include "chrome/browser/profiles/profile.h"
@@ -382,6 +383,32 @@ void InProcessBrowserTest::TearDown() {
BrowserTestBase::TearDown();
}
+void InProcessBrowserTest::CloseBrowserSynchronously(Browser* browser) {
+ content::WindowedNotificationObserver observer(
+ chrome::NOTIFICATION_BROWSER_CLOSED,
+ content::Source<Browser>(browser));
+ CloseBrowserAsynchronously(browser);
+ observer.Wait();
+}
+
+void InProcessBrowserTest::CloseBrowserAsynchronously(Browser* browser) {
+ browser->window()->Close();
+#if defined(OS_MACOSX)
+ // BrowserWindowController depends on the auto release pool being recycled
+ // in the message loop to delete itself.
+ AutoreleasePool()->Recycle();
+#endif
+}
+
+void InProcessBrowserTest::CloseAllBrowsers() {
+ chrome::CloseAllBrowsers();
+#if defined(OS_MACOSX)
+ // BrowserWindowController depends on the auto release pool being recycled
+ // in the message loop to delete itself.
+ AutoreleasePool()->Recycle();
+#endif
+}
+
// TODO(alexmos): This function should expose success of the underlying
// navigation to tests, which should make sure navigations succeed when
// appropriate. See https://crbug.com/425335
« no previous file with comments | « chrome/test/base/in_process_browser_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698