| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/setup/setup_util.h" | 10 #include "chrome/installer/setup/setup_util.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 product_state.AddUninstallSwitch(installer::switches::kSystemLevel); | 213 product_state.AddUninstallSwitch(installer::switches::kSystemLevel); |
| 214 installation_state->SetProductState(system_level, | 214 installation_state->SetProductState(system_level, |
| 215 BrowserDistribution::CHROME_BINARIES, | 215 BrowserDistribution::CHROME_BINARIES, |
| 216 product_state); | 216 product_state); |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 | 219 |
| 220 void AddChromeToInstallationState( | 220 void AddChromeToInstallationState( |
| 221 bool system_level, | 221 bool system_level, |
| 222 bool multi_install, | 222 bool multi_install, |
| 223 bool with_chrome_frame_ready_mode, | |
| 224 MockInstallationState* installation_state) { | 223 MockInstallationState* installation_state) { |
| 225 if (multi_install) | 224 if (multi_install) |
| 226 MaybeAddBinariesToInstallationState(system_level, installation_state); | 225 MaybeAddBinariesToInstallationState(system_level, installation_state); |
| 227 MockProductState product_state; | 226 MockProductState product_state; |
| 228 product_state.set_version(new Version(*current_version_)); | 227 product_state.set_version(new Version(*current_version_)); |
| 229 product_state.set_multi_install(multi_install); | 228 product_state.set_multi_install(multi_install); |
| 230 product_state.set_brand(L"TEST"); | 229 product_state.set_brand(L"TEST"); |
| 231 product_state.set_eula_accepted(1); | 230 product_state.set_eula_accepted(1); |
| 232 BrowserDistribution* dist = | 231 BrowserDistribution* dist = |
| 233 BrowserDistribution::GetSpecificDistribution( | 232 BrowserDistribution::GetSpecificDistribution( |
| 234 BrowserDistribution::CHROME_BROWSER); | 233 BrowserDistribution::CHROME_BROWSER); |
| 235 base::FilePath install_path = | 234 base::FilePath install_path = |
| 236 installer::GetChromeInstallPath(system_level, dist); | 235 installer::GetChromeInstallPath(system_level, dist); |
| 237 product_state.SetUninstallProgram( | 236 product_state.SetUninstallProgram( |
| 238 install_path.AppendASCII(current_version_->GetString()) | 237 install_path.AppendASCII(current_version_->GetString()) |
| 239 .Append(installer::kInstallerDir) | 238 .Append(installer::kInstallerDir) |
| 240 .Append(installer::kSetupExe)); | 239 .Append(installer::kSetupExe)); |
| 241 product_state.AddUninstallSwitch(installer::switches::kUninstall); | 240 product_state.AddUninstallSwitch(installer::switches::kUninstall); |
| 242 if (system_level) | 241 if (system_level) |
| 243 product_state.AddUninstallSwitch(installer::switches::kSystemLevel); | 242 product_state.AddUninstallSwitch(installer::switches::kSystemLevel); |
| 244 if (multi_install) { | 243 if (multi_install) { |
| 245 product_state.AddUninstallSwitch(installer::switches::kMultiInstall); | 244 product_state.AddUninstallSwitch(installer::switches::kMultiInstall); |
| 246 product_state.AddUninstallSwitch(installer::switches::kChrome); | 245 product_state.AddUninstallSwitch(installer::switches::kChrome); |
| 247 if (with_chrome_frame_ready_mode) { | |
| 248 product_state.AddUninstallSwitch(installer::switches::kChromeFrame); | |
| 249 product_state.AddUninstallSwitch( | |
| 250 installer::switches::kChromeFrameReadyMode); | |
| 251 } | |
| 252 } | 246 } |
| 253 | 247 |
| 254 installation_state->SetProductState(system_level, | 248 installation_state->SetProductState(system_level, |
| 255 BrowserDistribution::CHROME_BROWSER, | 249 BrowserDistribution::CHROME_BROWSER, |
| 256 product_state); | 250 product_state); |
| 257 } | 251 } |
| 258 | 252 |
| 259 void AddChromeFrameToInstallationState( | 253 void AddChromeFrameToInstallationState( |
| 260 bool system_level, | 254 bool system_level, |
| 261 bool multi_install, | 255 bool multi_install, |
| 262 bool ready_mode, | |
| 263 MockInstallationState* installation_state) { | 256 MockInstallationState* installation_state) { |
| 264 if (multi_install) | 257 if (multi_install) |
| 265 MaybeAddBinariesToInstallationState(system_level, installation_state); | 258 MaybeAddBinariesToInstallationState(system_level, installation_state); |
| 266 MockProductState product_state; | 259 MockProductState product_state; |
| 267 product_state.set_version(new Version(*current_version_)); | 260 product_state.set_version(new Version(*current_version_)); |
| 268 product_state.set_multi_install(multi_install); | 261 product_state.set_multi_install(multi_install); |
| 269 BrowserDistribution* dist = | 262 BrowserDistribution* dist = |
| 270 BrowserDistribution::GetSpecificDistribution( | 263 BrowserDistribution::GetSpecificDistribution( |
| 271 multi_install ? BrowserDistribution::CHROME_BINARIES : | 264 multi_install ? BrowserDistribution::CHROME_BINARIES : |
| 272 BrowserDistribution::CHROME_FRAME); | 265 BrowserDistribution::CHROME_FRAME); |
| 273 base::FilePath install_path = | 266 base::FilePath install_path = |
| 274 installer::GetChromeInstallPath(system_level, dist); | 267 installer::GetChromeInstallPath(system_level, dist); |
| 275 product_state.SetUninstallProgram( | 268 product_state.SetUninstallProgram( |
| 276 install_path.AppendASCII(current_version_->GetString()) | 269 install_path.AppendASCII(current_version_->GetString()) |
| 277 .Append(installer::kInstallerDir) | 270 .Append(installer::kInstallerDir) |
| 278 .Append(installer::kSetupExe)); | 271 .Append(installer::kSetupExe)); |
| 279 product_state.AddUninstallSwitch(installer::switches::kUninstall); | 272 product_state.AddUninstallSwitch(installer::switches::kUninstall); |
| 280 product_state.AddUninstallSwitch(installer::switches::kChromeFrame); | 273 product_state.AddUninstallSwitch(installer::switches::kChromeFrame); |
| 281 if (system_level) | 274 if (system_level) |
| 282 product_state.AddUninstallSwitch(installer::switches::kSystemLevel); | 275 product_state.AddUninstallSwitch(installer::switches::kSystemLevel); |
| 283 if (multi_install) { | 276 if (multi_install) |
| 284 product_state.AddUninstallSwitch(installer::switches::kMultiInstall); | 277 product_state.AddUninstallSwitch(installer::switches::kMultiInstall); |
| 285 if (ready_mode) { | |
| 286 product_state.AddUninstallSwitch( | |
| 287 installer::switches::kChromeFrameReadyMode); | |
| 288 } | |
| 289 } | |
| 290 | 278 |
| 291 installation_state->SetProductState(system_level, | 279 installation_state->SetProductState(system_level, |
| 292 BrowserDistribution::CHROME_FRAME, | 280 BrowserDistribution::CHROME_FRAME, |
| 293 product_state); | 281 product_state); |
| 294 } | 282 } |
| 295 | 283 |
| 296 MockInstallationState* BuildChromeInstallationState(bool system_level, | 284 MockInstallationState* BuildChromeInstallationState(bool system_level, |
| 297 bool multi_install) { | 285 bool multi_install) { |
| 298 scoped_ptr<MockInstallationState> installation_state( | 286 scoped_ptr<MockInstallationState> installation_state( |
| 299 new MockInstallationState()); | 287 new MockInstallationState()); |
| 300 AddChromeToInstallationState(system_level, multi_install, false, | 288 AddChromeToInstallationState(system_level, multi_install, |
| 301 installation_state.get()); | 289 installation_state.get()); |
| 302 return installation_state.release(); | 290 return installation_state.release(); |
| 303 } | 291 } |
| 304 | 292 |
| 305 static MockInstallerState* BuildBasicInstallerState( | 293 static MockInstallerState* BuildBasicInstallerState( |
| 306 bool system_install, | 294 bool system_install, |
| 307 bool multi_install, | 295 bool multi_install, |
| 308 const InstallationState& machine_state, | 296 const InstallationState& machine_state, |
| 309 InstallerState::Operation operation) { | 297 InstallerState::Operation operation) { |
| 310 scoped_ptr<MockInstallerState> installer_state(new MockInstallerState()); | 298 scoped_ptr<MockInstallerState> installer_state(new MockInstallerState()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 BrowserDistribution::CHROME_BROWSER); | 354 BrowserDistribution::CHROME_BROWSER); |
| 367 scoped_ptr<Product> product(new Product(dist)); | 355 scoped_ptr<Product> product(new Product(dist)); |
| 368 if (installer_state->is_multi_install()) | 356 if (installer_state->is_multi_install()) |
| 369 product->SetOption(installer::kOptionMultiInstall, true); | 357 product->SetOption(installer::kOptionMultiInstall, true); |
| 370 installer_state->AddProduct(&product); | 358 installer_state->AddProduct(&product); |
| 371 } | 359 } |
| 372 } | 360 } |
| 373 | 361 |
| 374 static void AddChromeFrameToInstallerState( | 362 static void AddChromeFrameToInstallerState( |
| 375 const InstallationState& machine_state, | 363 const InstallationState& machine_state, |
| 376 bool ready_mode, | |
| 377 MockInstallerState* installer_state) { | 364 MockInstallerState* installer_state) { |
| 378 // Fresh install or upgrade? | 365 // Fresh install or upgrade? |
| 379 const ProductState* cf = | 366 const ProductState* cf = |
| 380 machine_state.GetProductState(installer_state->system_install(), | 367 machine_state.GetProductState(installer_state->system_install(), |
| 381 BrowserDistribution::CHROME_FRAME); | 368 BrowserDistribution::CHROME_FRAME); |
| 382 if (cf != NULL) { | 369 if (cf != NULL) { |
| 383 installer_state->AddProductFromState(BrowserDistribution::CHROME_FRAME, | 370 installer_state->AddProductFromState(BrowserDistribution::CHROME_FRAME, |
| 384 *cf); | 371 *cf); |
| 385 } else { | 372 } else { |
| 386 BrowserDistribution* dist = | 373 BrowserDistribution* dist = |
| 387 BrowserDistribution::GetSpecificDistribution( | 374 BrowserDistribution::GetSpecificDistribution( |
| 388 BrowserDistribution::CHROME_FRAME); | 375 BrowserDistribution::CHROME_FRAME); |
| 389 scoped_ptr<Product> product(new Product(dist)); | 376 scoped_ptr<Product> product(new Product(dist)); |
| 390 if (installer_state->is_multi_install()) { | 377 if (installer_state->is_multi_install()) |
| 391 product->SetOption(installer::kOptionMultiInstall, true); | 378 product->SetOption(installer::kOptionMultiInstall, true); |
| 392 if (ready_mode) | |
| 393 product->SetOption(installer::kOptionReadyMode, true); | |
| 394 } | |
| 395 installer_state->AddProduct(&product); | 379 installer_state->AddProduct(&product); |
| 396 } | 380 } |
| 397 } | 381 } |
| 398 | 382 |
| 399 static MockInstallerState* BuildChromeInstallerState( | 383 static MockInstallerState* BuildChromeInstallerState( |
| 400 bool system_install, | 384 bool system_install, |
| 401 bool multi_install, | 385 bool multi_install, |
| 402 const InstallationState& machine_state, | 386 const InstallationState& machine_state, |
| 403 InstallerState::Operation operation) { | 387 InstallerState::Operation operation) { |
| 404 scoped_ptr<MockInstallerState> installer_state( | 388 scoped_ptr<MockInstallerState> installer_state( |
| 405 BuildBasicInstallerState(system_install, multi_install, machine_state, | 389 BuildBasicInstallerState(system_install, multi_install, machine_state, |
| 406 operation)); | 390 operation)); |
| 407 if (multi_install) { | 391 if (multi_install) { |
| 408 // We don't want to include Chrome Binaries for uninstall if the machine | 392 // We don't want to include Chrome Binaries for uninstall if the machine |
| 409 // has other products. For simplicity, we check Chrome Frame only. | 393 // has other products. For simplicity, we check Chrome Frame only. |
| 410 bool machine_has_other_products = | 394 bool machine_has_other_products = |
| 411 machine_state.GetProductState(system_install, | 395 machine_state.GetProductState(system_install, |
| 412 BrowserDistribution::CHROME_FRAME) != NULL; | 396 BrowserDistribution::CHROME_FRAME) != NULL; |
| 413 if (operation != InstallerState::UNINSTALL || !machine_has_other_products) | 397 if (operation != InstallerState::UNINSTALL || !machine_has_other_products) |
| 414 AddChromeBinariesToInstallerState(machine_state, installer_state.get()); | 398 AddChromeBinariesToInstallerState(machine_state, installer_state.get()); |
| 415 } | 399 } |
| 416 AddChromeToInstallerState(machine_state, installer_state.get()); | 400 AddChromeToInstallerState(machine_state, installer_state.get()); |
| 417 return installer_state.release(); | 401 return installer_state.release(); |
| 418 } | 402 } |
| 419 | 403 |
| 420 static MockInstallerState* BuildChromeFrameInstallerState( | 404 static MockInstallerState* BuildChromeFrameInstallerState( |
| 421 bool system_install, | 405 bool system_install, |
| 422 bool multi_install, | 406 bool multi_install, |
| 423 bool ready_mode, | |
| 424 const InstallationState& machine_state, | 407 const InstallationState& machine_state, |
| 425 InstallerState::Operation operation) { | 408 InstallerState::Operation operation) { |
| 426 // This method only works for installation/upgrade. | 409 // This method only works for installation/upgrade. |
| 427 DCHECK(operation != InstallerState::UNINSTALL); | 410 DCHECK(operation != InstallerState::UNINSTALL); |
| 428 scoped_ptr<MockInstallerState> installer_state( | 411 scoped_ptr<MockInstallerState> installer_state( |
| 429 BuildBasicInstallerState(system_install, multi_install, machine_state, | 412 BuildBasicInstallerState(system_install, multi_install, machine_state, |
| 430 operation)); | 413 operation)); |
| 431 if (multi_install) | 414 if (multi_install) |
| 432 AddChromeBinariesToInstallerState(machine_state, installer_state.get()); | 415 AddChromeBinariesToInstallerState(machine_state, installer_state.get()); |
| 433 AddChromeFrameToInstallerState(machine_state, ready_mode, | 416 AddChromeFrameToInstallerState(machine_state, installer_state.get()); |
| 434 installer_state.get()); | |
| 435 return installer_state.release(); | 417 return installer_state.release(); |
| 436 } | 418 } |
| 437 | 419 |
| 438 protected: | 420 protected: |
| 439 scoped_ptr<Version> current_version_; | 421 scoped_ptr<Version> current_version_; |
| 440 scoped_ptr<Version> new_version_; | 422 scoped_ptr<Version> new_version_; |
| 441 base::FilePath archive_path_; | 423 base::FilePath archive_path_; |
| 442 base::FilePath installation_path_; | 424 base::FilePath installation_path_; |
| 443 base::FilePath setup_path_; | 425 base::FilePath setup_path_; |
| 444 base::FilePath src_path_; | 426 base::FilePath src_path_; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 protected: | 480 protected: |
| 499 virtual void SetUp() OVERRIDE { | 481 virtual void SetUp() OVERRIDE { |
| 500 InstallWorkerTest::SetUp(); | 482 InstallWorkerTest::SetUp(); |
| 501 | 483 |
| 502 const ParamType& param = GetParam(); | 484 const ParamType& param = GetParam(); |
| 503 system_level_ = std::tr1::get<0>(param); | 485 system_level_ = std::tr1::get<0>(param); |
| 504 multi_install_ = std::tr1::get<1>(param); | 486 multi_install_ = std::tr1::get<1>(param); |
| 505 root_key_ = system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 487 root_key_ = system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 506 | 488 |
| 507 installation_state_.reset(new MockInstallationState()); | 489 installation_state_.reset(new MockInstallationState()); |
| 508 AddChromeFrameToInstallationState(system_level_, multi_install_, false, | 490 AddChromeFrameToInstallationState(system_level_, multi_install_, |
| 509 installation_state_.get()); | 491 installation_state_.get()); |
| 510 installer_state_.reset(BuildBasicInstallerState( | 492 installer_state_.reset(BuildBasicInstallerState( |
| 511 system_level_, multi_install_, *installation_state_, | 493 system_level_, multi_install_, *installation_state_, |
| 512 multi_install_ ? InstallerState::MULTI_UPDATE : | 494 multi_install_ ? InstallerState::MULTI_UPDATE : |
| 513 InstallerState::SINGLE_INSTALL_OR_UPDATE)); | 495 InstallerState::SINGLE_INSTALL_OR_UPDATE)); |
| 514 if (multi_install_) | 496 if (multi_install_) |
| 515 AddChromeBinariesToInstallerState(*installation_state_, | 497 AddChromeBinariesToInstallerState(*installation_state_, |
| 516 installer_state_.get()); | 498 installer_state_.get()); |
| 517 AddChromeFrameToInstallerState(*installation_state_, false, | 499 AddChromeFrameToInstallerState(*installation_state_, |
| 518 installer_state_.get()); | 500 installer_state_.get()); |
| 519 } | 501 } |
| 520 | 502 |
| 521 scoped_ptr<MockInstallationState> installation_state_; | 503 scoped_ptr<MockInstallationState> installation_state_; |
| 522 scoped_ptr<MockInstallerState> installer_state_; | 504 scoped_ptr<MockInstallerState> installer_state_; |
| 523 bool system_level_; | 505 bool system_level_; |
| 524 bool multi_install_; | 506 bool multi_install_; |
| 525 HKEY root_key_; | 507 HKEY root_key_; |
| 526 }; | 508 }; |
| 527 | 509 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 AddQuickEnableChromeFrameWorkItems(*installer_state, | 719 AddQuickEnableChromeFrameWorkItems(*installer_state, |
| 738 *machine_state_, | 720 *machine_state_, |
| 739 setup_path_, | 721 setup_path_, |
| 740 *new_version_.get(), | 722 *new_version_.get(), |
| 741 &work_item_list_); | 723 &work_item_list_); |
| 742 } | 724 } |
| 743 | 725 |
| 744 TEST_F(QuickEnableAbsentTest, CleanInstallSingleChromeFrame) { | 726 TEST_F(QuickEnableAbsentTest, CleanInstallSingleChromeFrame) { |
| 745 // Install single Chrome Frame on a clean system. | 727 // Install single Chrome Frame on a clean system. |
| 746 scoped_ptr<MockInstallerState> installer_state( | 728 scoped_ptr<MockInstallerState> installer_state( |
| 747 BuildChromeFrameInstallerState(system_level_, false, false, | 729 BuildChromeFrameInstallerState(system_level_, false, *machine_state_, |
| 748 *machine_state_, | |
| 749 InstallerState::SINGLE_INSTALL_OR_UPDATE)); | 730 InstallerState::SINGLE_INSTALL_OR_UPDATE)); |
| 750 AddQuickEnableChromeFrameWorkItems(*installer_state, | 731 AddQuickEnableChromeFrameWorkItems(*installer_state, |
| 751 *machine_state_, | 732 *machine_state_, |
| 752 setup_path_, | 733 setup_path_, |
| 753 *new_version_.get(), | 734 *new_version_.get(), |
| 754 &work_item_list_); | 735 &work_item_list_); |
| 755 } | 736 } |
| 756 | 737 |
| 757 TEST_F(QuickEnableAbsentTest, CleanInstallMultiChromeFrame) { | 738 TEST_F(QuickEnableAbsentTest, CleanInstallMultiChromeFrame) { |
| 758 // Install multi Chrome Frame on a clean system. | 739 // Install multi Chrome Frame on a clean system. |
| 759 scoped_ptr<MockInstallerState> installer_state( | 740 scoped_ptr<MockInstallerState> installer_state( |
| 760 BuildChromeFrameInstallerState(system_level_, true, false, | 741 BuildChromeFrameInstallerState(system_level_, true, *machine_state_, |
| 761 *machine_state_, | |
| 762 InstallerState::MULTI_INSTALL)); | 742 InstallerState::MULTI_INSTALL)); |
| 763 AddQuickEnableChromeFrameWorkItems(*installer_state, | 743 AddQuickEnableChromeFrameWorkItems(*installer_state, |
| 764 *machine_state_, | 744 *machine_state_, |
| 765 setup_path_, | 745 setup_path_, |
| 766 *new_version_.get(), | 746 *new_version_.get(), |
| 767 &work_item_list_); | 747 &work_item_list_); |
| 768 } | 748 } |
| 769 | 749 |
| 770 TEST_F(QuickEnableAbsentTest, CleanInstallMultiChromeChromeFrame) { | 750 TEST_F(QuickEnableAbsentTest, CleanInstallMultiChromeChromeFrame) { |
| 771 // Install multi Chrome and Chrome Frame on a clean system. | 751 // Install multi Chrome and Chrome Frame on a clean system. |
| 772 scoped_ptr<MockInstallerState> installer_state( | 752 scoped_ptr<MockInstallerState> installer_state( |
| 773 BuildBasicInstallerState(system_level_, true, *machine_state_, | 753 BuildBasicInstallerState(system_level_, true, *machine_state_, |
| 774 InstallerState::MULTI_INSTALL)); | 754 InstallerState::MULTI_INSTALL)); |
| 775 AddChromeBinariesToInstallerState(*machine_state_, installer_state.get()); | 755 AddChromeBinariesToInstallerState(*machine_state_, installer_state.get()); |
| 776 AddChromeToInstallerState(*machine_state_, installer_state.get()); | 756 AddChromeToInstallerState(*machine_state_, installer_state.get()); |
| 777 AddChromeFrameToInstallerState(*machine_state_, false, | 757 AddChromeFrameToInstallerState(*machine_state_, installer_state.get()); |
| 778 installer_state.get()); | |
| 779 AddQuickEnableChromeFrameWorkItems(*installer_state, | 758 AddQuickEnableChromeFrameWorkItems(*installer_state, |
| 780 *machine_state_, | 759 *machine_state_, |
| 781 setup_path_, | 760 setup_path_, |
| 782 *new_version_.get(), | 761 *new_version_.get(), |
| 783 &work_item_list_); | 762 &work_item_list_); |
| 784 } | 763 } |
| 785 | 764 |
| 786 TEST_F(QuickEnableAbsentTest, UninstallMultiChromeLeaveMultiChromeFrame) { | 765 TEST_F(QuickEnableAbsentTest, UninstallMultiChromeLeaveMultiChromeFrame) { |
| 787 // Uninstall multi Chrome on a machine with multi Chrome Frame. | 766 // Uninstall multi Chrome on a machine with multi Chrome Frame. |
| 788 AddChromeToInstallationState(system_level_, true, false, | 767 AddChromeToInstallationState(system_level_, true, machine_state_.get()); |
| 789 machine_state_.get()); | 768 AddChromeFrameToInstallationState(system_level_, true, machine_state_.get()); |
| 790 AddChromeFrameToInstallationState(system_level_, true, false, | |
| 791 machine_state_.get()); | |
| 792 scoped_ptr<MockInstallerState> installer_state( | 769 scoped_ptr<MockInstallerState> installer_state( |
| 793 BuildBasicInstallerState(system_level_, true, *machine_state_, | 770 BuildBasicInstallerState(system_level_, true, *machine_state_, |
| 794 InstallerState::UNINSTALL)); | 771 InstallerState::UNINSTALL)); |
| 795 AddChromeToInstallerState(*machine_state_, installer_state.get()); | 772 AddChromeToInstallerState(*machine_state_, installer_state.get()); |
| 796 AddQuickEnableChromeFrameWorkItems(*installer_state, | 773 AddQuickEnableChromeFrameWorkItems(*installer_state, |
| 797 *machine_state_, | 774 *machine_state_, |
| 798 setup_path_, | 775 setup_path_, |
| 799 *new_version_.get(), | 776 *new_version_.get(), |
| 800 &work_item_list_); | 777 &work_item_list_); |
| 801 } | 778 } |
| 802 | 779 |
| 803 TEST_F(QuickEnableAbsentTest, UninstallMultiChromeLeaveSingleChromeFrame) { | 780 TEST_F(QuickEnableAbsentTest, UninstallMultiChromeLeaveSingleChromeFrame) { |
| 804 // Uninstall multi Chrome on a machine with single Chrome Frame. | 781 // Uninstall multi Chrome on a machine with single Chrome Frame. |
| 805 AddChromeToInstallationState(system_level_, true, false, | 782 AddChromeToInstallationState(system_level_, true, machine_state_.get()); |
| 806 machine_state_.get()); | 783 AddChromeFrameToInstallationState(system_level_, false, machine_state_.get()); |
| 807 AddChromeFrameToInstallationState(system_level_, false, false, | |
| 808 machine_state_.get()); | |
| 809 scoped_ptr<MockInstallerState> installer_state( | 784 scoped_ptr<MockInstallerState> installer_state( |
| 810 BuildBasicInstallerState(system_level_, true, *machine_state_, | 785 BuildBasicInstallerState(system_level_, true, *machine_state_, |
| 811 InstallerState::UNINSTALL)); | 786 InstallerState::UNINSTALL)); |
| 812 AddChromeToInstallerState(*machine_state_, installer_state.get()); | 787 AddChromeToInstallerState(*machine_state_, installer_state.get()); |
| 813 AddChromeBinariesToInstallerState(*machine_state_, installer_state.get()); | 788 AddChromeBinariesToInstallerState(*machine_state_, installer_state.get()); |
| 814 AddQuickEnableChromeFrameWorkItems(*installer_state, | 789 AddQuickEnableChromeFrameWorkItems(*installer_state, |
| 815 *machine_state_, | 790 *machine_state_, |
| 816 setup_path_, | |
| 817 *new_version_.get(), | |
| 818 &work_item_list_); | |
| 819 } | |
| 820 | |
| 821 TEST_F(QuickEnableAbsentTest, AcceptReadyMode) { | |
| 822 // Accept ready-mode. | |
| 823 AddChromeToInstallationState(system_level_, true, true, | |
| 824 machine_state_.get()); | |
| 825 AddChromeFrameToInstallationState(system_level_, true, true, | |
| 826 machine_state_.get()); | |
| 827 scoped_ptr<MockInstallerState> installer_state( | |
| 828 BuildBasicInstallerState(system_level_, true, *machine_state_, | |
| 829 InstallerState::UNINSTALL)); | |
| 830 AddChromeToInstallerState(*machine_state_, installer_state.get()); | |
| 831 AddChromeFrameToInstallerState(*machine_state_, false, installer_state.get()); | |
| 832 AddChromeBinariesToInstallerState(*machine_state_, installer_state.get()); | |
| 833 AddQuickEnableChromeFrameWorkItems(*installer_state, | |
| 834 *machine_state_, | |
| 835 setup_path_, | 791 setup_path_, |
| 836 *new_version_.get(), | 792 *new_version_.get(), |
| 837 &work_item_list_); | 793 &work_item_list_); |
| 838 } | 794 } |
| 839 | 795 |
| 840 // Test scenarios under which the quick-enable-cf command should exist after the | 796 // Test scenarios under which the quick-enable-cf command should exist after the |
| 841 // run. | 797 // run. |
| 842 class QuickEnablePresentTest : public InstallWorkerTest { | 798 class QuickEnablePresentTest : public InstallWorkerTest { |
| 843 public: | 799 public: |
| 844 virtual void SetUp() { | 800 virtual void SetUp() { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 scoped_ptr<MockInstallerState> installer_state( | 851 scoped_ptr<MockInstallerState> installer_state( |
| 896 BuildChromeInstallerState(system_level_, true, *machine_state_, | 852 BuildChromeInstallerState(system_level_, true, *machine_state_, |
| 897 InstallerState::MULTI_INSTALL)); | 853 InstallerState::MULTI_INSTALL)); |
| 898 AddQuickEnableChromeFrameWorkItems(*installer_state, | 854 AddQuickEnableChromeFrameWorkItems(*installer_state, |
| 899 *machine_state_, | 855 *machine_state_, |
| 900 setup_path_, | 856 setup_path_, |
| 901 *new_version_.get(), | 857 *new_version_.get(), |
| 902 &work_item_list_); | 858 &work_item_list_); |
| 903 } | 859 } |
| 904 | 860 |
| 905 TEST_F(QuickEnablePresentTest, CleanInstallMultiChromeReadyMode) { | |
| 906 // Install multi Chrome with Chrome Frame ready-mode on a clean system. | |
| 907 scoped_ptr<MockInstallerState> installer_state( | |
| 908 BuildBasicInstallerState(system_level_, true, *machine_state_, | |
| 909 InstallerState::MULTI_INSTALL)); | |
| 910 AddChromeBinariesToInstallerState(*machine_state_, installer_state.get()); | |
| 911 AddChromeToInstallerState(*machine_state_, installer_state.get()); | |
| 912 AddChromeFrameToInstallerState(*machine_state_, true, | |
| 913 installer_state.get()); | |
| 914 AddQuickEnableChromeFrameWorkItems(*installer_state, | |
| 915 *machine_state_, | |
| 916 setup_path_, | |
| 917 *new_version_.get(), | |
| 918 &work_item_list_); | |
| 919 } | |
| 920 | |
| 921 TEST_F(QuickEnablePresentTest, UninstallSingleChromeFrame) { | 861 TEST_F(QuickEnablePresentTest, UninstallSingleChromeFrame) { |
| 922 // Uninstall single Chrome Frame on a machine with multi Chrome. | 862 // Uninstall single Chrome Frame on a machine with multi Chrome. |
| 923 AddChromeToInstallationState(system_level_, true, false, | 863 AddChromeToInstallationState(system_level_, true, machine_state_.get()); |
| 924 machine_state_.get()); | 864 AddChromeFrameToInstallationState(system_level_, false, machine_state_.get()); |
| 925 AddChromeFrameToInstallationState(system_level_, false, false, | |
| 926 machine_state_.get()); | |
| 927 scoped_ptr<MockInstallerState> installer_state( | 865 scoped_ptr<MockInstallerState> installer_state( |
| 928 BuildBasicInstallerState(system_level_, false, *machine_state_, | 866 BuildBasicInstallerState(system_level_, false, *machine_state_, |
| 929 InstallerState::UNINSTALL)); | 867 InstallerState::UNINSTALL)); |
| 930 AddChromeFrameToInstallerState(*machine_state_, false, installer_state.get()); | 868 AddChromeFrameToInstallerState(*machine_state_, installer_state.get()); |
| 931 AddQuickEnableChromeFrameWorkItems(*installer_state, | 869 AddQuickEnableChromeFrameWorkItems(*installer_state, |
| 932 *machine_state_, | 870 *machine_state_, |
| 933 setup_path_, | 871 setup_path_, |
| 934 *new_version_.get(), | 872 *new_version_.get(), |
| 935 &work_item_list_); | 873 &work_item_list_); |
| 936 } | 874 } |
| 937 | 875 |
| 938 TEST_F(QuickEnablePresentTest, UninstallMultiChromeFrame) { | 876 TEST_F(QuickEnablePresentTest, UninstallMultiChromeFrame) { |
| 939 // Uninstall multi Chrome Frame on a machine with multi Chrome. | 877 // Uninstall multi Chrome Frame on a machine with multi Chrome. |
| 940 AddChromeToInstallationState(system_level_, true, false, | 878 AddChromeToInstallationState(system_level_, true, machine_state_.get()); |
| 941 machine_state_.get()); | 879 AddChromeFrameToInstallationState(system_level_, true, machine_state_.get()); |
| 942 AddChromeFrameToInstallationState(system_level_, true, false, | |
| 943 machine_state_.get()); | |
| 944 scoped_ptr<MockInstallerState> installer_state( | 880 scoped_ptr<MockInstallerState> installer_state( |
| 945 BuildBasicInstallerState(system_level_, true, *machine_state_, | 881 BuildBasicInstallerState(system_level_, true, *machine_state_, |
| 946 InstallerState::UNINSTALL)); | 882 InstallerState::UNINSTALL)); |
| 947 AddChromeFrameToInstallerState(*machine_state_, false, installer_state.get()); | 883 AddChromeFrameToInstallerState(*machine_state_, installer_state.get()); |
| 948 AddQuickEnableChromeFrameWorkItems(*installer_state, | 884 AddQuickEnableChromeFrameWorkItems(*installer_state, |
| 949 *machine_state_, | 885 *machine_state_, |
| 950 setup_path_, | 886 setup_path_, |
| 951 *new_version_.get(), | 887 *new_version_.get(), |
| 952 &work_item_list_); | 888 &work_item_list_); |
| 953 } | 889 } |
| 954 | 890 |
| 955 TEST_F(InstallWorkerTest, WillProductBePresentAfterSetup) { | 891 TEST_F(InstallWorkerTest, WillProductBePresentAfterSetup) { |
| 956 BrowserDistribution::Type prod_type_list[] = { | 892 BrowserDistribution::Type prod_type_list[] = { |
| 957 BrowserDistribution::CHROME_BROWSER, | 893 BrowserDistribution::CHROME_BROWSER, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 972 | 908 |
| 973 const bool system_level = false; | 909 const bool system_level = false; |
| 974 const bool multi_install = true; | 910 const bool multi_install = true; |
| 975 | 911 |
| 976 // Loop over machine states: {No product, Chrome, CF, Chrome + CF}. | 912 // Loop over machine states: {No product, Chrome, CF, Chrome + CF}. |
| 977 for (int i_mach = 0; i_mach < (1 << NUM_TYPE); ++i_mach) { | 913 for (int i_mach = 0; i_mach < (1 << NUM_TYPE); ++i_mach) { |
| 978 // i_mach is the machine state before operation, as bit mask. | 914 // i_mach is the machine state before operation, as bit mask. |
| 979 scoped_ptr<MockInstallationState> machine_state( | 915 scoped_ptr<MockInstallationState> machine_state( |
| 980 new MockInstallationState()); | 916 new MockInstallationState()); |
| 981 if ((i_mach & (1 << TYPE_BROWSER)) != 0) { // Add Chrome. | 917 if ((i_mach & (1 << TYPE_BROWSER)) != 0) { // Add Chrome. |
| 982 AddChromeToInstallationState(system_level, multi_install, false, | 918 AddChromeToInstallationState(system_level, multi_install, |
| 983 machine_state.get()); | 919 machine_state.get()); |
| 984 } | 920 } |
| 985 if ((i_mach & (1 << TYPE_CF)) != 0) { // Add Chrome Frame. | 921 if ((i_mach & (1 << TYPE_CF)) != 0) { // Add Chrome Frame. |
| 986 AddChromeFrameToInstallationState(system_level, multi_install, false, | 922 AddChromeFrameToInstallationState(system_level, multi_install, |
| 987 machine_state.get()); | 923 machine_state.get()); |
| 988 } | 924 } |
| 989 | 925 |
| 990 // Loop over operations: {uninstall, install/update}. | 926 // Loop over operations: {uninstall, install/update}. |
| 991 for (int i_op = 0; i_op < arraysize(op_list); ++i_op) { | 927 for (int i_op = 0; i_op < arraysize(op_list); ++i_op) { |
| 992 | 928 |
| 993 // Loop over product types to operate on: {TYPE_BROWSER, TYPE_CF}. | 929 // Loop over product types to operate on: {TYPE_BROWSER, TYPE_CF}. |
| 994 for (int i_type_op = 0; i_type_op < NUM_TYPE; ++i_type_op) { | 930 for (int i_type_op = 0; i_type_op < NUM_TYPE; ++i_type_op) { |
| 995 scoped_ptr<InstallerState> installer_state; | 931 scoped_ptr<InstallerState> installer_state; |
| 996 if (i_type_op == TYPE_BROWSER) { | 932 if (i_type_op == TYPE_BROWSER) { |
| 997 installer_state.reset(BuildChromeInstallerState( | 933 installer_state.reset(BuildChromeInstallerState( |
| 998 system_level, multi_install, *machine_state, op_list[i_op])); | 934 system_level, multi_install, *machine_state, op_list[i_op])); |
| 999 } else if (i_type_op == TYPE_CF) { | 935 } else if (i_type_op == TYPE_CF) { |
| 1000 // Skip the CF uninstall case due to limitations in | 936 // Skip the CF uninstall case due to limitations in |
| 1001 // BuildChromeFrameInstallerState(). | 937 // BuildChromeFrameInstallerState(). |
| 1002 if (op_list[i_op] == InstallerState::UNINSTALL) | 938 if (op_list[i_op] == InstallerState::UNINSTALL) |
| 1003 continue; | 939 continue; |
| 1004 | 940 |
| 1005 installer_state.reset(BuildChromeFrameInstallerState( | 941 installer_state.reset(BuildChromeFrameInstallerState( |
| 1006 system_level, multi_install, false, *machine_state, | 942 system_level, multi_install, *machine_state, op_list[i_op])); |
| 1007 op_list[i_op])); | |
| 1008 } else { | 943 } else { |
| 1009 NOTREACHED(); | 944 NOTREACHED(); |
| 1010 } | 945 } |
| 1011 | 946 |
| 1012 // Calculate the machine state after operation, as bit mask. | 947 // Calculate the machine state after operation, as bit mask. |
| 1013 // If uninstall, remove product with bitwise AND; else add with OR. | 948 // If uninstall, remove product with bitwise AND; else add with OR. |
| 1014 int mach_after = (op_list[i_op] == InstallerState::UNINSTALL) ? | 949 int mach_after = (op_list[i_op] == InstallerState::UNINSTALL) ? |
| 1015 i_mach & ~(1 << i_type_op) : i_mach | (1 << i_type_op); | 950 i_mach & ~(1 << i_type_op) : i_mach | (1 << i_type_op); |
| 1016 | 951 |
| 1017 // Verify predicted presence of Chrome Binaries. | 952 // Verify predicted presence of Chrome Binaries. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1032 prod_type_list[i_type_check]); | 967 prod_type_list[i_type_check]); |
| 1033 bool prod_expect = (mach_after & (1 << i_type_check)) != 0; | 968 bool prod_expect = (mach_after & (1 << i_type_check)) != 0; |
| 1034 EXPECT_EQ(prod_expect, prod_res); | 969 EXPECT_EQ(prod_expect, prod_res); |
| 1035 } | 970 } |
| 1036 } | 971 } |
| 1037 } | 972 } |
| 1038 } | 973 } |
| 1039 } | 974 } |
| 1040 | 975 |
| 1041 #endif // defined(GOOGLE_CHROME_BUILD) | 976 #endif // defined(GOOGLE_CHROME_BUILD) |
| OLD | NEW |