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

Unified Diff: chrome/browser/browser_uitest.cc

Issue 255036: Adding a SIGTERM handler for OS_POSIX builds. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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/browser/browser_main.cc ('k') | chrome/test/ui/ui_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser_uitest.cc
===================================================================
--- chrome/browser/browser_uitest.cc (revision 27997)
+++ chrome/browser/browser_uitest.cc (working copy)
@@ -23,7 +23,49 @@
namespace {
+// Delay to let the browser shut down before trying more brutal methods.
+static const int kWaitForTerminateMsec = 30000;
+
class BrowserTest : public UITest {
+
+ protected:
+ void TerminateBrowser() {
+#if defined(OS_WIN)
+ scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser->TerminateSession());
+#elif defined(OS_POSIX)
+ // There's nothing to do here if the browser is not running.
+ if (IsBrowserRunning()) {
+ automation()->SetFilteredInet(false);
+
+ int window_count = 0;
+ EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count));
+
+ // Now, drop the automation IPC channel so that the automation provider in
+ // the browser notices and drops its reference to the browser process.
+ automation()->Disconnect();
+
+ EXPECT_EQ(kill(process_, SIGTERM), 0);
+
+ // Wait for the browser process to quit. It should have quit when it got
+ // SIGTERM.
+ int timeout = kWaitForTerminateMsec;
+#ifdef WAIT_FOR_DEBUGGER_ON_OPEN
+ timeout = 500000;
+#endif
+ if (!base::WaitForSingleProcess(process_, timeout)) {
+ // We need to force the browser to quit because it didn't quit fast
+ // enough. Take no chance and kill every chrome processes.
+ CleanupAppProcesses();
+ }
+
+ // Don't forget to close the handle
+ base::CloseProcessHandle(process_);
+ process_ = NULL;
+ }
+#endif // OS_POSIX
+ }
+
};
class VisibleBrowserTest : public UITest {
@@ -36,14 +78,18 @@
#if defined(OS_WIN)
// The browser should quit quickly if it receives a WM_ENDSESSION message.
TEST_F(BrowserTest, WindowsSessionEnd) {
+#elif defined(OS_POSIX)
+// The browser should quit gracefully and quickly if it receives a SIGTERM.
+TEST_F(BrowserTest, PosixSessionEnd) {
+#endif
+#if defined(OS_WIN) || defined(OS_POSIX)
FilePath test_file(test_data_directory_);
test_file = test_file.AppendASCII("title1.html");
NavigateToURL(net::FilePathToFileURL(test_file));
PlatformThread::Sleep(action_timeout_ms());
- scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
- ASSERT_TRUE(browser->TerminateSession());
+ TerminateBrowser();
PlatformThread::Sleep(action_timeout_ms());
ASSERT_FALSE(IsBrowserRunning());
@@ -69,7 +115,7 @@
&exited_cleanly));
ASSERT_TRUE(exited_cleanly);
}
-#endif
+#endif // OS_WIN || OS_POSIX
// Test that scripts can fork a new renderer process for a tab in a particular
// case (which matches following a link in Gmail). The script must open a new
« no previous file with comments | « chrome/browser/browser_main.cc ('k') | chrome/test/ui/ui_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698