Index: chrome/test/unit/chrome_test_suite.h |
=================================================================== |
--- chrome/test/unit/chrome_test_suite.h (revision 45661) |
+++ chrome/test/unit/chrome_test_suite.h (working copy) |
@@ -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 @@ |
#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 @@ |
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 @@ |
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 @@ |
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 @@ |
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_ |