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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/scoped_handle.h" | 7 #include "base/scoped_handle.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/installer/util/browser_distribution.h" | 9 #include "chrome/installer/util/browser_distribution.h" |
10 #include "chrome/installer/util/google_update_constants.h" | 10 #include "chrome/installer/util/google_update_constants.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 131 } |
132 } | 132 } |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 namespace { | 136 namespace { |
137 bool SetUninstallArguments(HKEY root, BrowserDistribution* dist, | 137 bool SetUninstallArguments(HKEY root, BrowserDistribution* dist, |
138 const CommandLine& args) { | 138 const CommandLine& args) { |
139 RegKey key(root, dist->GetStateKey().c_str(), KEY_ALL_ACCESS); | 139 RegKey key(root, dist->GetStateKey().c_str(), KEY_ALL_ACCESS); |
140 return key.WriteValue(installer::kUninstallArgumentsField, | 140 return key.WriteValue(installer::kUninstallArgumentsField, |
141 args.command_line_string().c_str()); | 141 args.command_line_string().c_str()) == ERROR_SUCCESS; |
142 } | 142 } |
143 | 143 |
144 bool SetInstalledVersion(HKEY root, BrowserDistribution* dist, | 144 bool SetInstalledVersion(HKEY root, BrowserDistribution* dist, |
145 const std::wstring& version) { | 145 const std::wstring& version) { |
146 RegKey key(root, dist->GetVersionKey().c_str(), KEY_ALL_ACCESS); | 146 RegKey key(root, dist->GetVersionKey().c_str(), KEY_ALL_ACCESS); |
147 return key.WriteValue(google_update::kRegVersionField, version.c_str()); | 147 LONG ret = key.WriteValue(google_update::kRegVersionField, version.c_str()); |
| 148 return ret == ERROR_SUCCESS; |
148 } | 149 } |
149 } // end namespace | 150 } // end namespace |
150 | 151 |
151 TEST_F(PackageTest, Dependency) { | 152 TEST_F(PackageTest, Dependency) { |
152 const bool multi_install = false; | 153 const bool multi_install = false; |
153 const bool system_level = true; | 154 const bool system_level = true; |
154 HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 155 HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
155 TempRegKeyOverride override(root, L"root_dep"); | 156 TempRegKeyOverride override(root, L"root_dep"); |
156 | 157 |
157 ChromePackageProperties properties; | 158 ChromePackageProperties properties; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 scoped_refptr<Product> product(new Product(distribution, package.get())); | 204 scoped_refptr<Product> product(new Product(distribution, package.get())); |
204 RegKey key; | 205 RegKey key; |
205 std::wstring launch_cmd = L"hey diddle diddle"; | 206 std::wstring launch_cmd = L"hey diddle diddle"; |
206 std::wstring value; | 207 std::wstring value; |
207 | 208 |
208 // check results for single Chrome | 209 // check results for single Chrome |
209 { | 210 { |
210 TempRegKeyOverride override(root, L"root_inst_res"); | 211 TempRegKeyOverride override(root, L"root_inst_res"); |
211 package->WriteInstallerResult(installer::FIRST_INSTALL_SUCCESS, 0, | 212 package->WriteInstallerResult(installer::FIRST_INSTALL_SUCCESS, 0, |
212 &launch_cmd); | 213 &launch_cmd); |
213 EXPECT_TRUE(key.Open(root, distribution->GetStateKey().c_str(), KEY_READ)); | 214 EXPECT_EQ(ERROR_SUCCESS, |
214 EXPECT_TRUE(key.ReadValue(installer::kInstallerSuccessLaunchCmdLine, | 215 key.Open(root, distribution->GetStateKey().c_str(), KEY_READ)); |
215 &value)); | 216 EXPECT_EQ(ERROR_SUCCESS, |
| 217 key.ReadValue(installer::kInstallerSuccessLaunchCmdLine, &value)); |
216 EXPECT_EQ(launch_cmd, value); | 218 EXPECT_EQ(launch_cmd, value); |
217 key.Close(); | 219 key.Close(); |
218 } | 220 } |
219 TempRegKeyOverride::DeleteAllTempKeys(); | 221 TempRegKeyOverride::DeleteAllTempKeys(); |
220 | 222 |
221 // check results for multi Chrome | 223 // check results for multi Chrome |
222 multi_install = true; | 224 multi_install = true; |
223 package = new Package(multi_install, system_level, test_dir_.path(), | 225 package = new Package(multi_install, system_level, test_dir_.path(), |
224 &properties); | 226 &properties); |
225 product = new Product(distribution, package.get()); | 227 product = new Product(distribution, package.get()); |
226 { | 228 { |
227 TempRegKeyOverride override(root, L"root_inst_res"); | 229 TempRegKeyOverride override(root, L"root_inst_res"); |
228 package->WriteInstallerResult(installer::FIRST_INSTALL_SUCCESS, 0, | 230 package->WriteInstallerResult(installer::FIRST_INSTALL_SUCCESS, 0, |
229 &launch_cmd); | 231 &launch_cmd); |
230 EXPECT_TRUE(key.Open(root, distribution->GetStateKey().c_str(), KEY_READ)); | 232 EXPECT_EQ(ERROR_SUCCESS, |
231 EXPECT_TRUE(key.ReadValue(installer::kInstallerSuccessLaunchCmdLine, | 233 key.Open(root, distribution->GetStateKey().c_str(), KEY_READ)); |
232 &value)); | 234 EXPECT_EQ(ERROR_SUCCESS, |
| 235 key.ReadValue(installer::kInstallerSuccessLaunchCmdLine, &value)); |
233 EXPECT_EQ(launch_cmd, value); | 236 EXPECT_EQ(launch_cmd, value); |
234 EXPECT_EQ(properties.ReceivesUpdates(), | 237 bool receive_update_setting = key.Open(root, |
235 key.Open(root, properties.GetStateKey().c_str(), KEY_READ)); | 238 properties.GetStateKey().c_str(), |
| 239 KEY_READ) == ERROR_SUCCESS; |
| 240 EXPECT_EQ(properties.ReceivesUpdates(), receive_update_setting); |
236 if (properties.ReceivesUpdates()) { | 241 if (properties.ReceivesUpdates()) { |
237 EXPECT_TRUE(key.ReadValue(installer::kInstallerSuccessLaunchCmdLine, | 242 EXPECT_EQ(ERROR_SUCCESS, |
238 &value)); | 243 key.ReadValue(installer::kInstallerSuccessLaunchCmdLine, &value)); |
239 EXPECT_EQ(launch_cmd, value); | 244 EXPECT_EQ(launch_cmd, value); |
240 } | 245 } |
241 key.Close(); | 246 key.Close(); |
242 } | 247 } |
243 TempRegKeyOverride::DeleteAllTempKeys(); | 248 TempRegKeyOverride::DeleteAllTempKeys(); |
244 } | 249 } |
OLD | NEW |