Index: chrome/browser/rlz/rlz_unittest.cc |
diff --git a/chrome/browser/rlz/rlz_unittest.cc b/chrome/browser/rlz/rlz_unittest.cc |
index 0726ce261178579328e9bd15e350d320d2cb0dfc..198c62a650f3e8c187d05b56e3c101b47aba1b73 100644 |
--- a/chrome/browser/rlz/rlz_unittest.cc |
+++ b/chrome/browser/rlz/rlz_unittest.cc |
@@ -4,32 +4,23 @@ |
#include "chrome/browser/rlz/rlz.h" |
-#include "base/files/scoped_temp_dir.h" |
#include "base/memory/scoped_ptr.h" |
-#include "base/message_loop/message_loop.h" |
-#include "base/path_service.h" |
-#include "base/strings/stringprintf.h" |
#include "base/strings/utf_string_conversions.h" |
-#include "base/threading/thread.h" |
#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/google/google_util.h" |
#include "chrome/browser/omnibox/omnibox_log.h" |
#include "chrome/browser/profiles/profile.h" |
-#include "chrome/common/env_vars.h" |
#include "chrome/installer/util/browser_distribution.h" |
#include "chrome/installer/util/google_update_constants.h" |
#include "content/public/browser/navigation_entry.h" |
#include "content/public/browser/notification_details.h" |
#include "content/public/browser/notification_service.h" |
#include "content/public/browser/notification_source.h" |
+#include "rlz/test/rlz_test_helpers.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#if defined(OS_WIN) |
-#include "base/test/test_reg_util_win.h" |
#include "base/win/registry.h" |
-#include "rlz/win/lib/rlz_lib.h" // InitializeTempHivesForTesting |
-#elif defined(OS_POSIX) |
-#include "rlz/lib/rlz_value_store.h" // SetRlzStoreDirectory |
#endif |
using content::NavigationEntry; |
@@ -39,17 +30,10 @@ using testing::AssertionFailure; |
#if defined(OS_WIN) |
using base::win::RegKey; |
-using registry_util::RegistryOverrideManager; |
#endif |
namespace { |
-#if defined(OS_WIN) |
-// Registry path to overridden hive. |
-const wchar_t kRlzTempHkcu[] = L"rlz_hkcu"; |
-const wchar_t kRlzTempHklm[] = L"rlz_hklm"; |
-#endif |
- |
// Dummy RLZ string for the access points. |
const char kOmniboxRlzString[] = "test_omnibox"; |
const char kHomepageRlzString[] = "test_homepage"; |
@@ -170,12 +154,10 @@ class TestRLZTracker : public RLZTracker { |
DISALLOW_COPY_AND_ASSIGN(TestRLZTracker); |
}; |
-class RlzLibTest : public testing::Test { |
- public: |
+class RlzLibTest : public RlzLibTestNoMachineState { |
+ protected: |
virtual void SetUp() OVERRIDE; |
- virtual void TearDown() OVERRIDE; |
- protected: |
void SetMainBrand(const char* brand); |
void SetReactivationBrand(const char* brand); |
#if defined(OS_WIN) |
@@ -191,52 +173,13 @@ class RlzLibTest : public testing::Test { |
void ExpectReactivationRlzPingSent(bool expected); |
TestRLZTracker tracker_; |
-#if defined(OS_WIN) |
- RegistryOverrideManager override_manager_; |
-#elif defined(OS_POSIX) |
- base::ScopedTempDir temp_dir_; |
+#if defined(OS_POSIX) |
scoped_ptr<google_util::BrandForTesting> brand_override_; |
#endif |
}; |
void RlzLibTest::SetUp() { |
- testing::Test::SetUp(); |
- |
-#if defined(OS_WIN) |
- // Before overriding HKLM for the tests, we need to set it up correctly |
- // so that the rlz_lib calls work. This needs to be done before we do the |
- // override. |
- |
- string16 temp_hklm_path = base::StringPrintf( |
- L"%ls\\%ls", |
- RegistryOverrideManager::kTempTestKeyPath, |
- kRlzTempHklm); |
- |
- base::win::RegKey hklm; |
- ASSERT_EQ(ERROR_SUCCESS, hklm.Create(HKEY_CURRENT_USER, |
- temp_hklm_path.c_str(), |
- KEY_READ)); |
- |
- string16 temp_hkcu_path = base::StringPrintf( |
- L"%ls\\%ls", |
- RegistryOverrideManager::kTempTestKeyPath, |
- kRlzTempHkcu); |
- |
- base::win::RegKey hkcu; |
- ASSERT_EQ(ERROR_SUCCESS, hkcu.Create(HKEY_CURRENT_USER, |
- temp_hkcu_path.c_str(), |
- KEY_READ)); |
- |
- rlz_lib::InitializeTempHivesForTesting(hklm, hkcu); |
- |
- // Its important to override HKLM before HKCU because of the registry |
- // initialization performed above. |
- override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE, kRlzTempHklm); |
- override_manager_.OverrideRegistry(HKEY_CURRENT_USER, kRlzTempHkcu); |
-#elif defined(OS_POSIX) |
- ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
- rlz_lib::testing::SetRlzStoreDirectory(temp_dir_.path()); |
-#endif |
+ RlzLibTestNoMachineState::SetUp(); |
// Make sure a non-organic brand code is set in the registry or the RLZTracker |
// is pretty much a no-op. |
@@ -244,13 +187,6 @@ void RlzLibTest::SetUp() { |
SetReactivationBrand(""); |
} |
-void RlzLibTest::TearDown() { |
-#if defined(OS_POSIX) |
- rlz_lib::testing::SetRlzStoreDirectory(base::FilePath()); |
-#endif |
- testing::Test::TearDown(); |
-} |
- |
void RlzLibTest::SetMainBrand(const char* brand) { |
#if defined(OS_WIN) |
SetRegistryBrandValue(google_update::kRegRLZBrandField, brand); |