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/setup/install_worker.h" | 5 #include "chrome/installer/setup/install_worker.h" |
6 | 6 |
7 #include "base/win/registry.h" | 7 #include "base/win/registry.h" |
8 #include "base/version.h" | 8 #include "base/version.h" |
9 #include "chrome/common/chrome_constants.h" | 9 #include "chrome/common/chrome_constants.h" |
10 #include "chrome/installer/util/delete_reg_key_work_item.h" | 10 #include "chrome/installer/util/delete_reg_key_work_item.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 InstallerState::set_package_type(type); | 158 InstallerState::set_package_type(type); |
159 } | 159 } |
160 }; | 160 }; |
161 | 161 |
162 // The test fixture | 162 // The test fixture |
163 //------------------------------------------------------------------------------ | 163 //------------------------------------------------------------------------------ |
164 | 164 |
165 class InstallWorkerTest : public testing::Test { | 165 class InstallWorkerTest : public testing::Test { |
166 public: | 166 public: |
167 virtual void SetUp() { | 167 virtual void SetUp() { |
168 current_version_.reset(Version::GetVersionFromString("1.0.0.0")); | 168 current_version_.reset(new Version("1.0.0.0")); |
169 new_version_.reset(Version::GetVersionFromString("42.0.0.0")); | 169 new_version_.reset(new Version("42.0.0.0")); |
170 | 170 |
171 // Don't bother ensuring that these paths exist. Since we're just | 171 // Don't bother ensuring that these paths exist. Since we're just |
172 // building the work item lists and not running them, they shouldn't | 172 // building the work item lists and not running them, they shouldn't |
173 // actually be touched. | 173 // actually be touched. |
174 archive_path_ = FilePath(L"C:\\UnlikelyPath\\Temp\\chrome_123\\chrome.7z"); | 174 archive_path_ = FilePath(L"C:\\UnlikelyPath\\Temp\\chrome_123\\chrome.7z"); |
175 // TODO(robertshield): Take this from the BrowserDistribution once that | 175 // TODO(robertshield): Take this from the BrowserDistribution once that |
176 // no longer depends on MasterPreferences. | 176 // no longer depends on MasterPreferences. |
177 installation_path_ = FilePath(L"C:\\Program Files\\Google\\Chrome\\"); | 177 installation_path_ = FilePath(L"C:\\Program Files\\Google\\Chrome\\"); |
178 src_path_ = | 178 src_path_ = |
179 FilePath(L"C:\\UnlikelyPath\\Temp\\chrome_123\\source\\Chrome-bin"); | 179 FilePath(L"C:\\UnlikelyPath\\Temp\\chrome_123\\source\\Chrome-bin"); |
180 setup_path_ = FilePath(L"C:\\UnlikelyPath\\Temp\\CR_123.tmp\\setup.exe"); | 180 setup_path_ = FilePath(L"C:\\UnlikelyPath\\Temp\\CR_123.tmp\\setup.exe"); |
181 temp_dir_ = FilePath(L"C:\\UnlikelyPath\\Temp\\chrome_123"); | 181 temp_dir_ = FilePath(L"C:\\UnlikelyPath\\Temp\\chrome_123"); |
182 } | 182 } |
183 | 183 |
184 virtual void TearDown() { | 184 virtual void TearDown() { |
185 } | 185 } |
186 | 186 |
187 void MaybeAddBinariesToInstallationState( | 187 void MaybeAddBinariesToInstallationState( |
188 bool system_level, | 188 bool system_level, |
189 MockInstallationState* installation_state) { | 189 MockInstallationState* installation_state) { |
190 if (installation_state->GetProductState( | 190 if (installation_state->GetProductState( |
191 system_level, BrowserDistribution::CHROME_BINARIES) == NULL) { | 191 system_level, BrowserDistribution::CHROME_BINARIES) == NULL) { |
192 MockProductState product_state; | 192 MockProductState product_state; |
193 product_state.set_version(current_version_->Clone()); | 193 product_state.set_version(new Version(*current_version_)); |
194 installation_state->SetProductState(system_level, | 194 installation_state->SetProductState(system_level, |
195 BrowserDistribution::CHROME_BINARIES, | 195 BrowserDistribution::CHROME_BINARIES, |
196 product_state); | 196 product_state); |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 void AddChromeToInstallationState( | 200 void AddChromeToInstallationState( |
201 bool system_level, | 201 bool system_level, |
202 bool multi_install, | 202 bool multi_install, |
203 bool with_chrome_frame_ready_mode, | 203 bool with_chrome_frame_ready_mode, |
204 MockInstallationState* installation_state) { | 204 MockInstallationState* installation_state) { |
205 if (multi_install) | 205 if (multi_install) |
206 MaybeAddBinariesToInstallationState(system_level, installation_state); | 206 MaybeAddBinariesToInstallationState(system_level, installation_state); |
207 MockProductState product_state; | 207 MockProductState product_state; |
208 product_state.set_version(current_version_->Clone()); | 208 product_state.set_version(new Version(*current_version_)); |
209 product_state.set_multi_install(multi_install); | 209 product_state.set_multi_install(multi_install); |
210 product_state.set_brand(L"TEST"); | 210 product_state.set_brand(L"TEST"); |
211 product_state.set_eula_accepted(1); | 211 product_state.set_eula_accepted(1); |
212 BrowserDistribution* dist = | 212 BrowserDistribution* dist = |
213 BrowserDistribution::GetSpecificDistribution( | 213 BrowserDistribution::GetSpecificDistribution( |
214 BrowserDistribution::CHROME_BROWSER); | 214 BrowserDistribution::CHROME_BROWSER); |
215 FilePath install_path = | 215 FilePath install_path = |
216 installer::GetChromeInstallPath(system_level, dist); | 216 installer::GetChromeInstallPath(system_level, dist); |
217 product_state.SetUninstallProgram( | 217 product_state.SetUninstallProgram( |
218 install_path.AppendASCII(current_version_->GetString()) | 218 install_path.AppendASCII(current_version_->GetString()) |
(...skipping 18 matching lines...) Expand all Loading... |
237 } | 237 } |
238 | 238 |
239 void AddChromeFrameToInstallationState( | 239 void AddChromeFrameToInstallationState( |
240 bool system_level, | 240 bool system_level, |
241 bool multi_install, | 241 bool multi_install, |
242 bool ready_mode, | 242 bool ready_mode, |
243 MockInstallationState* installation_state) { | 243 MockInstallationState* installation_state) { |
244 if (multi_install) | 244 if (multi_install) |
245 MaybeAddBinariesToInstallationState(system_level, installation_state); | 245 MaybeAddBinariesToInstallationState(system_level, installation_state); |
246 MockProductState product_state; | 246 MockProductState product_state; |
247 product_state.set_version(current_version_->Clone()); | 247 product_state.set_version(new Version(*current_version_)); |
248 product_state.set_multi_install(multi_install); | 248 product_state.set_multi_install(multi_install); |
249 BrowserDistribution* dist = | 249 BrowserDistribution* dist = |
250 BrowserDistribution::GetSpecificDistribution( | 250 BrowserDistribution::GetSpecificDistribution( |
251 multi_install ? BrowserDistribution::CHROME_BINARIES : | 251 multi_install ? BrowserDistribution::CHROME_BINARIES : |
252 BrowserDistribution::CHROME_FRAME); | 252 BrowserDistribution::CHROME_FRAME); |
253 FilePath install_path = | 253 FilePath install_path = |
254 installer::GetChromeInstallPath(system_level, dist); | 254 installer::GetChromeInstallPath(system_level, dist); |
255 product_state.SetUninstallProgram( | 255 product_state.SetUninstallProgram( |
256 install_path.AppendASCII(current_version_->GetString()) | 256 install_path.AppendASCII(current_version_->GetString()) |
257 .Append(installer::kInstallerDir) | 257 .Append(installer::kInstallerDir) |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 | 491 |
492 TEST_F(InstallWorkerTest, GoogleUpdateWorkItemsTest) { | 492 TEST_F(InstallWorkerTest, GoogleUpdateWorkItemsTest) { |
493 const bool system_level = true; | 493 const bool system_level = true; |
494 const bool multi_install = true; | 494 const bool multi_install = true; |
495 MockWorkItemList work_item_list; | 495 MockWorkItemList work_item_list; |
496 | 496 |
497 scoped_ptr<MockInstallationState> installation_state( | 497 scoped_ptr<MockInstallationState> installation_state( |
498 BuildChromeInstallationState(system_level, false)); | 498 BuildChromeInstallationState(system_level, false)); |
499 | 499 |
500 MockProductState cf_state; | 500 MockProductState cf_state; |
501 cf_state.set_version(current_version_->Clone()); | 501 cf_state.set_version(new Version(*current_version_)); |
502 cf_state.set_multi_install(false); | 502 cf_state.set_multi_install(false); |
503 | 503 |
504 installation_state->SetProductState(system_level, | 504 installation_state->SetProductState(system_level, |
505 BrowserDistribution::CHROME_FRAME, cf_state); | 505 BrowserDistribution::CHROME_FRAME, cf_state); |
506 | 506 |
507 scoped_ptr<MockInstallerState> installer_state( | 507 scoped_ptr<MockInstallerState> installer_state( |
508 BuildChromeInstallerState(system_level, multi_install, | 508 BuildChromeInstallerState(system_level, multi_install, |
509 *installation_state, | 509 *installation_state, |
510 InstallerState::MULTI_INSTALL)); | 510 InstallerState::MULTI_INSTALL)); |
511 | 511 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 // Test that usagestats values are migrated properly. | 564 // Test that usagestats values are migrated properly. |
565 TEST_F(InstallWorkerTest, AddUsageStatsWorkItems) { | 565 TEST_F(InstallWorkerTest, AddUsageStatsWorkItems) { |
566 const bool system_level = true; | 566 const bool system_level = true; |
567 const bool multi_install = true; | 567 const bool multi_install = true; |
568 MockWorkItemList work_item_list; | 568 MockWorkItemList work_item_list; |
569 | 569 |
570 scoped_ptr<MockInstallationState> installation_state( | 570 scoped_ptr<MockInstallationState> installation_state( |
571 BuildChromeInstallationState(system_level, multi_install)); | 571 BuildChromeInstallationState(system_level, multi_install)); |
572 | 572 |
573 MockProductState chrome_state; | 573 MockProductState chrome_state; |
574 chrome_state.set_version(current_version_->Clone()); | 574 chrome_state.set_version(new Version(*current_version_)); |
575 chrome_state.set_multi_install(false); | 575 chrome_state.set_multi_install(false); |
576 chrome_state.set_usagestats(1); | 576 chrome_state.set_usagestats(1); |
577 | 577 |
578 installation_state->SetProductState(system_level, | 578 installation_state->SetProductState(system_level, |
579 BrowserDistribution::CHROME_BROWSER, chrome_state); | 579 BrowserDistribution::CHROME_BROWSER, chrome_state); |
580 | 580 |
581 scoped_ptr<MockInstallerState> installer_state( | 581 scoped_ptr<MockInstallerState> installer_state( |
582 BuildChromeInstallerState(system_level, multi_install, | 582 BuildChromeInstallerState(system_level, multi_install, |
583 *installation_state, | 583 *installation_state, |
584 InstallerState::MULTI_INSTALL)); | 584 InstallerState::MULTI_INSTALL)); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 machine_state_.get()); | 846 machine_state_.get()); |
847 scoped_ptr<MockInstallerState> installer_state( | 847 scoped_ptr<MockInstallerState> installer_state( |
848 BuildBasicInstallerState(system_level_, true, *machine_state_, | 848 BuildBasicInstallerState(system_level_, true, *machine_state_, |
849 InstallerState::UNINSTALL)); | 849 InstallerState::UNINSTALL)); |
850 AddChromeFrameToInstallerState(*machine_state_, false, installer_state.get()); | 850 AddChromeFrameToInstallerState(*machine_state_, false, installer_state.get()); |
851 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, | 851 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, |
852 new_version_.get(), &work_item_list_); | 852 new_version_.get(), &work_item_list_); |
853 } | 853 } |
854 | 854 |
855 #endif // defined(GOOGLE_CHROME_BUILD) | 855 #endif // defined(GOOGLE_CHROME_BUILD) |
OLD | NEW |