diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-01 16:17:12 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-01 16:17:12 +0000 |
commit | e0f29ef841dc384925edbea6223894f804a0c969 (patch) | |
tree | 2b76ea7e76ed191f573f4fb17033ad3cb912ba6a | |
parent | eb64fdf34ac3fb33a0bf91a4e030164c75613fbc (diff) | |
download | chromium_src-e0f29ef841dc384925edbea6223894f804a0c969.zip chromium_src-e0f29ef841dc384925edbea6223894f804a0c969.tar.gz chromium_src-e0f29ef841dc384925edbea6223894f804a0c969.tar.bz2 |
Redirect USER_DATA_DIR for GoogleUpdateTest and FirstRunTest.
They used to write to the default user data dir, which breaks test isolation and is flaky due to leaking state.
BUG=chromium:146032
TEST=unit tests
Review URL: https://chromiumcodereview.appspot.com/10909037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154618 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/first_run/first_run_unittest.cc | 17 | ||||
-rw-r--r-- | chrome/browser/google/google_update_settings_unittest.cc | 18 |
2 files changed, 34 insertions, 1 deletions
diff --git a/chrome/browser/first_run/first_run_unittest.cc b/chrome/browser/first_run/first_run_unittest.cc index 601416c..9876d55 100644 --- a/chrome/browser/first_run/first_run_unittest.cc +++ b/chrome/browser/first_run/first_run_unittest.cc @@ -2,18 +2,33 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/basictypes.h" +#include "base/compiler_specific.h" #include "base/file_util.h" +#include "base/path_service.h" +#include "base/scoped_temp_dir.h" #include "chrome/browser/first_run/first_run.h" #include "chrome/browser/first_run/first_run_internal.h" +#include "chrome/common/chrome_paths.h" #include "testing/gtest/include/gtest/gtest.h" class FirstRunTest : public testing::Test { protected: - virtual void SetUp() { + FirstRunTest() {} + virtual ~FirstRunTest() {} + + virtual void SetUp() OVERRIDE { + ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); + PathService::Override(chrome::DIR_USER_DATA, temp_dir_.path()); first_run::internal::GetFirstRunSentinelFilePath(&sentinel_path_); } FilePath sentinel_path_; + + private: + ScopedTempDir temp_dir_; + + DISALLOW_COPY_AND_ASSIGN(FirstRunTest); }; TEST_F(FirstRunTest, RemoveSentinel) { diff --git a/chrome/browser/google/google_update_settings_unittest.cc b/chrome/browser/google/google_update_settings_unittest.cc index 0896a16..245e029 100644 --- a/chrome/browser/google/google_update_settings_unittest.cc +++ b/chrome/browser/google/google_update_settings_unittest.cc @@ -2,12 +2,30 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "base/path_service.h" +#include "base/scoped_temp_dir.h" #include "chrome/browser/google/google_util.h" +#include "chrome/common/chrome_paths.h" #include "chrome/installer/util/google_update_settings.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" class GoogleUpdateTest : public PlatformTest { + protected: + GoogleUpdateTest() {} + virtual ~GoogleUpdateTest() {} + + virtual void SetUp() OVERRIDE { + ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); + PathService::Override(chrome::DIR_USER_DATA, temp_dir_.path()); + } + + private: + ScopedTempDir temp_dir_; + + DISALLOW_COPY_AND_ASSIGN(GoogleUpdateTest); }; TEST_F(GoogleUpdateTest, StatsConsent) { |