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/setup_util_unittest.h" | 5 #include "chrome/installer/setup/setup_util_unittest.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <shlobj.h> | 8 #include <shlobj.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 max_version_ = base::Version("47.0.1559.0"); | 380 max_version_ = base::Version("47.0.1559.0"); |
381 | 381 |
382 // Install the product according to the version. | 382 // Install the product according to the version. |
383 original_state_.reset(new FakeInstallationState()); | 383 original_state_.reset(new FakeInstallationState()); |
384 InstallProduct(); | 384 InstallProduct(); |
385 | 385 |
386 // Prepare to update the product in the temp dir. | 386 // Prepare to update the product in the temp dir. |
387 installer_state_.reset(new installer::InstallerState( | 387 installer_state_.reset(new installer::InstallerState( |
388 kSystemInstall_ ? installer::InstallerState::SYSTEM_LEVEL : | 388 kSystemInstall_ ? installer::InstallerState::SYSTEM_LEVEL : |
389 installer::InstallerState::USER_LEVEL)); | 389 installer::InstallerState::USER_LEVEL)); |
390 installer_state_->AddProductFromState(*original_state_->GetProductState( | 390 installer_state_->AddProductFromState( |
391 kSystemInstall_, BrowserDistribution::CHROME_BROWSER)); | 391 *original_state_->GetProductState(kSystemInstall_)); |
392 | 392 |
393 // Create archives in the two version dirs. | 393 // Create archives in the two version dirs. |
394 ASSERT_TRUE( | 394 ASSERT_TRUE( |
395 base::CreateDirectory(GetProductVersionArchivePath().DirName())); | 395 base::CreateDirectory(GetProductVersionArchivePath().DirName())); |
396 ASSERT_EQ(1, base::WriteFile(GetProductVersionArchivePath(), "a", 1)); | 396 ASSERT_EQ(1, base::WriteFile(GetProductVersionArchivePath(), "a", 1)); |
397 ASSERT_TRUE( | 397 ASSERT_TRUE( |
398 base::CreateDirectory(GetMaxVersionArchivePath().DirName())); | 398 base::CreateDirectory(GetMaxVersionArchivePath().DirName())); |
399 ASSERT_EQ(1, base::WriteFile(GetMaxVersionArchivePath(), "b", 1)); | 399 ASSERT_EQ(1, base::WriteFile(GetMaxVersionArchivePath(), "b", 1)); |
400 } | 400 } |
401 | 401 |
(...skipping 11 matching lines...) Expand all Loading... |
413 base::FilePath GetMaxVersionArchivePath() const { | 413 base::FilePath GetMaxVersionArchivePath() const { |
414 return GetArchivePath(max_version_); | 414 return GetArchivePath(max_version_); |
415 } | 415 } |
416 | 416 |
417 base::FilePath GetProductVersionArchivePath() const { | 417 base::FilePath GetProductVersionArchivePath() const { |
418 return GetArchivePath(product_version_); | 418 return GetArchivePath(product_version_); |
419 } | 419 } |
420 | 420 |
421 void InstallProduct() { | 421 void InstallProduct() { |
422 FakeProductState* product = FakeProductState::FromProductState( | 422 FakeProductState* product = FakeProductState::FromProductState( |
423 original_state_->GetNonVersionedProductState( | 423 original_state_->GetNonVersionedProductState(kSystemInstall_)); |
424 kSystemInstall_, BrowserDistribution::CHROME_BROWSER)); | |
425 | 424 |
426 product->set_version(product_version_); | 425 product->set_version(product_version_); |
427 base::CommandLine uninstall_command( | 426 base::CommandLine uninstall_command( |
428 test_dir_.GetPath() | 427 test_dir_.GetPath() |
429 .AppendASCII(product_version_.GetString()) | 428 .AppendASCII(product_version_.GetString()) |
430 .Append(installer::kInstallerDir) | 429 .Append(installer::kInstallerDir) |
431 .Append(installer::kSetupExe)); | 430 .Append(installer::kSetupExe)); |
432 uninstall_command.AppendSwitch(installer::switches::kUninstall); | 431 uninstall_command.AppendSwitch(installer::switches::kUninstall); |
433 product->set_uninstall_command(uninstall_command); | 432 product->set_uninstall_command(uninstall_command); |
434 } | 433 } |
435 | 434 |
436 void UninstallProduct() { | 435 void UninstallProduct() { |
437 FakeProductState::FromProductState( | 436 FakeProductState::FromProductState( |
438 original_state_->GetNonVersionedProductState( | 437 original_state_->GetNonVersionedProductState(kSystemInstall_)) |
439 kSystemInstall_, BrowserDistribution::CHROME_BROWSER)) | |
440 ->set_version(base::Version()); | 438 ->set_version(base::Version()); |
441 } | 439 } |
442 | 440 |
443 static const bool kSystemInstall_; | 441 static const bool kSystemInstall_; |
444 base::ScopedTempDir test_dir_; | 442 base::ScopedTempDir test_dir_; |
445 base::Version product_version_; | 443 base::Version product_version_; |
446 base::Version max_version_; | 444 base::Version max_version_; |
447 std::unique_ptr<FakeInstallationState> original_state_; | 445 std::unique_ptr<FakeInstallationState> original_state_; |
448 std::unique_ptr<installer::InstallerState> installer_state_; | 446 std::unique_ptr<installer::InstallerState> installer_state_; |
449 | 447 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 EXPECT_FALSE(HasBinariesVersionKey()); | 767 EXPECT_FALSE(HasBinariesVersionKey()); |
770 #if defined(GOOGLE_CHROME_BUILD) | 768 #if defined(GOOGLE_CHROME_BUILD) |
771 EXPECT_FALSE(HasMultiGCFVersionKey()); | 769 EXPECT_FALSE(HasMultiGCFVersionKey()); |
772 EXPECT_FALSE(HasAppLauncherVersionKey()); | 770 EXPECT_FALSE(HasAppLauncherVersionKey()); |
773 EXPECT_FALSE(HasAppHostExe()); | 771 EXPECT_FALSE(HasAppHostExe()); |
774 EXPECT_FALSE(HasInstallExtensionCommand()); | 772 EXPECT_FALSE(HasInstallExtensionCommand()); |
775 #endif // GOOGLE_CHROME_BUILD | 773 #endif // GOOGLE_CHROME_BUILD |
776 } | 774 } |
777 | 775 |
778 } // namespace installer | 776 } // namespace installer |
OLD | NEW |