Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: chrome/browser/google/google_update_win_unittest.cc

Issue 2622293002: Remove traces of multi-install from GoogleUpdateWinTest. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 program_files_x86_override_.reset( 556 program_files_x86_override_.reset(
557 new base::ScopedPathOverride(base::DIR_PROGRAM_FILESX86, temp)); 557 new base::ScopedPathOverride(base::DIR_PROGRAM_FILESX86, temp));
558 PathService::Get(base::DIR_LOCAL_APP_DATA, &temp); 558 PathService::Get(base::DIR_LOCAL_APP_DATA, &temp);
559 local_app_data_override_.reset( 559 local_app_data_override_.reset(
560 new base::ScopedPathOverride(base::DIR_LOCAL_APP_DATA, temp)); 560 new base::ScopedPathOverride(base::DIR_LOCAL_APP_DATA, temp));
561 561
562 // Override the registry so that tests can freely push state to it. 562 // Override the registry so that tests can freely push state to it.
563 registry_override_manager_.OverrideRegistry(HKEY_CURRENT_USER); 563 registry_override_manager_.OverrideRegistry(HKEY_CURRENT_USER);
564 registry_override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE); 564 registry_override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE);
565 565
566 // Chrome is installed as multi-install. 566 // Chrome is installed.
567 const HKEY root = 567 const HKEY root =
568 system_level_install_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 568 system_level_install_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
569 base::win::RegKey key(root, kClients, KEY_WRITE | KEY_WOW64_32KEY); 569 base::win::RegKey key(root, kClients, KEY_WRITE | KEY_WOW64_32KEY);
570 ASSERT_EQ(ERROR_SUCCESS, 570 ASSERT_EQ(ERROR_SUCCESS,
571 key.CreateKey(kChromeGuid, KEY_WRITE | KEY_WOW64_32KEY)); 571 key.CreateKey(kChromeGuid, KEY_WRITE | KEY_WOW64_32KEY));
572 ASSERT_EQ(ERROR_SUCCESS, 572 ASSERT_EQ(ERROR_SUCCESS,
573 key.WriteValue( 573 key.WriteValue(
574 L"pv", base::ASCIIToUTF16(CHROME_VERSION_STRING).c_str())); 574 L"pv", base::ASCIIToUTF16(CHROME_VERSION_STRING).c_str()));
575 ASSERT_EQ(ERROR_SUCCESS, 575 ASSERT_EQ(ERROR_SUCCESS,
576 key.Create(root, kClientState, KEY_WRITE | KEY_WOW64_32KEY)); 576 key.Create(root, kClientState, KEY_WRITE | KEY_WOW64_32KEY));
577 ASSERT_EQ(ERROR_SUCCESS, 577 ASSERT_EQ(ERROR_SUCCESS,
578 key.CreateKey(kChromeGuid, KEY_WRITE | KEY_WOW64_32KEY)); 578 key.CreateKey(kChromeGuid, KEY_WRITE | KEY_WOW64_32KEY));
579 ASSERT_EQ(ERROR_SUCCESS, 579 ASSERT_EQ(ERROR_SUCCESS,
580 key.WriteValue(L"UninstallArguments", 580 key.WriteValue(L"UninstallArguments", L"--uninstall"));
581 L"--uninstall --multi-install --chrome"));
582 581
583 // Provide an IGoogleUpdate3Web class factory so that this test can provide 582 // Provide an IGoogleUpdate3Web class factory so that this test can provide
584 // a mocked-out instance. 583 // a mocked-out instance.
585 SetGoogleUpdateFactoryForTesting( 584 SetGoogleUpdateFactoryForTesting(
586 base::Bind(&GoogleUpdateFactory::Create, 585 base::Bind(&GoogleUpdateFactory::Create,
587 base::Unretained(&mock_google_update_factory_))); 586 base::Unretained(&mock_google_update_factory_)));
588 587
589 // Compute a newer version. 588 // Compute a newer version.
590 base::Version current_version(CHROME_VERSION_STRING); 589 base::Version current_version(CHROME_VERSION_STRING);
591 new_version_ = base::StringPrintf(L"%u.%u.%u.%u", 590 new_version_ = base::StringPrintf(L"%u.%u.%u.%u",
592 current_version.components()[0], 591 current_version.components()[0],
593 current_version.components()[1], 592 current_version.components()[1],
594 current_version.components()[2] + 1, 593 current_version.components()[2] + 1,
595 current_version.components()[3]); 594 current_version.components()[3]);
596 } 595 }
597 596
598 // Creates app bundle and app mocks that will be used to simulate Google 597 // Creates app bundle and app mocks that will be used to simulate Google
599 // Update. 598 // Update.
600 void MakeGoogleUpdateMocks(CComObject<MockAppBundle>** mock_app_bundle, 599 void MakeGoogleUpdateMocks(CComObject<MockAppBundle>** mock_app_bundle,
601 CComObject<MockApp>** mock_app) { 600 CComObject<MockApp>** mock_app) {
602 CComObject<MockGoogleUpdate>* google_update = 601 CComObject<MockGoogleUpdate>* google_update =
603 mock_google_update_factory_.MakeServerMock(); 602 mock_google_update_factory_.MakeServerMock();
604 CComObject<MockAppBundle>* app_bundle = google_update->MakeAppBundle(); 603 CComObject<MockAppBundle>* app_bundle = google_update->MakeAppBundle();
605 CComObject<MockApp>* app = app_bundle->MakeApp(kChromeBinariesGuid); 604 CComObject<MockApp>* app = app_bundle->MakeApp(kChromeGuid);
606 605
607 if (mock_app_bundle) 606 if (mock_app_bundle)
608 *mock_app_bundle = app_bundle; 607 *mock_app_bundle = app_bundle;
609 if (mock_app) 608 if (mock_app)
610 *mock_app = app; 609 *mock_app = app;
611 } 610 }
612 611
613 void TearDown() override { 612 void TearDown() override {
614 // Remove the test's IGoogleUpdate on-demand update class factory. 613 // Remove the test's IGoogleUpdate on-demand update class factory.
615 SetGoogleUpdateFactoryForTesting(GoogleUpdate3ClassFactory()); 614 SetGoogleUpdateFactoryForTesting(GoogleUpdate3ClassFactory());
616 ::testing::TestWithParam<bool>::TearDown(); 615 ::testing::TestWithParam<bool>::TearDown();
617 } 616 }
618 617
619 static const base::char16 kClients[]; 618 static const base::char16 kClients[];
620 static const base::char16 kClientState[]; 619 static const base::char16 kClientState[];
621 static const base::char16 kChromeGuid[]; 620 static const base::char16 kChromeGuid[];
622 static const base::char16 kChromeBinariesGuid[];
623 621
624 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 622 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
625 base::ThreadTaskRunnerHandle task_runner_handle_; 623 base::ThreadTaskRunnerHandle task_runner_handle_;
626 bool system_level_install_; 624 bool system_level_install_;
627 std::unique_ptr<base::ScopedPathOverride> file_exe_override_; 625 std::unique_ptr<base::ScopedPathOverride> file_exe_override_;
628 std::unique_ptr<base::ScopedPathOverride> program_files_override_; 626 std::unique_ptr<base::ScopedPathOverride> program_files_override_;
629 std::unique_ptr<base::ScopedPathOverride> program_files_x86_override_; 627 std::unique_ptr<base::ScopedPathOverride> program_files_x86_override_;
630 std::unique_ptr<base::ScopedPathOverride> local_app_data_override_; 628 std::unique_ptr<base::ScopedPathOverride> local_app_data_override_;
631 registry_util::RegistryOverrideManager registry_override_manager_; 629 registry_util::RegistryOverrideManager registry_override_manager_;
632 630
(...skipping 13 matching lines...) Expand all
646 DISALLOW_COPY_AND_ASSIGN(GoogleUpdateWinTest); 644 DISALLOW_COPY_AND_ASSIGN(GoogleUpdateWinTest);
647 }; 645 };
648 646
649 // static 647 // static
650 const base::char16 GoogleUpdateWinTest::kClients[] = 648 const base::char16 GoogleUpdateWinTest::kClients[] =
651 L"Software\\Google\\Update\\Clients"; 649 L"Software\\Google\\Update\\Clients";
652 const base::char16 GoogleUpdateWinTest::kClientState[] = 650 const base::char16 GoogleUpdateWinTest::kClientState[] =
653 L"Software\\Google\\Update\\ClientState"; 651 L"Software\\Google\\Update\\ClientState";
654 const base::char16 GoogleUpdateWinTest::kChromeGuid[] = 652 const base::char16 GoogleUpdateWinTest::kChromeGuid[] =
655 L"{8A69D345-D564-463c-AFF1-A69D9E530F96}"; 653 L"{8A69D345-D564-463c-AFF1-A69D9E530F96}";
656 const base::char16 GoogleUpdateWinTest::kChromeBinariesGuid[] =
657 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}";
658 654
659 // Test that an update check fails with the proper error code if Chrome isn't in 655 // Test that an update check fails with the proper error code if Chrome isn't in
660 // one of the expected install directories. 656 // one of the expected install directories.
661 TEST_P(GoogleUpdateWinTest, InvalidInstallDirectory) { 657 TEST_P(GoogleUpdateWinTest, InvalidInstallDirectory) {
662 // Override FILE_EXE so that it looks like the test is running from a 658 // Override FILE_EXE so that it looks like the test is running from a
663 // non-standard location. 659 // non-standard location.
664 base::FilePath file_exe; 660 base::FilePath file_exe;
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));
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
921 // is already in progress. 917 // is already in progress.
922 Sequence bundle_seq; 918 Sequence bundle_seq;
923 EXPECT_CALL(*mock_app_bundle, createInstalledApp(StrEq(kChromeBinariesGuid))) 919 EXPECT_CALL(*mock_app_bundle, createInstalledApp(StrEq(kChromeGuid)))
924 .InSequence(bundle_seq) 920 .InSequence(bundle_seq)
925 .WillOnce(Return(GOOPDATE_E_APP_USING_EXTERNAL_UPDATER)); 921 .WillOnce(Return(GOOPDATE_E_APP_USING_EXTERNAL_UPDATER));
926 922
927 // Expect a retry on the same instance. 923 // Expect a retry on the same instance.
928 EXPECT_CALL(*mock_app_bundle, createInstalledApp(StrEq(kChromeBinariesGuid))) 924 EXPECT_CALL(*mock_app_bundle, createInstalledApp(StrEq(kChromeGuid)))
929 .InSequence(bundle_seq) 925 .InSequence(bundle_seq)
930 .WillOnce(Return(S_OK)); 926 .WillOnce(Return(S_OK));
931 927
932 // See MakeApp() for an explanation of this: 928 // See MakeApp() for an explanation of this:
933 CComObject<MockApp>* mock_app = nullptr; 929 CComObject<MockApp>* mock_app = nullptr;
934 EXPECT_EQ(S_OK, CComObject<MockApp>::CreateInstance(&mock_app)); 930 EXPECT_EQ(S_OK, CComObject<MockApp>::CreateInstance(&mock_app));
935 mock_app->AddRef(); 931 mock_app->AddRef();
936 EXPECT_CALL(*mock_app_bundle, get_appWeb(0, _)) 932 EXPECT_CALL(*mock_app_bundle, get_appWeb(0, _))
937 .WillOnce(DoAll(SetArgPointee<1>(mock_app), Return(S_OK))); 933 .WillOnce(DoAll(SetArgPointee<1>(mock_app), Return(S_OK)));
938 934
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 BeginUpdateCheck(task_runner_, std::string(), true, 0, 1005 BeginUpdateCheck(task_runner_, 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(task_runner_, std::string(), true, 0,
1012 mock_update_check_delegate_2.AsWeakPtr()); 1008 mock_update_check_delegate_2.AsWeakPtr());
1013 task_runner_->RunUntilIdle(); 1009 task_runner_->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));
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698