Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/google/google_update_win.h" | 5 #include "chrome/browser/google/google_update_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <atlbase.h> | 8 #include <atlbase.h> |
| 9 #include <atlcom.h> | 9 #include <atlcom.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <queue> | 12 #include <queue> |
| 13 | 13 |
| 14 #include "base/base_paths.h" | 14 #include "base/base_paths.h" |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 19 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/test/scoped_path_override.h" | 21 #include "base/test/scoped_path_override.h" |
| 22 #include "base/test/scoped_task_environment.h" | |
| 22 #include "base/test/test_reg_util_win.h" | 23 #include "base/test/test_reg_util_win.h" |
| 23 #include "base/test/test_simple_task_runner.h" | |
| 24 #include "base/threading/thread_task_runner_handle.h" | |
| 25 #include "base/version.h" | 24 #include "base/version.h" |
| 26 #include "base/win/registry.h" | 25 #include "base/win/registry.h" |
| 27 #include "base/win/scoped_comptr.h" | 26 #include "base/win/scoped_comptr.h" |
| 28 #include "chrome/common/chrome_version.h" | 27 #include "chrome/common/chrome_version.h" |
| 29 #include "chrome/install_static/test/scoped_install_details.h" | 28 #include "chrome/install_static/test/scoped_install_details.h" |
| 30 #include "chrome/installer/util/google_update_settings.h" | 29 #include "chrome/installer/util/google_update_settings.h" |
| 31 #include "chrome/installer/util/helper.h" | 30 #include "chrome/installer/util/helper.h" |
| 32 #include "google_update/google_update_idl.h" | 31 #include "google_update/google_update_idl.h" |
| 33 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
| 34 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 522 static void SetUpTestCase() { | 521 static void SetUpTestCase() { |
| 523 ui::win::CreateATLModuleIfNeeded(); | 522 ui::win::CreateATLModuleIfNeeded(); |
| 524 // Configure all mock functions that return HRESULT to return failure. | 523 // Configure all mock functions that return HRESULT to return failure. |
| 525 ::testing::DefaultValue<HRESULT>::Set(E_FAIL); | 524 ::testing::DefaultValue<HRESULT>::Set(E_FAIL); |
| 526 } | 525 } |
| 527 | 526 |
| 528 static void TearDownTestCase() { ::testing::DefaultValue<HRESULT>::Clear(); } | 527 static void TearDownTestCase() { ::testing::DefaultValue<HRESULT>::Clear(); } |
| 529 | 528 |
| 530 protected: | 529 protected: |
| 531 GoogleUpdateWinTest() | 530 GoogleUpdateWinTest() |
| 532 : task_runner_(new base::TestSimpleTaskRunner()), | 531 : system_level_install_(GetParam()), |
| 533 task_runner_handle_(task_runner_), | |
| 534 system_level_install_(GetParam()), | |
| 535 scoped_install_details_(system_level_install_, 0) {} | 532 scoped_install_details_(system_level_install_, 0) {} |
| 536 | 533 |
| 537 void SetUp() override { | 534 void SetUp() override { |
| 538 ::testing::TestWithParam<bool>::SetUp(); | 535 ::testing::TestWithParam<bool>::SetUp(); |
| 539 | 536 |
| 540 // Override FILE_EXE so that it looks like the test is running from the | 537 // Override FILE_EXE so that it looks like the test is running from the |
| 541 // standard install location for this mode (system-level or user-level). | 538 // standard install location for this mode (system-level or user-level). |
| 542 base::FilePath file_exe; | 539 base::FilePath file_exe; |
| 543 ASSERT_TRUE(PathService::Get(base::FILE_EXE, &file_exe)); | 540 ASSERT_TRUE(PathService::Get(base::FILE_EXE, &file_exe)); |
| 544 base::FilePath install_dir( | 541 base::FilePath install_dir( |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 615 void TearDown() override { | 612 void TearDown() override { |
| 616 // Remove the test's IGoogleUpdate on-demand update class factory. | 613 // Remove the test's IGoogleUpdate on-demand update class factory. |
| 617 SetGoogleUpdateFactoryForTesting(GoogleUpdate3ClassFactory()); | 614 SetGoogleUpdateFactoryForTesting(GoogleUpdate3ClassFactory()); |
| 618 ::testing::TestWithParam<bool>::TearDown(); | 615 ::testing::TestWithParam<bool>::TearDown(); |
| 619 } | 616 } |
| 620 | 617 |
| 621 static const base::char16 kClients[]; | 618 static const base::char16 kClients[]; |
| 622 static const base::char16 kClientState[]; | 619 static const base::char16 kClientState[]; |
| 623 static const base::char16 kChromeGuid[]; | 620 static const base::char16 kChromeGuid[]; |
| 624 | 621 |
| 625 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; | 622 base::test::ScopedTaskEnvironment scoped_task_environment_; |
|
gab
2017/07/17 17:14:40
TestSimpleTaskRunner ignores delays in delayed tas
calamity
2017/07/19 09:03:38
Done.
| |
| 626 base::ThreadTaskRunnerHandle task_runner_handle_; | |
| 627 bool system_level_install_; | 623 bool system_level_install_; |
| 628 install_static::ScopedInstallDetails scoped_install_details_; | 624 install_static::ScopedInstallDetails scoped_install_details_; |
| 629 std::unique_ptr<base::ScopedPathOverride> file_exe_override_; | 625 std::unique_ptr<base::ScopedPathOverride> file_exe_override_; |
| 630 std::unique_ptr<base::ScopedPathOverride> program_files_override_; | 626 std::unique_ptr<base::ScopedPathOverride> program_files_override_; |
| 631 std::unique_ptr<base::ScopedPathOverride> program_files_x86_override_; | 627 std::unique_ptr<base::ScopedPathOverride> program_files_x86_override_; |
| 632 std::unique_ptr<base::ScopedPathOverride> local_app_data_override_; | 628 std::unique_ptr<base::ScopedPathOverride> local_app_data_override_; |
| 633 registry_util::RegistryOverrideManager registry_override_manager_; | 629 registry_util::RegistryOverrideManager registry_override_manager_; |
| 634 | 630 |
| 635 // A mock object, the OnUpdateCheckCallback method of which will be invoked | 631 // A mock object, the OnUpdateCheckCallback method of which will be invoked |
| 636 // each time the update check machinery invokes the given UpdateCheckCallback. | 632 // each time the update check machinery invokes the given UpdateCheckCallback. |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 665 base::FilePath dir_temp; | 661 base::FilePath dir_temp; |
| 666 ASSERT_TRUE(PathService::Get(base::FILE_EXE, &file_exe)); | 662 ASSERT_TRUE(PathService::Get(base::FILE_EXE, &file_exe)); |
| 667 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &dir_temp)); | 663 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &dir_temp)); |
| 668 file_exe_override_.reset(); | 664 file_exe_override_.reset(); |
| 669 file_exe_override_.reset(new base::ScopedPathOverride( | 665 file_exe_override_.reset(new base::ScopedPathOverride( |
| 670 base::FILE_EXE, dir_temp.Append(file_exe.BaseName()), | 666 base::FILE_EXE, dir_temp.Append(file_exe.BaseName()), |
| 671 true /* is_absolute */, false /* create */)); | 667 true /* is_absolute */, false /* create */)); |
| 672 | 668 |
| 673 EXPECT_CALL(mock_update_check_delegate_, | 669 EXPECT_CALL(mock_update_check_delegate_, |
| 674 OnError(CANNOT_UPGRADE_CHROME_IN_THIS_DIRECTORY, _, _)); | 670 OnError(CANNOT_UPGRADE_CHROME_IN_THIS_DIRECTORY, _, _)); |
| 675 BeginUpdateCheck(task_runner_, std::string(), false, 0, | 671 BeginUpdateCheck(std::string(), false, 0, |
| 676 mock_update_check_delegate_.AsWeakPtr()); | 672 mock_update_check_delegate_.AsWeakPtr()); |
| 677 task_runner_->RunUntilIdle(); | 673 scoped_task_environment_.RunUntilIdle(); |
| 678 } | 674 } |
| 679 | 675 |
| 680 // Test the case where the GoogleUpdate class can't be created for an update | 676 // Test the case where the GoogleUpdate class can't be created for an update |
| 681 // check. | 677 // check. |
| 682 TEST_P(GoogleUpdateWinTest, NoGoogleUpdateForCheck) { | 678 TEST_P(GoogleUpdateWinTest, NoGoogleUpdateForCheck) { |
| 683 // The factory should be called upon: let it fail. | 679 // The factory should be called upon: let it fail. |
| 684 EXPECT_CALL(mock_google_update_factory_, Create(_)); | 680 EXPECT_CALL(mock_google_update_factory_, Create(_)); |
| 685 | 681 |
| 686 // Expect the appropriate error when the on-demand class cannot be created. | 682 // Expect the appropriate error when the on-demand class cannot be created. |
| 687 EXPECT_CALL(mock_update_check_delegate_, | 683 EXPECT_CALL(mock_update_check_delegate_, |
| 688 OnError(GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND, _, _)); | 684 OnError(GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND, _, _)); |
| 689 BeginUpdateCheck(task_runner_, std::string(), false, 0, | 685 BeginUpdateCheck(std::string(), false, 0, |
| 690 mock_update_check_delegate_.AsWeakPtr()); | 686 mock_update_check_delegate_.AsWeakPtr()); |
| 691 task_runner_->RunUntilIdle(); | 687 scoped_task_environment_.RunUntilIdle(); |
| 692 } | 688 } |
| 693 | 689 |
| 694 // Test the case where the GoogleUpdate class can't be created for an upgrade. | 690 // Test the case where the GoogleUpdate class can't be created for an upgrade. |
| 695 TEST_P(GoogleUpdateWinTest, NoGoogleUpdateForUpgrade) { | 691 TEST_P(GoogleUpdateWinTest, NoGoogleUpdateForUpgrade) { |
| 696 // The factory should be called upon: let it fail. | 692 // The factory should be called upon: let it fail. |
| 697 EXPECT_CALL(mock_google_update_factory_, Create(_)); | 693 EXPECT_CALL(mock_google_update_factory_, Create(_)); |
| 698 | 694 |
| 699 // Expect the appropriate error when the on-demand class cannot be created. | 695 // Expect the appropriate error when the on-demand class cannot be created. |
| 700 EXPECT_CALL(mock_update_check_delegate_, | 696 EXPECT_CALL(mock_update_check_delegate_, |
| 701 OnError(GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND, _, _)); | 697 OnError(GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND, _, _)); |
| 702 BeginUpdateCheck(task_runner_, std::string(), true, 0, | 698 BeginUpdateCheck(std::string(), true, 0, |
| 703 mock_update_check_delegate_.AsWeakPtr()); | 699 mock_update_check_delegate_.AsWeakPtr()); |
| 704 task_runner_->RunUntilIdle(); | 700 scoped_task_environment_.RunUntilIdle(); |
| 705 } | 701 } |
| 706 | 702 |
| 707 // Test the case where the GoogleUpdate class returns an error when an update | 703 // Test the case where the GoogleUpdate class returns an error when an update |
| 708 // check is started. | 704 // check is started. |
| 709 TEST_P(GoogleUpdateWinTest, FailUpdateCheck) { | 705 TEST_P(GoogleUpdateWinTest, FailUpdateCheck) { |
| 710 CComObject<MockAppBundle>* mock_app_bundle = nullptr; | 706 CComObject<MockAppBundle>* mock_app_bundle = nullptr; |
| 711 MakeGoogleUpdateMocks(&mock_app_bundle, nullptr); | 707 MakeGoogleUpdateMocks(&mock_app_bundle, nullptr); |
| 712 | 708 |
| 713 // checkForUpdate will fail. | 709 // checkForUpdate will fail. |
| 714 EXPECT_CALL(*mock_app_bundle, checkForUpdate()) | 710 EXPECT_CALL(*mock_app_bundle, checkForUpdate()) |
| 715 .WillOnce(Return(E_FAIL)); | 711 .WillOnce(Return(E_FAIL)); |
| 716 | 712 |
| 717 EXPECT_CALL(mock_update_check_delegate_, | 713 EXPECT_CALL(mock_update_check_delegate_, |
| 718 OnError(GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR, _, _)); | 714 OnError(GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR, _, _)); |
| 719 BeginUpdateCheck(task_runner_, std::string(), false, 0, | 715 BeginUpdateCheck(std::string(), false, 0, |
| 720 mock_update_check_delegate_.AsWeakPtr()); | 716 mock_update_check_delegate_.AsWeakPtr()); |
| 721 task_runner_->RunUntilIdle(); | 717 scoped_task_environment_.RunUntilIdle(); |
| 722 } | 718 } |
| 723 | 719 |
| 724 // Test the case where the GoogleUpdate class reports that updates are disabled | 720 // Test the case where the GoogleUpdate class reports that updates are disabled |
| 725 // by Group Policy. | 721 // by Group Policy. |
| 726 TEST_P(GoogleUpdateWinTest, UpdatesDisabledByPolicy) { | 722 TEST_P(GoogleUpdateWinTest, UpdatesDisabledByPolicy) { |
| 727 static const HRESULT GOOPDATE_E_APP_UPDATE_DISABLED_BY_POLICY = 0x80040813; | 723 static const HRESULT GOOPDATE_E_APP_UPDATE_DISABLED_BY_POLICY = 0x80040813; |
| 728 | 724 |
| 729 CComObject<MockAppBundle>* mock_app_bundle = nullptr; | 725 CComObject<MockAppBundle>* mock_app_bundle = nullptr; |
| 730 CComObject<MockApp>* mock_app = nullptr; | 726 CComObject<MockApp>* mock_app = nullptr; |
| 731 MakeGoogleUpdateMocks(&mock_app_bundle, &mock_app); | 727 MakeGoogleUpdateMocks(&mock_app_bundle, &mock_app); |
| 732 | 728 |
| 733 // Expect the bundle to be called on to start the update. | 729 // Expect the bundle to be called on to start the update. |
| 734 EXPECT_CALL(*mock_app_bundle, checkForUpdate()) | 730 EXPECT_CALL(*mock_app_bundle, checkForUpdate()) |
| 735 .WillOnce(Return(S_OK)); | 731 .WillOnce(Return(S_OK)); |
| 736 | 732 |
| 737 mock_app->PushState(STATE_INIT); | 733 mock_app->PushState(STATE_INIT); |
| 738 mock_app->PushState(STATE_CHECKING_FOR_UPDATE); | 734 mock_app->PushState(STATE_CHECKING_FOR_UPDATE); |
| 739 mock_app->PushErrorState(GOOPDATE_E_APP_UPDATE_DISABLED_BY_POLICY, | 735 mock_app->PushErrorState(GOOPDATE_E_APP_UPDATE_DISABLED_BY_POLICY, |
| 740 L"disabled by policy", -1); | 736 L"disabled by policy", -1); |
| 741 | 737 |
| 742 EXPECT_CALL(mock_update_check_delegate_, | 738 EXPECT_CALL(mock_update_check_delegate_, |
| 743 OnError(GOOGLE_UPDATE_DISABLED_BY_POLICY, _, _)); | 739 OnError(GOOGLE_UPDATE_DISABLED_BY_POLICY, _, _)); |
| 744 BeginUpdateCheck(task_runner_, std::string(), false, 0, | 740 BeginUpdateCheck(std::string(), false, 0, |
| 745 mock_update_check_delegate_.AsWeakPtr()); | 741 mock_update_check_delegate_.AsWeakPtr()); |
| 746 task_runner_->RunUntilIdle(); | 742 scoped_task_environment_.RunUntilIdle(); |
| 747 } | 743 } |
| 748 | 744 |
| 749 // Test the case where the GoogleUpdate class reports that manual updates are | 745 // Test the case where the GoogleUpdate class reports that manual updates are |
| 750 // disabled by Group Policy, but that automatic updates are enabled. | 746 // disabled by Group Policy, but that automatic updates are enabled. |
| 751 TEST_P(GoogleUpdateWinTest, ManualUpdatesDisabledByPolicy) { | 747 TEST_P(GoogleUpdateWinTest, ManualUpdatesDisabledByPolicy) { |
| 752 static const HRESULT GOOPDATE_E_APP_UPDATE_DISABLED_BY_POLICY_MANUAL = | 748 static const HRESULT GOOPDATE_E_APP_UPDATE_DISABLED_BY_POLICY_MANUAL = |
| 753 0x8004081f; | 749 0x8004081f; |
| 754 | 750 |
| 755 CComObject<MockAppBundle>* mock_app_bundle = nullptr; | 751 CComObject<MockAppBundle>* mock_app_bundle = nullptr; |
| 756 CComObject<MockApp>* mock_app = nullptr; | 752 CComObject<MockApp>* mock_app = nullptr; |
| 757 MakeGoogleUpdateMocks(&mock_app_bundle, &mock_app); | 753 MakeGoogleUpdateMocks(&mock_app_bundle, &mock_app); |
| 758 | 754 |
| 759 // Expect the bundle to be called on to start the update. | 755 // Expect the bundle to be called on to start the update. |
| 760 EXPECT_CALL(*mock_app_bundle, checkForUpdate()) | 756 EXPECT_CALL(*mock_app_bundle, checkForUpdate()) |
| 761 .WillOnce(Return(S_OK)); | 757 .WillOnce(Return(S_OK)); |
| 762 | 758 |
| 763 mock_app->PushState(STATE_INIT); | 759 mock_app->PushState(STATE_INIT); |
| 764 mock_app->PushState(STATE_CHECKING_FOR_UPDATE); | 760 mock_app->PushState(STATE_CHECKING_FOR_UPDATE); |
| 765 mock_app->PushErrorState(GOOPDATE_E_APP_UPDATE_DISABLED_BY_POLICY_MANUAL, | 761 mock_app->PushErrorState(GOOPDATE_E_APP_UPDATE_DISABLED_BY_POLICY_MANUAL, |
| 766 L"manual updates disabled by policy", -1); | 762 L"manual updates disabled by policy", -1); |
| 767 | 763 |
| 768 EXPECT_CALL(mock_update_check_delegate_, | 764 EXPECT_CALL(mock_update_check_delegate_, |
| 769 OnError(GOOGLE_UPDATE_DISABLED_BY_POLICY_AUTO_ONLY, _, _)); | 765 OnError(GOOGLE_UPDATE_DISABLED_BY_POLICY_AUTO_ONLY, _, _)); |
| 770 BeginUpdateCheck(task_runner_, std::string(), false, 0, | 766 BeginUpdateCheck(std::string(), false, 0, |
| 771 mock_update_check_delegate_.AsWeakPtr()); | 767 mock_update_check_delegate_.AsWeakPtr()); |
| 772 task_runner_->RunUntilIdle(); | 768 scoped_task_environment_.RunUntilIdle(); |
| 773 } | 769 } |
| 774 | 770 |
| 775 // Test an update check where no update is available. | 771 // Test an update check where no update is available. |
| 776 TEST_P(GoogleUpdateWinTest, UpdateCheckNoUpdate) { | 772 TEST_P(GoogleUpdateWinTest, UpdateCheckNoUpdate) { |
| 777 CComObject<MockAppBundle>* mock_app_bundle = nullptr; | 773 CComObject<MockAppBundle>* mock_app_bundle = nullptr; |
| 778 CComObject<MockApp>* mock_app = nullptr; | 774 CComObject<MockApp>* mock_app = nullptr; |
| 779 MakeGoogleUpdateMocks(&mock_app_bundle, &mock_app); | 775 MakeGoogleUpdateMocks(&mock_app_bundle, &mock_app); |
| 780 | 776 |
| 781 // Expect the bundle to be called on to start the update. | 777 // Expect the bundle to be called on to start the update. |
| 782 EXPECT_CALL(*mock_app_bundle, checkForUpdate()) | 778 EXPECT_CALL(*mock_app_bundle, checkForUpdate()) |
| 783 .WillOnce(Return(S_OK)); | 779 .WillOnce(Return(S_OK)); |
| 784 | 780 |
| 785 mock_app->PushState(STATE_INIT); | 781 mock_app->PushState(STATE_INIT); |
| 786 mock_app->PushState(STATE_CHECKING_FOR_UPDATE); | 782 mock_app->PushState(STATE_CHECKING_FOR_UPDATE); |
| 787 mock_app->PushState(STATE_NO_UPDATE); | 783 mock_app->PushState(STATE_NO_UPDATE); |
| 788 | 784 |
| 789 EXPECT_CALL(mock_update_check_delegate_, | 785 EXPECT_CALL(mock_update_check_delegate_, |
| 790 OnUpdateCheckComplete(IsEmpty())); // new_version | 786 OnUpdateCheckComplete(IsEmpty())); // new_version |
| 791 BeginUpdateCheck(task_runner_, std::string(), false, 0, | 787 BeginUpdateCheck(std::string(), false, 0, |
| 792 mock_update_check_delegate_.AsWeakPtr()); | 788 mock_update_check_delegate_.AsWeakPtr()); |
| 793 task_runner_->RunUntilIdle(); | 789 scoped_task_environment_.RunUntilIdle(); |
| 794 } | 790 } |
| 795 | 791 |
| 796 // Test an update check where an update is available. | 792 // Test an update check where an update is available. |
| 797 TEST_P(GoogleUpdateWinTest, UpdateCheckUpdateAvailable) { | 793 TEST_P(GoogleUpdateWinTest, UpdateCheckUpdateAvailable) { |
| 798 CComObject<MockAppBundle>* mock_app_bundle = nullptr; | 794 CComObject<MockAppBundle>* mock_app_bundle = nullptr; |
| 799 CComObject<MockApp>* mock_app = nullptr; | 795 CComObject<MockApp>* mock_app = nullptr; |
| 800 MakeGoogleUpdateMocks(&mock_app_bundle, &mock_app); | 796 MakeGoogleUpdateMocks(&mock_app_bundle, &mock_app); |
| 801 | 797 |
| 802 // Expect the bundle to be called on to start the update. | 798 // Expect the bundle to be called on to start the update. |
| 803 EXPECT_CALL(*mock_app_bundle, checkForUpdate()) | 799 EXPECT_CALL(*mock_app_bundle, checkForUpdate()) |
| 804 .WillOnce(Return(S_OK)); | 800 .WillOnce(Return(S_OK)); |
| 805 | 801 |
| 806 mock_app->PushState(STATE_INIT); | 802 mock_app->PushState(STATE_INIT); |
| 807 mock_app->PushState(STATE_CHECKING_FOR_UPDATE); | 803 mock_app->PushState(STATE_CHECKING_FOR_UPDATE); |
| 808 mock_app->PushUpdateAvailableState(new_version_); | 804 mock_app->PushUpdateAvailableState(new_version_); |
| 809 | 805 |
| 810 EXPECT_CALL(mock_update_check_delegate_, | 806 EXPECT_CALL(mock_update_check_delegate_, |
| 811 OnUpdateCheckComplete(StrEq(new_version_))); | 807 OnUpdateCheckComplete(StrEq(new_version_))); |
| 812 BeginUpdateCheck(task_runner_, std::string(), false, 0, | 808 BeginUpdateCheck(std::string(), false, 0, |
| 813 mock_update_check_delegate_.AsWeakPtr()); | 809 mock_update_check_delegate_.AsWeakPtr()); |
| 814 task_runner_->RunUntilIdle(); | 810 scoped_task_environment_.RunUntilIdle(); |
| 815 } | 811 } |
| 816 | 812 |
| 817 // Test a successful upgrade. | 813 // Test a successful upgrade. |
| 818 TEST_P(GoogleUpdateWinTest, UpdateInstalled) { | 814 TEST_P(GoogleUpdateWinTest, UpdateInstalled) { |
| 819 CComObject<MockAppBundle>* mock_app_bundle = nullptr; | 815 CComObject<MockAppBundle>* mock_app_bundle = nullptr; |
| 820 CComObject<MockApp>* mock_app = nullptr; | 816 CComObject<MockApp>* mock_app = nullptr; |
| 821 MakeGoogleUpdateMocks(&mock_app_bundle, &mock_app); | 817 MakeGoogleUpdateMocks(&mock_app_bundle, &mock_app); |
| 822 | 818 |
| 823 // Expect the bundle to be called on to start the update. | 819 // Expect the bundle to be called on to start the update. |
| 824 EXPECT_CALL(*mock_app_bundle, checkForUpdate()) | 820 EXPECT_CALL(*mock_app_bundle, checkForUpdate()) |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 847 OnUpgradeProgress(12, StrEq(new_version_))); | 843 OnUpgradeProgress(12, StrEq(new_version_))); |
| 848 EXPECT_CALL(mock_update_check_delegate_, | 844 EXPECT_CALL(mock_update_check_delegate_, |
| 849 OnUpgradeProgress(37, StrEq(new_version_))); | 845 OnUpgradeProgress(37, StrEq(new_version_))); |
| 850 EXPECT_CALL(mock_update_check_delegate_, | 846 EXPECT_CALL(mock_update_check_delegate_, |
| 851 OnUpgradeProgress(50, StrEq(new_version_))); | 847 OnUpgradeProgress(50, StrEq(new_version_))); |
| 852 EXPECT_CALL(mock_update_check_delegate_, | 848 EXPECT_CALL(mock_update_check_delegate_, |
| 853 OnUpgradeProgress(75, StrEq(new_version_))); | 849 OnUpgradeProgress(75, StrEq(new_version_))); |
| 854 EXPECT_CALL(mock_update_check_delegate_, | 850 EXPECT_CALL(mock_update_check_delegate_, |
| 855 OnUpgradeComplete(StrEq(new_version_))); | 851 OnUpgradeComplete(StrEq(new_version_))); |
| 856 } | 852 } |
| 857 BeginUpdateCheck(task_runner_, std::string(), true, 0, | 853 BeginUpdateCheck(std::string(), true, 0, |
| 858 mock_update_check_delegate_.AsWeakPtr()); | 854 mock_update_check_delegate_.AsWeakPtr()); |
| 859 task_runner_->RunUntilIdle(); | 855 scoped_task_environment_.RunUntilIdle(); |
| 860 } | 856 } |
| 861 | 857 |
| 862 // Test a failed upgrade where Google Update reports that the installer failed. | 858 // Test a failed upgrade where Google Update reports that the installer failed. |
| 863 TEST_P(GoogleUpdateWinTest, UpdateFailed) { | 859 TEST_P(GoogleUpdateWinTest, UpdateFailed) { |
| 864 const base::string16 error(L"It didn't work."); | 860 const base::string16 error(L"It didn't work."); |
| 865 static const HRESULT GOOPDATEINSTALL_E_INSTALLER_FAILED = 0x80040902; | 861 static const HRESULT GOOPDATEINSTALL_E_INSTALLER_FAILED = 0x80040902; |
| 866 static const int kInstallerError = 12; | 862 static const int kInstallerError = 12; |
| 867 | 863 |
| 868 CComObject<MockAppBundle>* mock_app_bundle = nullptr; | 864 CComObject<MockAppBundle>* mock_app_bundle = nullptr; |
| 869 CComObject<MockApp>* mock_app = nullptr; | 865 CComObject<MockApp>* mock_app = nullptr; |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 898 EXPECT_CALL(mock_update_check_delegate_, | 894 EXPECT_CALL(mock_update_check_delegate_, |
| 899 OnUpgradeProgress(37, StrEq(new_version_))); | 895 OnUpgradeProgress(37, StrEq(new_version_))); |
| 900 EXPECT_CALL(mock_update_check_delegate_, | 896 EXPECT_CALL(mock_update_check_delegate_, |
| 901 OnUpgradeProgress(50, StrEq(new_version_))); | 897 OnUpgradeProgress(50, StrEq(new_version_))); |
| 902 EXPECT_CALL(mock_update_check_delegate_, | 898 EXPECT_CALL(mock_update_check_delegate_, |
| 903 OnUpgradeProgress(75, StrEq(new_version_))); | 899 OnUpgradeProgress(75, StrEq(new_version_))); |
| 904 EXPECT_CALL(mock_update_check_delegate_, | 900 EXPECT_CALL(mock_update_check_delegate_, |
| 905 OnError(GOOGLE_UPDATE_ERROR_UPDATING, HasSubstr(error), | 901 OnError(GOOGLE_UPDATE_ERROR_UPDATING, HasSubstr(error), |
| 906 StrEq(new_version_))); | 902 StrEq(new_version_))); |
| 907 } | 903 } |
| 908 BeginUpdateCheck(task_runner_, std::string(), true, 0, | 904 BeginUpdateCheck(std::string(), true, 0, |
| 909 mock_update_check_delegate_.AsWeakPtr()); | 905 mock_update_check_delegate_.AsWeakPtr()); |
| 910 task_runner_->RunUntilIdle(); | 906 scoped_task_environment_.RunUntilIdle(); |
| 911 } | 907 } |
| 912 | 908 |
| 913 // Test that a retry after a USING_EXTERNAL_UPDATER failure succeeds. | 909 // Test that a retry after a USING_EXTERNAL_UPDATER failure succeeds. |
| 914 TEST_P(GoogleUpdateWinTest, RetryAfterExternalUpdaterError) { | 910 TEST_P(GoogleUpdateWinTest, RetryAfterExternalUpdaterError) { |
| 915 static const HRESULT GOOPDATE_E_APP_USING_EXTERNAL_UPDATER = 0xa043081d; | 911 static const HRESULT GOOPDATE_E_APP_USING_EXTERNAL_UPDATER = 0xa043081d; |
| 916 | 912 |
| 917 CComObject<MockAppBundle>* mock_app_bundle = | 913 CComObject<MockAppBundle>* mock_app_bundle = |
| 918 mock_google_update_factory_.MakeServerMock()->MakeAppBundle(); | 914 mock_google_update_factory_.MakeServerMock()->MakeAppBundle(); |
| 919 | 915 |
| 920 // The first attempt will fail in createInstalledApp indicating that an update | 916 // The first attempt will fail in createInstalledApp indicating that an update |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 939 // Expect the bundle to be called on to start the update. | 935 // Expect the bundle to be called on to start the update. |
| 940 EXPECT_CALL(*mock_app_bundle, checkForUpdate()).WillOnce(Return(S_OK)); | 936 EXPECT_CALL(*mock_app_bundle, checkForUpdate()).WillOnce(Return(S_OK)); |
| 941 | 937 |
| 942 mock_app->PushState(STATE_INIT); | 938 mock_app->PushState(STATE_INIT); |
| 943 mock_app->PushState(STATE_CHECKING_FOR_UPDATE); | 939 mock_app->PushState(STATE_CHECKING_FOR_UPDATE); |
| 944 mock_app->PushState(STATE_NO_UPDATE); | 940 mock_app->PushState(STATE_NO_UPDATE); |
| 945 | 941 |
| 946 // Expect the update check to succeed. | 942 // Expect the update check to succeed. |
| 947 EXPECT_CALL(mock_update_check_delegate_, | 943 EXPECT_CALL(mock_update_check_delegate_, |
| 948 OnUpdateCheckComplete(IsEmpty())); // new_version | 944 OnUpdateCheckComplete(IsEmpty())); // new_version |
| 949 BeginUpdateCheck(task_runner_, std::string(), false, 0, | 945 BeginUpdateCheck(std::string(), false, 0, |
| 950 mock_update_check_delegate_.AsWeakPtr()); | 946 mock_update_check_delegate_.AsWeakPtr()); |
| 951 task_runner_->RunUntilIdle(); | 947 scoped_task_environment_.RunUntilIdle(); |
| 952 } | 948 } |
| 953 | 949 |
| 954 TEST_P(GoogleUpdateWinTest, UpdateInstalledMultipleDelegates) { | 950 TEST_P(GoogleUpdateWinTest, UpdateInstalledMultipleDelegates) { |
| 955 CComObject<MockAppBundle>* mock_app_bundle = nullptr; | 951 CComObject<MockAppBundle>* mock_app_bundle = nullptr; |
| 956 CComObject<MockApp>* mock_app = nullptr; | 952 CComObject<MockApp>* mock_app = nullptr; |
| 957 MakeGoogleUpdateMocks(&mock_app_bundle, &mock_app); | 953 MakeGoogleUpdateMocks(&mock_app_bundle, &mock_app); |
| 958 | 954 |
| 959 // Expect the bundle to be called on to start the update. | 955 // Expect the bundle to be called on to start the update. |
| 960 EXPECT_CALL(*mock_app_bundle, checkForUpdate()).WillOnce(Return(S_OK)); | 956 EXPECT_CALL(*mock_app_bundle, checkForUpdate()).WillOnce(Return(S_OK)); |
| 961 // Expect the bundle to be called on to start the install. | 957 // Expect the bundle to be called on to start the install. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 999 EXPECT_CALL(mock_update_check_delegate_, | 995 EXPECT_CALL(mock_update_check_delegate_, |
| 1000 OnUpgradeProgress(75, StrEq(new_version_))); | 996 OnUpgradeProgress(75, StrEq(new_version_))); |
| 1001 EXPECT_CALL(mock_update_check_delegate_2, | 997 EXPECT_CALL(mock_update_check_delegate_2, |
| 1002 OnUpgradeProgress(75, StrEq(new_version_))); | 998 OnUpgradeProgress(75, StrEq(new_version_))); |
| 1003 | 999 |
| 1004 EXPECT_CALL(mock_update_check_delegate_, | 1000 EXPECT_CALL(mock_update_check_delegate_, |
| 1005 OnUpgradeComplete(StrEq(new_version_))); | 1001 OnUpgradeComplete(StrEq(new_version_))); |
| 1006 EXPECT_CALL(mock_update_check_delegate_2, | 1002 EXPECT_CALL(mock_update_check_delegate_2, |
| 1007 OnUpgradeComplete(StrEq(new_version_))); | 1003 OnUpgradeComplete(StrEq(new_version_))); |
| 1008 } | 1004 } |
| 1009 BeginUpdateCheck(task_runner_, std::string(), true, 0, | 1005 BeginUpdateCheck(std::string(), true, 0, |
| 1010 mock_update_check_delegate_.AsWeakPtr()); | 1006 mock_update_check_delegate_.AsWeakPtr()); |
| 1011 BeginUpdateCheck(task_runner_, std::string(), true, 0, | 1007 BeginUpdateCheck(std::string(), true, 0, |
| 1012 mock_update_check_delegate_2.AsWeakPtr()); | 1008 mock_update_check_delegate_2.AsWeakPtr()); |
| 1013 task_runner_->RunUntilIdle(); | 1009 scoped_task_environment_.RunUntilIdle(); |
| 1014 } | 1010 } |
| 1015 | 1011 |
| 1016 INSTANTIATE_TEST_CASE_P(UserLevel, GoogleUpdateWinTest, Values(false)); | 1012 INSTANTIATE_TEST_CASE_P(UserLevel, GoogleUpdateWinTest, Values(false)); |
| 1017 | 1013 |
| 1018 INSTANTIATE_TEST_CASE_P(SystemLevel, GoogleUpdateWinTest, Values(true)); | 1014 INSTANTIATE_TEST_CASE_P(SystemLevel, GoogleUpdateWinTest, Values(true)); |
| OLD | NEW |