summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-14 19:22:43 +0000
committerrdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-14 19:22:43 +0000
commit10f6b14ab493ff65e7fecb893537bd15c36f9c37 (patch)
tree558539222a941c402a7d2d1d614f766fae32472d
parenta98677335ad72347d7d8efe062ebede2a70beb41 (diff)
downloadchromium_src-10f6b14ab493ff65e7fecb893537bd15c36f9c37.zip
chromium_src-10f6b14ab493ff65e7fecb893537bd15c36f9c37.tar.gz
chromium_src-10f6b14ab493ff65e7fecb893537bd15c36f9c37.tar.bz2
Enable UserDataDir selection in InProcessBrowserTest
Changed InProcessBrowserTest to allow us to use SetUpCommandLine to specify a UserDataDir via the kUserDataDir switch. It appears this was intended in the original code, since CreateUserDataDirectory currently checks the commandline for the presence of kUserDataDir. BUG=122883 TEST=None Review URL: http://codereview.chromium.org/10037023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132347 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/extension_browsertest.h1
-rw-r--r--chrome/browser/extensions/extension_startup_browsertest.cc40
-rw-r--r--chrome/test/base/in_process_browser_test.cc18
3 files changed, 31 insertions, 28 deletions
diff --git a/chrome/browser/extensions/extension_browsertest.h b/chrome/browser/extensions/extension_browsertest.h
index 2ae201f..6058184 100644
--- a/chrome/browser/extensions/extension_browsertest.h
+++ b/chrome/browser/extensions/extension_browsertest.h
@@ -27,6 +27,7 @@ class ExtensionBrowserTest
ExtensionBrowserTest();
virtual ~ExtensionBrowserTest();
+ // InProcessBrowserTest
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
const Extension* LoadExtension(const FilePath& path);
diff --git a/chrome/browser/extensions/extension_startup_browsertest.cc b/chrome/browser/extensions/extension_startup_browsertest.cc
index 37757451..d2a5f53 100644
--- a/chrome/browser/extensions/extension_startup_browsertest.cc
+++ b/chrome/browser/extensions/extension_startup_browsertest.cc
@@ -38,6 +38,18 @@ class ExtensionStartupTestBase : public InProcessBrowserTest {
virtual void SetUpCommandLine(CommandLine* command_line) {
EnableDOMAutomation();
+ if (!enable_extensions_)
+ command_line->AppendSwitch(switches::kDisableExtensions);
+
+ if (!load_extensions_.empty()) {
+ FilePath::StringType paths = JoinString(load_extensions_, ',');
+ command_line->AppendSwitchNative(switches::kLoadExtension,
+ paths);
+ command_line->AppendSwitch(switches::kDisableExtensionsFileAccessCheck);
+ }
+ }
+
+ virtual bool SetUpUserDataDirectory() {
FilePath profile_dir;
PathService::Get(chrome::DIR_USER_DATA, &profile_dir);
profile_dir = profile_dir.AppendASCII("Default");
@@ -47,27 +59,17 @@ class ExtensionStartupTestBase : public InProcessBrowserTest {
user_scripts_dir_ = profile_dir.AppendASCII("User Scripts");
extensions_dir_ = profile_dir.AppendASCII("Extensions");
- if (enable_extensions_) {
- if (load_extensions_.empty()) {
- FilePath src_dir;
- PathService::Get(chrome::DIR_TEST_DATA, &src_dir);
- src_dir = src_dir.AppendASCII("extensions").AppendASCII("good");
-
- file_util::CopyFile(src_dir.AppendASCII("Preferences"),
- preferences_file_);
- file_util::CopyDirectory(src_dir.AppendASCII("Extensions"),
- profile_dir, true); // recursive
- }
- } else {
- command_line->AppendSwitch(switches::kDisableExtensions);
- }
+ if (enable_extensions_ && load_extensions_.empty()) {
+ FilePath src_dir;
+ PathService::Get(chrome::DIR_TEST_DATA, &src_dir);
+ src_dir = src_dir.AppendASCII("extensions").AppendASCII("good");
- if (!load_extensions_.empty()) {
- FilePath::StringType paths = JoinString(load_extensions_, ',');
- command_line->AppendSwitchNative(switches::kLoadExtension,
- paths);
- command_line->AppendSwitch(switches::kDisableExtensionsFileAccessCheck);
+ file_util::CopyFile(src_dir.AppendASCII("Preferences"),
+ preferences_file_);
+ file_util::CopyDirectory(src_dir.AppendASCII("Extensions"),
+ profile_dir, true); // recursive
}
+ return true;
}
virtual void TearDown() {
diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc
index ebce6ca..f29448b 100644
--- a/chrome/test/base/in_process_browser_test.cc
+++ b/chrome/test/base/in_process_browser_test.cc
@@ -87,27 +87,27 @@ InProcessBrowserTest::~InProcessBrowserTest() {
}
void InProcessBrowserTest::SetUp() {
- // Create a temporary user data directory if required.
- ASSERT_TRUE(CreateUserDataDirectory())
- << "Could not create user data directory.";
-
// Undo TestingBrowserProcess creation in ChromeTestSuite.
// TODO(phajdan.jr): Extract a smaller test suite so we don't need this.
DCHECK(g_browser_process);
delete g_browser_process;
g_browser_process = NULL;
- // Allow subclasses the opportunity to make changes to the default user data
- // dir before running any tests.
- ASSERT_TRUE(SetUpUserDataDirectory())
- << "Could not set up user data directory.";
-
CommandLine* command_line = CommandLine::ForCurrentProcess();
// Allow subclasses to change the command line before running any tests.
SetUpCommandLine(command_line);
// Add command line arguments that are used by all InProcessBrowserTests.
PrepareTestCommandLine(command_line);
+ // Create a temporary user data directory if required.
+ ASSERT_TRUE(CreateUserDataDirectory())
+ << "Could not create user data directory.";
+
+ // Allow subclasses the opportunity to make changes to the default user data
+ // dir before running any tests.
+ 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)) {