diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-27 04:55:06 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-27 04:55:06 +0000 |
commit | 4a5b5695a4cc32bcbc0e396111b34e692bf9b809 (patch) | |
tree | 1921d1c9e9bc4fe51b505e15e1ebc2ba8ddc9df1 /chrome/test/unit | |
parent | 4d6be6cea9b673149b6ad9668a1c58ec8b5d9234 (diff) | |
download | chromium_src-4a5b5695a4cc32bcbc0e396111b34e692bf9b809.zip chromium_src-4a5b5695a4cc32bcbc0e396111b34e692bf9b809.tar.gz chromium_src-4a5b5695a4cc32bcbc0e396111b34e692bf9b809.tar.bz2 |
Don't delete the user profile directory for tests that ran with --user-data-dir.
Committing for rsimha@chromium.org. Original review: http://codereview.chromium.org/1739007/show
Added a boolean field to class ChromeTestSuite, called "created_user_data_dir_". It defaults to false, and is set to true if no value is passed for --user_data_dir via command line. If the flag is false, the directory specified by the user is not deleted after test execution, and if it is true, the directory is deleted, as it always has been.
Note: user_data_dir is emptied before test execution -- this behavior remains unaltered.
BUG=42374
TEST=User profile directory still exists after running a test with --user-data-dir.
Review URL: http://codereview.chromium.org/1755009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45673 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/unit')
-rw-r--r-- | chrome/test/unit/chrome_test_suite.h | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/chrome/test/unit/chrome_test_suite.h b/chrome/test/unit/chrome_test_suite.h index 3529801..99747f8 100644 --- a/chrome/test/unit/chrome_test_suite.h +++ b/chrome/test/unit/chrome_test_suite.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -36,9 +36,7 @@ #include "base/shared_memory.h" #endif -namespace { - -void RemoveSharedMemoryFile(std::string& filename) { +static void RemoveSharedMemoryFile(const std::string& filename) { // Stats uses SharedMemory under the hood. On posix, this results in a file // on disk. #if defined(OS_POSIX) @@ -47,9 +45,6 @@ void RemoveSharedMemoryFile(std::string& filename) { #endif } -} // namespace - - // In many cases it may be not obvious that a test makes a real DNS lookup. // We generally don't want to rely on external DNS servers for our tests, // so this host resolver procedure catches external queries. @@ -88,7 +83,8 @@ class ChromeTestSuite : public TestSuite { public: ChromeTestSuite(int argc, char** argv) : TestSuite(argc, argv), - stats_table_(NULL) { + stats_table_(NULL), + created_user_data_dir_(false) { } protected: @@ -117,6 +113,7 @@ class ChromeTestSuite : public TestSuite { file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("chrome_test_"), &user_data_dir)) { user_data_dir = user_data_dir.AppendASCII("test_user_data"); + created_user_data_dir_ = true; } if (!user_data_dir.empty()) PathService::Override(chrome::DIR_USER_DATA, user_data_dir); @@ -164,8 +161,11 @@ class ChromeTestSuite : public TestSuite { RemoveSharedMemoryFile(stats_filename_); // Delete the test_user_data dir recursively + // NOTE: user_data_dir will be deleted only if it was automatically + // created. FilePath user_data_dir; - if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir) && + if (created_user_data_dir_ && + PathService::Get(chrome::DIR_USER_DATA, &user_data_dir) && !user_data_dir.empty()) { file_util::Delete(user_data_dir, true); file_util::Delete(user_data_dir.DirName(), false); @@ -188,6 +188,9 @@ class ChromeTestSuite : public TestSuite { ScopedOleInitializer ole_initializer_; scoped_refptr<WarningHostResolverProc> host_resolver_proc_; net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_; + + // Flag indicating whether user_data_dir was automatically created or not. + bool created_user_data_dir_; }; #endif // CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_ |