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

Side by Side Diff: chrome/test/base/in_process_browser_test.cc

Issue 10037023: Enable UserDataDir selection in InProcessBrowserTest (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed issues with tests using InProcessBrowserTest Created 8 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/base/in_process_browser_test.h" 5 #include "chrome/test/base/in_process_browser_test.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/stack_trace.h" 10 #include "base/debug/stack_trace.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 test_server_.reset(new net::TestServer( 77 test_server_.reset(new net::TestServer(
78 net::TestServer::TYPE_HTTP, 78 net::TestServer::TYPE_HTTP,
79 net::TestServer::kLocalhost, 79 net::TestServer::kLocalhost,
80 FilePath(FILE_PATH_LITERAL("chrome/test/data")))); 80 FilePath(FILE_PATH_LITERAL("chrome/test/data"))));
81 } 81 }
82 82
83 InProcessBrowserTest::~InProcessBrowserTest() { 83 InProcessBrowserTest::~InProcessBrowserTest() {
84 } 84 }
85 85
86 void InProcessBrowserTest::SetUp() { 86 void InProcessBrowserTest::SetUp() {
87 // Create a temporary user data directory if required.
88 ASSERT_TRUE(CreateUserDataDirectory())
89 << "Could not create user data directory.";
90
91 // Undo TestingBrowserProcess creation in ChromeTestSuite. 87 // Undo TestingBrowserProcess creation in ChromeTestSuite.
92 // TODO(phajdan.jr): Extract a smaller test suite so we don't need this. 88 // TODO(phajdan.jr): Extract a smaller test suite so we don't need this.
93 DCHECK(g_browser_process); 89 DCHECK(g_browser_process);
94 delete g_browser_process; 90 delete g_browser_process;
95 g_browser_process = NULL; 91 g_browser_process = NULL;
96 92
97 // Allow subclasses the opportunity to make changes to the default user data
98 // dir before running any tests.
99 ASSERT_TRUE(SetUpUserDataDirectory())
100 << "Could not set up user data directory.";
101
102 CommandLine* command_line = CommandLine::ForCurrentProcess(); 93 CommandLine* command_line = CommandLine::ForCurrentProcess();
103 // Allow subclasses to change the command line before running any tests. 94 // Allow subclasses to change the command line before running any tests.
104 SetUpCommandLine(command_line); 95 SetUpCommandLine(command_line);
105 // Add command line arguments that are used by all InProcessBrowserTests. 96 // Add command line arguments that are used by all InProcessBrowserTests.
106 PrepareTestCommandLine(command_line); 97 PrepareTestCommandLine(command_line);
107 98
99 // Create a temporary user data directory if required.
100 ASSERT_TRUE(CreateUserDataDirectory())
101 << "Could not create user data directory.";
102
103 // Allow subclasses the opportunity to make changes to the default user data
104 // dir before running any tests.
105 ASSERT_TRUE(SetUpUserDataDirectory())
106 << "Could not set up user data directory.";
107
108 // Single-process mode is not set in BrowserMain, so process it explicitly, 108 // Single-process mode is not set in BrowserMain, so process it explicitly,
109 // and set up renderer. 109 // and set up renderer.
110 if (command_line->HasSwitch(switches::kSingleProcess)) { 110 if (command_line->HasSwitch(switches::kSingleProcess)) {
111 content::RenderProcessHost::set_run_renderer_in_process(true); 111 content::RenderProcessHost::set_run_renderer_in_process(true);
112 single_process_renderer_client_.reset( 112 single_process_renderer_client_.reset(
113 new content::MockContentRendererClient); 113 new content::MockContentRendererClient);
114 content::GetContentClient()->set_renderer( 114 content::GetContentClient()->set_renderer(
115 single_process_renderer_client_.get()); 115 single_process_renderer_client_.get());
116 } 116 }
117 117
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 if (BrowserList::size() == 0) 344 if (BrowserList::size() == 0)
345 return; 345 return;
346 346
347 // Invoke CloseAllBrowsersAndMayExit on a running message loop. 347 // Invoke CloseAllBrowsersAndMayExit on a running message loop.
348 // CloseAllBrowsersAndMayExit exits the message loop after everything has been 348 // CloseAllBrowsersAndMayExit exits the message loop after everything has been
349 // shut down properly. 349 // shut down properly.
350 MessageLoopForUI::current()->PostTask(FROM_HERE, 350 MessageLoopForUI::current()->PostTask(FROM_HERE,
351 base::Bind(&BrowserList::AttemptExit)); 351 base::Bind(&BrowserList::AttemptExit));
352 ui_test_utils::RunMessageLoop(); 352 ui_test_utils::RunMessageLoop();
353 } 353 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698