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