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

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

Issue 2207523002: Move on-demand update checks from the FILE thread to the blocking pool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@threadfix
Patch Set: pk review Created 4 years, 4 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
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
11 #include <map>
11 #include <memory> 12 #include <memory>
12 #include <queue> 13 #include <queue>
13 14
14 #include "base/base_paths.h" 15 #include "base/base_paths.h"
15 #include "base/bind.h" 16 #include "base/bind.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
18 #include "base/path_service.h" 19 #include "base/path_service.h"
19 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
20 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
21 #include "base/test/scoped_path_override.h" 22 #include "base/test/scoped_path_override.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/test/test_simple_task_runner.h"
24 #include "base/threading/thread_task_runner_handle.h" 25 #include "base/threading/thread_task_runner_handle.h"
25 #include "base/version.h" 26 #include "base/version.h"
26 #include "base/win/registry.h" 27 #include "base/win/registry.h"
28 #include "base/win/scoped_com_initializer.h"
27 #include "base/win/scoped_comptr.h" 29 #include "base/win/scoped_comptr.h"
28 #include "chrome/common/chrome_version.h" 30 #include "chrome/common/chrome_version.h"
29 #include "chrome/installer/util/browser_distribution.h" 31 #include "chrome/installer/util/browser_distribution.h"
30 #include "chrome/installer/util/google_update_settings.h" 32 #include "chrome/installer/util/google_update_settings.h"
31 #include "chrome/installer/util/helper.h" 33 #include "chrome/installer/util/helper.h"
32 #include "google_update/google_update_idl.h" 34 #include "google_update/google_update_idl.h"
33 #include "testing/gmock/include/gmock/gmock.h" 35 #include "testing/gmock/include/gmock/gmock.h"
34 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
35 #include "ui/base/win/atl_module.h" 37 #include "ui/base/win/atl_module.h"
36 38
37 using ::testing::DoAll; 39 using ::testing::DoAll;
38 using ::testing::HasSubstr; 40 using ::testing::HasSubstr;
39 using ::testing::InSequence; 41 using ::testing::InSequence;
42 using ::testing::InvokeWithoutArgs;
40 using ::testing::IsEmpty; 43 using ::testing::IsEmpty;
41 using ::testing::Return; 44 using ::testing::Return;
42 using ::testing::Sequence; 45 using ::testing::Sequence;
43 using ::testing::SetArgPointee; 46 using ::testing::SetArgPointee;
44 using ::testing::StrEq; 47 using ::testing::StrEq;
45 using ::testing::StrictMock; 48 using ::testing::StrictMock;
46 using ::testing::Values; 49 using ::testing::Values;
47 using ::testing::_; 50 using ::testing::_;
48 51
49 namespace { 52 namespace {
(...skipping 12 matching lines...) Expand all
62 MOCK_METHOD3(OnError, void(GoogleUpdateErrorCode, 65 MOCK_METHOD3(OnError, void(GoogleUpdateErrorCode,
63 const base::string16&, 66 const base::string16&,
64 const base::string16&)); 67 const base::string16&));
65 68
66 private: 69 private:
67 base::WeakPtrFactory<UpdateCheckDelegate> weak_ptr_factory_; 70 base::WeakPtrFactory<UpdateCheckDelegate> weak_ptr_factory_;
68 71
69 DISALLOW_COPY_AND_ASSIGN(MockUpdateCheckDelegate); 72 DISALLOW_COPY_AND_ASSIGN(MockUpdateCheckDelegate);
70 }; 73 };
71 74
75 // A fake implementation of the COM IGlobalInterfaceTable that holds and hands
76 // out object pointers.
77 class FakeGlobalInterfaceTable : public CComObjectRootEx<CComSingleThreadModel>,
78 public IGlobalInterfaceTable {
79 public:
80 BEGIN_COM_MAP(FakeGlobalInterfaceTable)
81 COM_INTERFACE_ENTRY(IGlobalInterfaceTable)
82 END_COM_MAP()
83
84 FakeGlobalInterfaceTable() = default;
85
86 HRESULT STDMETHODCALLTYPE RegisterInterfaceInGlobal(IUnknown* object,
87 REFIID,
88 DWORD* cookie) override {
89 objects_[++last_cookie_] = object;
90 *cookie = last_cookie_;
91 return S_OK;
92 }
93
94 HRESULT STDMETHODCALLTYPE RevokeInterfaceFromGlobal(DWORD cookie) override {
95 return objects_.erase(cookie) ? S_OK : E_INVALIDARG;
96 }
97
98 HRESULT STDMETHODCALLTYPE GetInterfaceFromGlobal(DWORD cookie,
99 REFIID,
100 void** object) override {
101 auto it = objects_.find(cookie);
102 if (it == objects_.end())
103 return E_INVALIDARG;
104 it->second.get()->AddRef();
105 *object = it->second.get();
106 return S_OK;
107 }
108
109 size_t empty() const { return objects_.empty(); }
110
111 private:
112 using CookieToObjectMap = std::map<DWORD, base::win::ScopedComPtr<IUnknown>>;
113
114 CookieToObjectMap objects_;
115 DWORD last_cookie_ = 0;
116
117 DISALLOW_COPY_AND_ASSIGN(FakeGlobalInterfaceTable);
118 };
119
72 // An interface that exposes a factory method for creating an IGoogleUpdate3Web 120 // An interface that exposes a factory method for creating an IGoogleUpdate3Web
73 // instance. 121 // instance.
74 class GoogleUpdateFactory { 122 class GoogleUpdateFactory {
75 public: 123 public:
76 virtual ~GoogleUpdateFactory() {} 124 virtual ~GoogleUpdateFactory() {}
77 virtual HRESULT Create( 125 virtual HRESULT Create(
78 base::win::ScopedComPtr<IGoogleUpdate3Web>* google_update) = 0; 126 base::win::ScopedComPtr<IGoogleUpdate3Web>* google_update) = 0;
79 }; 127 };
80 128
81 class MockCurrentState : public CComObjectRootEx<CComSingleThreadModel>, 129 class MockCurrentState : public CComObjectRootEx<CComSingleThreadModel>,
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 // in setting up expectations until a consumer obtains it via get_appWeb, at 459 // in setting up expectations until a consumer obtains it via get_appWeb, at
412 // which time it is owned by the consumer. 460 // which time it is owned by the consumer.
413 CComObject<MockApp>* MakeApp(const base::char16* app_guid) { 461 CComObject<MockApp>* MakeApp(const base::char16* app_guid) {
414 // The bundle will be called on to create the installed app. 462 // The bundle will be called on to create the installed app.
415 EXPECT_CALL(*this, createInstalledApp(StrEq(app_guid))) 463 EXPECT_CALL(*this, createInstalledApp(StrEq(app_guid)))
416 .WillOnce(Return(S_OK)); 464 .WillOnce(Return(S_OK));
417 465
418 CComObject<MockApp>* mock_app = nullptr; 466 CComObject<MockApp>* mock_app = nullptr;
419 EXPECT_EQ(S_OK, CComObject<MockApp>::CreateInstance(&mock_app)); 467 EXPECT_EQ(S_OK, CComObject<MockApp>::CreateInstance(&mock_app));
420 468
421 // Give mock_app_bundle a ref to the app which it will return when asked.
422 // Note: to support multiple apps, get_appWeb expectations should use 469 // Note: to support multiple apps, get_appWeb expectations should use
423 // successive indices. 470 // successive indices.
424 mock_app->AddRef(); 471 app_ = mock_app;
425 EXPECT_CALL(*this, get_appWeb(0, _)) 472 EXPECT_CALL(*this, get_appWeb(0, _))
426 .WillOnce(DoAll(SetArgPointee<1>(mock_app), 473 .WillRepeatedly(
427 Return(S_OK))); 474 DoAll(SetArgPointee<1>(mock_app),
475 InvokeWithoutArgs(mock_app, &CComObject<MockApp>::AddRef)));
428 476
429 return mock_app; 477 return mock_app;
430 } 478 }
431 479
432 private: 480 private:
481 base::win::ScopedComPtr<IAppWeb> app_;
482
433 DISALLOW_COPY_AND_ASSIGN(MockAppBundle); 483 DISALLOW_COPY_AND_ASSIGN(MockAppBundle);
434 }; 484 };
435 485
436 // A mock IGoogleUpdate3Web that can handle a call to initialize and 486 // A mock IGoogleUpdate3Web that can handle a call to initialize and
437 // createAppBundleWeb by consumers. 487 // createAppBundleWeb by consumers.
438 class MockGoogleUpdate : public CComObjectRootEx<CComSingleThreadModel>, 488 class MockGoogleUpdate : public CComObjectRootEx<CComSingleThreadModel>,
439 public IGoogleUpdate3Web { 489 public IGoogleUpdate3Web {
440 public: 490 public:
441 BEGIN_COM_MAP(MockGoogleUpdate) 491 BEGIN_COM_MAP(MockGoogleUpdate)
442 COM_INTERFACE_ENTRY(IGoogleUpdate3Web) 492 COM_INTERFACE_ENTRY(IGoogleUpdate3Web)
(...skipping 27 matching lines...) Expand all
470 // at which time it is owned by the consumer. 520 // at which time it is owned by the consumer.
471 CComObject<MockAppBundle>* MakeAppBundle() { 521 CComObject<MockAppBundle>* MakeAppBundle() {
472 CComObject<MockAppBundle>* mock_app_bundle = nullptr; 522 CComObject<MockAppBundle>* mock_app_bundle = nullptr;
473 EXPECT_EQ(S_OK, 523 EXPECT_EQ(S_OK,
474 CComObject<MockAppBundle>::CreateInstance(&mock_app_bundle)); 524 CComObject<MockAppBundle>::CreateInstance(&mock_app_bundle));
475 EXPECT_CALL(*mock_app_bundle, initialize()) 525 EXPECT_CALL(*mock_app_bundle, initialize())
476 .WillOnce(Return(S_OK)); 526 .WillOnce(Return(S_OK));
477 // Give this instance a ref to the bundle which it will return when created. 527 // Give this instance a ref to the bundle which it will return when created.
478 mock_app_bundle->AddRef(); 528 mock_app_bundle->AddRef();
479 EXPECT_CALL(*this, createAppBundleWeb(_)) 529 EXPECT_CALL(*this, createAppBundleWeb(_))
530 .InSequence(sequence_)
480 .WillOnce(DoAll(SetArgPointee<0>(mock_app_bundle), Return(S_OK))); 531 .WillOnce(DoAll(SetArgPointee<0>(mock_app_bundle), Return(S_OK)));
481 return mock_app_bundle; 532 return mock_app_bundle;
482 } 533 }
483 534
484 private: 535 private:
536 Sequence sequence_;
537
485 DISALLOW_COPY_AND_ASSIGN(MockGoogleUpdate); 538 DISALLOW_COPY_AND_ASSIGN(MockGoogleUpdate);
486 }; 539 };
487 540
488 // A mock factory for creating an IGoogleUpdate3Web instance. 541 // A mock factory for creating an IGoogleUpdate3Web instance.
489 class MockGoogleUpdateFactory : public GoogleUpdateFactory { 542 class MockGoogleUpdateFactory : public GoogleUpdateFactory {
490 public: 543 public:
491 MockGoogleUpdateFactory() {} 544 MockGoogleUpdateFactory() {}
492 MOCK_METHOD1(Create, HRESULT(base::win::ScopedComPtr<IGoogleUpdate3Web>*)); 545 MOCK_METHOD1(Create, HRESULT(base::win::ScopedComPtr<IGoogleUpdate3Web>*));
493 546
494 // Returns a mock IGoogleUpdate3Web object that will be returned by the 547 // Returns a mock IGoogleUpdate3Web object that will be returned by the
(...skipping 29 matching lines...) Expand all
524 // Configure all mock functions that return HRESULT to return failure. 577 // Configure all mock functions that return HRESULT to return failure.
525 ::testing::DefaultValue<HRESULT>::Set(E_FAIL); 578 ::testing::DefaultValue<HRESULT>::Set(E_FAIL);
526 } 579 }
527 580
528 static void TearDownTestCase() { ::testing::DefaultValue<HRESULT>::Clear(); } 581 static void TearDownTestCase() { ::testing::DefaultValue<HRESULT>::Clear(); }
529 582
530 protected: 583 protected:
531 GoogleUpdateWinTest() 584 GoogleUpdateWinTest()
532 : task_runner_(new base::TestSimpleTaskRunner()), 585 : task_runner_(new base::TestSimpleTaskRunner()),
533 task_runner_handle_(task_runner_), 586 task_runner_handle_(task_runner_),
534 system_level_install_(GetParam()) {} 587 system_level_install_(GetParam()),
588 fake_global_interface_table_(nullptr) {}
535 589
536 void SetUp() override { 590 void SetUp() override {
537 ::testing::TestWithParam<bool>::SetUp(); 591 ::testing::TestWithParam<bool>::SetUp();
538 592
539 // Override FILE_EXE so that it looks like the test is running from the 593 // Override FILE_EXE so that it looks like the test is running from the
540 // standard install location for this mode (system-level or user-level). 594 // standard install location for this mode (system-level or user-level).
541 base::FilePath file_exe; 595 base::FilePath file_exe;
542 ASSERT_TRUE(PathService::Get(base::FILE_EXE, &file_exe)); 596 ASSERT_TRUE(PathService::Get(base::FILE_EXE, &file_exe));
543 base::FilePath install_dir(installer::GetChromeInstallPath( 597 base::FilePath install_dir(installer::GetChromeInstallPath(
544 system_level_install_, BrowserDistribution::GetDistribution())); 598 system_level_install_, BrowserDistribution::GetDistribution()));
(...skipping 30 matching lines...) Expand all
575 ASSERT_EQ(ERROR_SUCCESS, 629 ASSERT_EQ(ERROR_SUCCESS,
576 key.Create(root, kClientState, KEY_WRITE | KEY_WOW64_32KEY)); 630 key.Create(root, kClientState, KEY_WRITE | KEY_WOW64_32KEY));
577 ASSERT_EQ(ERROR_SUCCESS, 631 ASSERT_EQ(ERROR_SUCCESS,
578 key.CreateKey(kChromeGuid, KEY_WRITE | KEY_WOW64_32KEY)); 632 key.CreateKey(kChromeGuid, KEY_WRITE | KEY_WOW64_32KEY));
579 ASSERT_EQ(ERROR_SUCCESS, 633 ASSERT_EQ(ERROR_SUCCESS,
580 key.WriteValue(L"UninstallArguments", 634 key.WriteValue(L"UninstallArguments",
581 L"--uninstall --multi-install --chrome")); 635 L"--uninstall --multi-install --chrome"));
582 636
583 // Provide an IGoogleUpdate3Web class factory so that this test can provide 637 // Provide an IGoogleUpdate3Web class factory so that this test can provide
584 // a mocked-out instance. 638 // a mocked-out instance.
585 SetGoogleUpdateFactoryForTesting( 639 SetUpdateCheckFactoriesForTesting(
640 base::Bind(&GoogleUpdateWinTest::GetFakeGlobalInterfaceTable,
641 base::Unretained(this)),
586 base::Bind(&GoogleUpdateFactory::Create, 642 base::Bind(&GoogleUpdateFactory::Create,
587 base::Unretained(&mock_google_update_factory_))); 643 base::Unretained(&mock_google_update_factory_)));
588 644
589 // Compute a newer version. 645 // Compute a newer version.
590 base::Version current_version(CHROME_VERSION_STRING); 646 base::Version current_version(CHROME_VERSION_STRING);
591 new_version_ = base::StringPrintf(L"%u.%u.%u.%u", 647 new_version_ = base::StringPrintf(L"%u.%u.%u.%u",
592 current_version.components()[0], 648 current_version.components()[0],
593 current_version.components()[1], 649 current_version.components()[1],
594 current_version.components()[2] + 1, 650 current_version.components()[2] + 1,
595 current_version.components()[3]); 651 current_version.components()[3]);
596 } 652 }
597 653
598 // Creates app bundle and app mocks that will be used to simulate Google 654 // Creates app bundle and app mocks that will be used to simulate Google
599 // Update. 655 // Update.
600 void MakeGoogleUpdateMocks(CComObject<MockAppBundle>** mock_app_bundle, 656 void MakeGoogleUpdateMocks(CComObject<MockAppBundle>** mock_app_bundle,
601 CComObject<MockApp>** mock_app) { 657 CComObject<MockApp>** mock_app) {
602 CComObject<MockGoogleUpdate>* google_update = 658 CComObject<MockGoogleUpdate>* google_update =
603 mock_google_update_factory_.MakeServerMock(); 659 mock_google_update_factory_.MakeServerMock();
604 CComObject<MockAppBundle>* app_bundle = google_update->MakeAppBundle(); 660 CComObject<MockAppBundle>* app_bundle = google_update->MakeAppBundle();
605 CComObject<MockApp>* app = app_bundle->MakeApp(kChromeBinariesGuid); 661 CComObject<MockApp>* app = app_bundle->MakeApp(kChromeBinariesGuid);
606 662
607 if (mock_app_bundle) 663 if (mock_app_bundle)
608 *mock_app_bundle = app_bundle; 664 *mock_app_bundle = app_bundle;
609 if (mock_app) 665 if (mock_app)
610 *mock_app = app; 666 *mock_app = app;
611 } 667 }
612 668
613 void TearDown() override { 669 void TearDown() override {
670 // Be sure all objects were removed from the Global Interface Table.
671 if (fake_global_interface_table_) {
672 ASSERT_TRUE(fake_global_interface_table_->empty());
673 global_interface_table_.Release();
674 fake_global_interface_table_ = nullptr;
675 }
676
614 // Remove the test's IGoogleUpdate on-demand update class factory. 677 // Remove the test's IGoogleUpdate on-demand update class factory.
615 SetGoogleUpdateFactoryForTesting(GoogleUpdate3ClassFactory()); 678 SetUpdateCheckFactoriesForTesting(GlobalInterfaceTableClassFactory(),
679 GoogleUpdate3ClassFactory());
616 ::testing::TestWithParam<bool>::TearDown(); 680 ::testing::TestWithParam<bool>::TearDown();
617 } 681 }
618 682
683 HRESULT GetFakeGlobalInterfaceTable(
684 base::win::ScopedComPtr<IGlobalInterfaceTable>* global_interface_table) {
685 if (!fake_global_interface_table_) {
686 EXPECT_EQ(S_OK, CComObject<FakeGlobalInterfaceTable>::CreateInstance(
687 &fake_global_interface_table_));
688 EXPECT_NE(nullptr, fake_global_interface_table_);
689 global_interface_table_ = fake_global_interface_table_;
690 }
691 *global_interface_table = global_interface_table_;
692 return S_OK;
693 }
694
619 static const base::char16 kClients[]; 695 static const base::char16 kClients[];
620 static const base::char16 kClientState[]; 696 static const base::char16 kClientState[];
621 static const base::char16 kChromeGuid[]; 697 static const base::char16 kChromeGuid[];
622 static const base::char16 kChromeBinariesGuid[]; 698 static const base::char16 kChromeBinariesGuid[];
623 699
700 base::win::ScopedCOMInitializer com_initializer_;
624 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 701 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
625 base::ThreadTaskRunnerHandle task_runner_handle_; 702 base::ThreadTaskRunnerHandle task_runner_handle_;
626 bool system_level_install_; 703 bool system_level_install_;
627 std::unique_ptr<base::ScopedPathOverride> file_exe_override_; 704 std::unique_ptr<base::ScopedPathOverride> file_exe_override_;
628 std::unique_ptr<base::ScopedPathOverride> program_files_override_; 705 std::unique_ptr<base::ScopedPathOverride> program_files_override_;
629 std::unique_ptr<base::ScopedPathOverride> program_files_x86_override_; 706 std::unique_ptr<base::ScopedPathOverride> program_files_x86_override_;
630 std::unique_ptr<base::ScopedPathOverride> local_app_data_override_; 707 std::unique_ptr<base::ScopedPathOverride> local_app_data_override_;
631 registry_util::RegistryOverrideManager registry_override_manager_; 708 registry_util::RegistryOverrideManager registry_override_manager_;
632 709
710 CComObject<FakeGlobalInterfaceTable>* fake_global_interface_table_;
711 base::win::ScopedComPtr<IGlobalInterfaceTable> global_interface_table_;
712
633 // A mock object, the OnUpdateCheckCallback method of which will be invoked 713 // A mock object, the OnUpdateCheckCallback method of which will be invoked
634 // each time the update check machinery invokes the given UpdateCheckCallback. 714 // each time the update check machinery invokes the given UpdateCheckCallback.
635 StrictMock<MockUpdateCheckDelegate> mock_update_check_delegate_; 715 StrictMock<MockUpdateCheckDelegate> mock_update_check_delegate_;
636 716
637 // A mock object that provides a GoogleUpdate3ClassFactory by which the test 717 // A mock object that provides a GoogleUpdate3ClassFactory by which the test
638 // fixture's IGoogleUpdate3Web simulator is provided to the update check 718 // fixture's IGoogleUpdate3Web simulator is provided to the update check
639 // machinery. 719 // machinery.
640 StrictMock<MockGoogleUpdateFactory> mock_google_update_factory_; 720 StrictMock<MockGoogleUpdateFactory> mock_google_update_factory_;
641 721
642 // The new version that the fixture will pretend is available. 722 // The new version that the fixture will pretend is available.
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 } 987 }
908 BeginUpdateCheck(task_runner_, std::string(), true, 0, 988 BeginUpdateCheck(task_runner_, std::string(), true, 0,
909 mock_update_check_delegate_.AsWeakPtr()); 989 mock_update_check_delegate_.AsWeakPtr());
910 task_runner_->RunUntilIdle(); 990 task_runner_->RunUntilIdle();
911 } 991 }
912 992
913 // Test that a retry after a USING_EXTERNAL_UPDATER failure succeeds. 993 // Test that a retry after a USING_EXTERNAL_UPDATER failure succeeds.
914 TEST_P(GoogleUpdateWinTest, RetryAfterExternalUpdaterError) { 994 TEST_P(GoogleUpdateWinTest, RetryAfterExternalUpdaterError) {
915 static const HRESULT GOOPDATE_E_APP_USING_EXTERNAL_UPDATER = 0xa043081d; 995 static const HRESULT GOOPDATE_E_APP_USING_EXTERNAL_UPDATER = 0xa043081d;
916 996
917 CComObject<MockAppBundle>* mock_app_bundle = 997 CComObject<MockGoogleUpdate>* google_update =
918 mock_google_update_factory_.MakeServerMock()->MakeAppBundle(); 998 mock_google_update_factory_.MakeServerMock();
999 CComObject<MockAppBundle>* mock_app_bundle = google_update->MakeAppBundle();
919 1000
920 // The first attempt will fail in createInstalledApp indicating that an update 1001 // The first attempt will fail in createInstalledApp indicating that an update
921 // is already in progress. 1002 // is already in progress.
922 Sequence bundle_seq;
923 EXPECT_CALL(*mock_app_bundle, createInstalledApp(StrEq(kChromeBinariesGuid))) 1003 EXPECT_CALL(*mock_app_bundle, createInstalledApp(StrEq(kChromeBinariesGuid)))
924 .InSequence(bundle_seq)
925 .WillOnce(Return(GOOPDATE_E_APP_USING_EXTERNAL_UPDATER)); 1004 .WillOnce(Return(GOOPDATE_E_APP_USING_EXTERNAL_UPDATER));
926 1005
927 // Expect a retry on the same instance. 1006 // Expect a retry on a new bundle.
928 EXPECT_CALL(*mock_app_bundle, createInstalledApp(StrEq(kChromeBinariesGuid))) 1007 mock_app_bundle = google_update->MakeAppBundle();
929 .InSequence(bundle_seq) 1008 CComObject<MockApp>* mock_app = mock_app_bundle->MakeApp(kChromeBinariesGuid);
930 .WillOnce(Return(S_OK));
931
932 // See MakeApp() for an explanation of this:
933 CComObject<MockApp>* mock_app = nullptr;
934 EXPECT_EQ(S_OK, CComObject<MockApp>::CreateInstance(&mock_app));
935 mock_app->AddRef();
936 EXPECT_CALL(*mock_app_bundle, get_appWeb(0, _))
937 .WillOnce(DoAll(SetArgPointee<1>(mock_app), Return(S_OK)));
938 1009
939 // Expect the bundle to be called on to start the update. 1010 // Expect the bundle to be called on to start the update.
940 EXPECT_CALL(*mock_app_bundle, checkForUpdate()).WillOnce(Return(S_OK)); 1011 EXPECT_CALL(*mock_app_bundle, checkForUpdate()).WillOnce(Return(S_OK));
941 1012
942 mock_app->PushState(STATE_INIT); 1013 mock_app->PushState(STATE_INIT);
943 mock_app->PushState(STATE_CHECKING_FOR_UPDATE); 1014 mock_app->PushState(STATE_CHECKING_FOR_UPDATE);
944 mock_app->PushState(STATE_NO_UPDATE); 1015 mock_app->PushState(STATE_NO_UPDATE);
945 1016
946 // Expect the update check to succeed. 1017 // Expect the update check to succeed.
947 EXPECT_CALL(mock_update_check_delegate_, 1018 EXPECT_CALL(mock_update_check_delegate_,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 BeginUpdateCheck(task_runner_, std::string(), true, 0, 1080 BeginUpdateCheck(task_runner_, std::string(), true, 0,
1010 mock_update_check_delegate_.AsWeakPtr()); 1081 mock_update_check_delegate_.AsWeakPtr());
1011 BeginUpdateCheck(task_runner_, std::string(), true, 0, 1082 BeginUpdateCheck(task_runner_, std::string(), true, 0,
1012 mock_update_check_delegate_2.AsWeakPtr()); 1083 mock_update_check_delegate_2.AsWeakPtr());
1013 task_runner_->RunUntilIdle(); 1084 task_runner_->RunUntilIdle();
1014 } 1085 }
1015 1086
1016 INSTANTIATE_TEST_CASE_P(UserLevel, GoogleUpdateWinTest, Values(false)); 1087 INSTANTIATE_TEST_CASE_P(UserLevel, GoogleUpdateWinTest, Values(false));
1017 1088
1018 INSTANTIATE_TEST_CASE_P(SystemLevel, GoogleUpdateWinTest, Values(true)); 1089 INSTANTIATE_TEST_CASE_P(SystemLevel, GoogleUpdateWinTest, Values(true));
OLDNEW
« no previous file with comments | « chrome/browser/google/google_update_win.cc ('k') | chrome/browser/ui/webui/help/version_updater_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698