| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/installer/util/product_unittest.h" | 5 #include "chrome/installer/util/product_unittest.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/installer/util/chrome_frame_distribution.h" | 9 #include "chrome/installer/util/chrome_frame_distribution.h" |
| 10 #include "chrome/installer/util/google_update_constants.h" | 10 #include "chrome/installer/util/google_update_constants.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 //////////////////////////////////////////////////////////////////////////////// | 47 //////////////////////////////////////////////////////////////////////////////// |
| 48 const wchar_t TempRegKeyOverride::kTempTestKeyPath[] = | 48 const wchar_t TempRegKeyOverride::kTempTestKeyPath[] = |
| 49 L"Software\\Chromium\\TempTestKeys"; | 49 L"Software\\Chromium\\TempTestKeys"; |
| 50 | 50 |
| 51 TempRegKeyOverride::TempRegKeyOverride(HKEY override, const wchar_t* temp_name) | 51 TempRegKeyOverride::TempRegKeyOverride(HKEY override, const wchar_t* temp_name) |
| 52 : override_(override), temp_name_(temp_name) { | 52 : override_(override), temp_name_(temp_name) { |
| 53 DCHECK(temp_name && lstrlenW(temp_name)); | 53 DCHECK(temp_name && lstrlenW(temp_name)); |
| 54 std::wstring key_path(kTempTestKeyPath); | 54 std::wstring key_path(kTempTestKeyPath); |
| 55 key_path += L"\\" + temp_name_; | 55 key_path += L"\\" + temp_name_; |
| 56 EXPECT_TRUE(temp_key_.Create(HKEY_CURRENT_USER, key_path.c_str(), | 56 EXPECT_EQ(ERROR_SUCCESS, |
| 57 KEY_ALL_ACCESS)); | 57 temp_key_.Create(HKEY_CURRENT_USER, key_path.c_str(), KEY_ALL_ACCESS)); |
| 58 EXPECT_EQ(ERROR_SUCCESS, | 58 EXPECT_EQ(ERROR_SUCCESS, |
| 59 ::RegOverridePredefKey(override_, temp_key_.Handle())); | 59 ::RegOverridePredefKey(override_, temp_key_.Handle())); |
| 60 } | 60 } |
| 61 | 61 |
| 62 TempRegKeyOverride::~TempRegKeyOverride() { | 62 TempRegKeyOverride::~TempRegKeyOverride() { |
| 63 ::RegOverridePredefKey(override_, NULL); | 63 ::RegOverridePredefKey(override_, NULL); |
| 64 // The temp key will be deleted via a call to DeleteAllTempKeys(). | 64 // The temp key will be deleted via a call to DeleteAllTempKeys(). |
| 65 } | 65 } |
| 66 | 66 |
| 67 // static | 67 // static |
| 68 void TempRegKeyOverride::DeleteAllTempKeys() { | 68 void TempRegKeyOverride::DeleteAllTempKeys() { |
| 69 RegKey key; | 69 RegKey key; |
| 70 if (key.Open(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS)) { | 70 if (key.Open(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS) == ERROR_SUCCESS) { |
| 71 key.DeleteKey(kTempTestKeyPath); | 71 key.DeleteKey(kTempTestKeyPath); |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 //////////////////////////////////////////////////////////////////////////////// | 75 //////////////////////////////////////////////////////////////////////////////// |
| 76 | 76 |
| 77 class ProductTest : public TestWithTempDirAndDeleteTempOverrideKeys { | 77 class ProductTest : public TestWithTempDirAndDeleteTempOverrideKeys { |
| 78 protected: | 78 protected: |
| 79 }; | 79 }; |
| 80 | 80 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 107 // We started out with a non-msi product. | 107 // We started out with a non-msi product. |
| 108 EXPECT_FALSE(product->IsMsi()); | 108 EXPECT_FALSE(product->IsMsi()); |
| 109 | 109 |
| 110 HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 110 HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 111 { | 111 { |
| 112 TempRegKeyOverride override(root, L"root_pit"); | 112 TempRegKeyOverride override(root, L"root_pit"); |
| 113 | 113 |
| 114 // Create a make-believe client state key. | 114 // Create a make-believe client state key. |
| 115 RegKey key; | 115 RegKey key; |
| 116 std::wstring state_key_path(distribution->GetStateKey()); | 116 std::wstring state_key_path(distribution->GetStateKey()); |
| 117 ASSERT_TRUE(key.Create(root, state_key_path.c_str(), KEY_ALL_ACCESS)); | 117 ASSERT_EQ(ERROR_SUCCESS, |
| 118 key.Create(root, state_key_path.c_str(), KEY_ALL_ACCESS)); |
| 118 | 119 |
| 119 // Set the MSI marker, delete the objects, create new ones and verify | 120 // Set the MSI marker, delete the objects, create new ones and verify |
| 120 // that we now see the MSI marker. | 121 // that we now see the MSI marker. |
| 121 EXPECT_TRUE(product->SetMsiMarker(true)); | 122 EXPECT_TRUE(product->SetMsiMarker(true)); |
| 122 package = new Package(multi_install, system_level, test_dir_.path(), | 123 package = new Package(multi_install, system_level, test_dir_.path(), |
| 123 &properties); | 124 &properties); |
| 124 product = new Product(distribution, package.get()); | 125 product = new Product(distribution, package.get()); |
| 125 EXPECT_TRUE(product->IsMsi()); | 126 EXPECT_TRUE(product->IsMsi()); |
| 126 | 127 |
| 127 // There should be no installed version in the registry. | 128 // There should be no installed version in the registry. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 193 |
| 193 installs.AddDistribution(BrowserDistribution::CHROME_BROWSER, prefs); | 194 installs.AddDistribution(BrowserDistribution::CHROME_BROWSER, prefs); |
| 194 FakeChromeFrameDistribution fake_chrome_frame(prefs); | 195 FakeChromeFrameDistribution fake_chrome_frame(prefs); |
| 195 installs.AddDistribution(&fake_chrome_frame); | 196 installs.AddDistribution(&fake_chrome_frame); |
| 196 EXPECT_EQ(2U, installs.products().size()); | 197 EXPECT_EQ(2U, installs.products().size()); |
| 197 // Since our fake Chrome Frame distribution class is reporting the same | 198 // Since our fake Chrome Frame distribution class is reporting the same |
| 198 // installation directory as Chrome, we should have only one package object. | 199 // installation directory as Chrome, we should have only one package object. |
| 199 EXPECT_EQ(1U, installs.packages().size()); | 200 EXPECT_EQ(1U, installs.packages().size()); |
| 200 EXPECT_EQ(multi_install, installs.packages()[0]->multi_install()); | 201 EXPECT_EQ(multi_install, installs.packages()[0]->multi_install()); |
| 201 } | 202 } |
| OLD | NEW |