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

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

Issue 190663012: Run ContentMain in a browser_test's browser process. This removes duplication of code in the browse… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: try to fix android by restoring old path just for it Created 6 years, 9 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/chrome_unit_test_suite.cc ('k') | chrome/test/base/interactive_ui_tests_main.cc » ('j') | 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
===================================================================
--- chrome/test/base/in_process_browser_test.cc (revision 257432)
+++ chrome/test/base/in_process_browser_test.cc (working copy)
@@ -75,10 +75,6 @@
// Passed as value of kTestType.
const char kBrowserTestType[] = "browser";
-// Used when running in single-process mode.
-base::LazyInstance<ChromeContentRendererClient>::Leaky
- g_chrome_content_renderer_client = LAZY_INSTANCE_INITIALIZER;
-
// A BrowserListObserver that makes sure that all browsers created are on the
// |allowed_desktop_|.
class SingleDesktopTestObserver : public chrome::BrowserListObserver,
@@ -133,11 +129,17 @@
chrome_path = chrome_path.Append(chrome::kBrowserProcessExecutablePath);
CHECK(PathService::Override(base::FILE_EXE, chrome_path));
#endif // defined(OS_MACOSX)
+
CreateTestServer(base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
base::FilePath src_dir;
CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir));
- embedded_test_server()->ServeFilesFromDirectory(
- src_dir.AppendASCII("chrome/test/data"));
+ base::FilePath test_data_dir = src_dir.AppendASCII("chrome/test/data");
+ embedded_test_server()->ServeFilesFromDirectory(test_data_dir);
+
+ // chrome::DIR_TEST_DATA isn't going to be setup until after we call
+ // ContentMain. However that is after tests' constructors or SetUp methods,
+ // which sometimes need it. So just override it.
+ CHECK(PathService::Override(chrome::DIR_TEST_DATA, test_data_dir));
}
InProcessBrowserTest::~InProcessBrowserTest() {
@@ -162,13 +164,6 @@
ASSERT_TRUE(SetUpUserDataDirectory())
<< "Could not set up user data directory.";
- // Single-process mode is not set in BrowserMain, so process it explicitly,
- // and set up renderer.
- if (command_line->HasSwitch(switches::kSingleProcess)) {
- content::SetRendererClientForTesting(
- g_chrome_content_renderer_client.Pointer());
- }
-
#if defined(OS_CHROMEOS)
// Make sure that the log directory exists.
base::FilePath log_dir = logging::GetSessionLogFile(*command_line).DirName();
@@ -176,15 +171,6 @@
#endif // defined(OS_CHROMEOS)
#if defined(OS_MACOSX)
- // On Mac, without the following autorelease pool, code which is directly
- // executed (as opposed to executed inside a message loop) would autorelease
- // objects into a higher-level pool. This pool is not recycled in-sync with
- // the message loops' pools and causes problems with code relying on
- // deallocation via an autorelease pool (such as browser window closure and
- // browser shutdown). To avoid this, the following pool is recycled after each
- // time code is directly executed.
- autorelease_pool_ = new base::mac::ScopedNSAutoreleasePool;
-
// Always use the MockKeychain if OS encription is used (which is when
// anything sensitive gets stored, including Cookies). Without this,
// many tests will hang waiting for a user to approve KeyChain access.
@@ -382,10 +368,6 @@
// Pump startup related events.
content::RunAllPendingInMessageLoop();
-#if defined(OS_MACOSX)
- autorelease_pool_->Recycle();
-#endif
-
chrome::HostDesktopType active_desktop = chrome::GetActiveDesktop();
// Self-adds/removes itself from the BrowserList observers.
scoped_ptr<SingleDesktopTestObserver> single_desktop_test_observer;
@@ -413,6 +395,17 @@
ASSERT_TRUE(storage_monitor::TestStorageMonitor::CreateForBrowserTests());
#endif
+#if defined(OS_MACOSX)
+ // On Mac, without the following autorelease pool, code which is directly
+ // executed (as opposed to executed inside a message loop) would autorelease
+ // objects into a higher-level pool. This pool is not recycled in-sync with
+ // the message loops' pools and causes problems with code relying on
+ // deallocation via an autorelease pool (such as browser window closure and
+ // browser shutdown). To avoid this, the following pool is recycled after each
+ // time code is directly executed.
+ autorelease_pool_ = new base::mac::ScopedNSAutoreleasePool;
+#endif
+
// Pump any pending events that were created as a result of creating a
// browser.
content::RunAllPendingInMessageLoop();
« no previous file with comments | « chrome/test/base/chrome_unit_test_suite.cc ('k') | chrome/test/base/interactive_ui_tests_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698