diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 00:55:22 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 00:55:22 +0000 |
commit | 69c24dc36c245c47c4d2f7488de67ce181e5a7c2 (patch) | |
tree | b0789a47b97f7d20eab8d67348bd32473b47ace7 /chrome/browser/extensions/extension_updater_unittest.cc | |
parent | 92899e21866e90a17e365704ed310b5641423a1e (diff) | |
download | chromium_src-69c24dc36c245c47c4d2f7488de67ce181e5a7c2.zip chromium_src-69c24dc36c245c47c4d2f7488de67ce181e5a7c2.tar.gz chromium_src-69c24dc36c245c47c4d2f7488de67ce181e5a7c2.tar.bz2 |
Cleanup temporary files created by the extension updater unit test.
BUG=None
TEST=Run unit_tests --gtest_filter=ExtensionUpdaterTest.*, make sure there's no extra temporary files after the test finishes.
Review URL: http://codereview.chromium.org/173635
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24996 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_updater_unittest.cc')
-rw-r--r-- | chrome/browser/extensions/extension_updater_unittest.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/chrome/browser/extensions/extension_updater_unittest.cc b/chrome/browser/extensions/extension_updater_unittest.cc index 724d736..266244f 100644 --- a/chrome/browser/extensions/extension_updater_unittest.cc +++ b/chrome/browser/extensions/extension_updater_unittest.cc @@ -60,8 +60,8 @@ class ScopedTempPrefService { ScopedTempPrefService() { // Make sure different tests won't use the same prefs file. It will cause // problem when different tests are running in parallel. - FilePath pref_file = temp_dir_.path().AppendASCII( - StringPrintf("prefs_%lld", base::RandUint64())); + temp_dir_.CreateUniqueTempDir(); + FilePath pref_file = temp_dir_.path().AppendASCII("prefs"); prefs_.reset(new PrefService(pref_file, NULL)); } @@ -72,8 +72,9 @@ class ScopedTempPrefService { } private: - scoped_ptr<PrefService> prefs_; + // Ordering matters, we want |prefs_| to be destroyed before |temp_dir_|. ScopedTempDir temp_dir_; + scoped_ptr<PrefService> prefs_; }; const char* kIdPrefix = "000000000000000000000000000000000000000"; @@ -442,6 +443,7 @@ class ExtensionUpdaterTest : public testing::Test { EXPECT_TRUE(file_util::ReadFileToString(tmpfile_path, &file_contents)); EXPECT_TRUE(extension_data == file_contents); + file_util::Delete(tmpfile_path, false); URLFetcher::set_factory(NULL); } @@ -528,6 +530,7 @@ class ExtensionUpdaterTest : public testing::Test { EXPECT_FALSE(tmpfile_path.empty()); EXPECT_EQ(id1, service.extension_id()); message_loop.RunAllPending(); + file_util::Delete(tmpfile_path, false); // Make sure the second fetch finished and asked the service to do an // update. @@ -546,6 +549,7 @@ class ExtensionUpdaterTest : public testing::Test { EXPECT_TRUE(file_util::ReadFileToString(service.install_path(), &file_contents)); EXPECT_TRUE(extension_data2 == file_contents); + file_util::Delete(service.install_path(), false); } }; |