| 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 <windows.h> | 5 #include <windows.h> |
| 6 | 6 |
| 7 #include <fstream> | 7 #include <fstream> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 << "Unexpected version dir found: " << version.GetString(); | 595 << "Unexpected version dir found: " << version.GetString(); |
| 596 } | 596 } |
| 597 } | 597 } |
| 598 | 598 |
| 599 std::set<std::string>::const_iterator iter( | 599 std::set<std::string>::const_iterator iter( |
| 600 expected_remaining_dirs.begin()); | 600 expected_remaining_dirs.begin()); |
| 601 for (; iter != expected_remaining_dirs.end(); ++iter) | 601 for (; iter != expected_remaining_dirs.end(); ++iter) |
| 602 ADD_FAILURE() << "Expected to find version dir for " << *iter; | 602 ADD_FAILURE() << "Expected to find version dir for " << *iter; |
| 603 } | 603 } |
| 604 | 604 |
| 605 TEST_F(InstallerStateTest, InitializeTwice) { |
| 606 InstallationState machine_state; |
| 607 machine_state.Initialize(); |
| 608 |
| 609 InstallerState installer_state; |
| 610 |
| 611 // Initialize the instance to install multi Chrome. |
| 612 { |
| 613 CommandLine cmd_line( |
| 614 CommandLine::FromString(L"setup.exe --multi-install --chrome")); |
| 615 MasterPreferences prefs(cmd_line); |
| 616 installer_state.Initialize(cmd_line, prefs, machine_state); |
| 617 } |
| 618 // Confirm the expected state. |
| 619 EXPECT_EQ(InstallerState::USER_LEVEL, installer_state.level()); |
| 620 EXPECT_EQ(InstallerState::MULTI_PACKAGE, installer_state.package_type()); |
| 621 EXPECT_EQ(InstallerState::MULTI_INSTALL, installer_state.operation()); |
| 622 EXPECT_TRUE(wcsstr(installer_state.target_path().value().c_str(), |
| 623 BrowserDistribution::GetSpecificDistribution( |
| 624 BrowserDistribution::CHROME_BINARIES)-> |
| 625 GetInstallSubDir().c_str())); |
| 626 EXPECT_FALSE(installer_state.verbose_logging()); |
| 627 EXPECT_EQ(installer_state.state_key(), |
| 628 BrowserDistribution::GetSpecificDistribution( |
| 629 BrowserDistribution::CHROME_BROWSER)->GetStateKey()); |
| 630 EXPECT_EQ(installer_state.state_type(), BrowserDistribution::CHROME_BROWSER); |
| 631 EXPECT_TRUE(installer_state.multi_package_binaries_distribution()); |
| 632 EXPECT_TRUE(installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER)); |
| 633 EXPECT_FALSE(installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)); |
| 634 |
| 635 // Now initialize it to install system-level single Chrome Frame. |
| 636 { |
| 637 CommandLine cmd_line( |
| 638 CommandLine::FromString(L"setup.exe --system-level --chrome-frame " |
| 639 L"--verbose-logging")); |
| 640 MasterPreferences prefs(cmd_line); |
| 641 installer_state.Initialize(cmd_line, prefs, machine_state); |
| 642 } |
| 643 |
| 644 // Confirm that the old state is gone. |
| 645 EXPECT_EQ(InstallerState::SYSTEM_LEVEL, installer_state.level()); |
| 646 EXPECT_EQ(InstallerState::SINGLE_PACKAGE, installer_state.package_type()); |
| 647 EXPECT_EQ(InstallerState::SINGLE_INSTALL_OR_UPDATE, |
| 648 installer_state.operation()); |
| 649 EXPECT_TRUE(wcsstr(installer_state.target_path().value().c_str(), |
| 650 BrowserDistribution::GetSpecificDistribution( |
| 651 BrowserDistribution::CHROME_FRAME)-> |
| 652 GetInstallSubDir().c_str())); |
| 653 EXPECT_TRUE(installer_state.verbose_logging()); |
| 654 // state_key and type are wrong in unittests since it is set based on the |
| 655 // current process's BrowserDistribution. |
| 656 // EXPECT_EQ(installer_state.state_key(), |
| 657 // BrowserDistribution::GetSpecificDistribution( |
| 658 // BrowserDistribution::CHROME_FRAME)->GetStateKey()); |
| 659 // EXPECT_EQ(installer_state.state_type(), BrowserDistribution::CHROME_FRAME); |
| 660 EXPECT_FALSE( |
| 661 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER)); |
| 662 EXPECT_TRUE(installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)); |
| 663 } |
| 605 | 664 |
| 606 // A fixture for testing InstallerState::DetermineCriticalVersion. Individual | 665 // A fixture for testing InstallerState::DetermineCriticalVersion. Individual |
| 607 // tests must invoke Initialize() with a critical version. | 666 // tests must invoke Initialize() with a critical version. |
| 608 class InstallerStateCriticalVersionTest : public ::testing::Test { | 667 class InstallerStateCriticalVersionTest : public ::testing::Test { |
| 609 protected: | 668 protected: |
| 610 InstallerStateCriticalVersionTest() : cmd_line_(CommandLine::NO_PROGRAM) {} | 669 InstallerStateCriticalVersionTest() : cmd_line_(CommandLine::NO_PROGRAM) {} |
| 611 | 670 |
| 612 // Creates a set of versions for use by all test runs. | 671 // Creates a set of versions for use by all test runs. |
| 613 static void SetUpTestCase() { | 672 static void SetUpTestCase() { |
| 614 low_version_ = new Version("15.0.874.106"); | 673 low_version_ = new Version("15.0.874.106"); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 // Critical update newer than the new version. | 807 // Critical update newer than the new version. |
| 749 EXPECT_FALSE( | 808 EXPECT_FALSE( |
| 750 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid()); | 809 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid()); |
| 751 EXPECT_FALSE( | 810 EXPECT_FALSE( |
| 752 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_) | 811 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_) |
| 753 .IsValid()); | 812 .IsValid()); |
| 754 EXPECT_FALSE( | 813 EXPECT_FALSE( |
| 755 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_) | 814 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_) |
| 756 .IsValid()); | 815 .IsValid()); |
| 757 } | 816 } |
| OLD | NEW |