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

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: GitCookie 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 FakeGit : public CComObjectRootEx<CComSingleThreadModel>,
78 public IGlobalInterfaceTable {
79 public:
80 BEGIN_COM_MAP(FakeGit)
81 COM_INTERFACE_ENTRY(IGlobalInterfaceTable)
82 END_COM_MAP()
83
84 FakeGit() = 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 size() const { return objects_.size(); }
110
111 private:
112 using CookieToObjectMap = std::map<DWORD, base::win::ScopedComPtr<IUnknown>>;
113
114 CookieToObjectMap objects_;
115 DWORD last_cookie_ = 0;
116 };
Peter Kasting 2016/08/03 01:24:34 Nit: DISALLOW_COPY_AND_ASSIGN?
grt (UTC plus 2) 2016/08/03 05:36:31 Done.
117
72 // An interface that exposes a factory method for creating an IGoogleUpdate3Web 118 // An interface that exposes a factory method for creating an IGoogleUpdate3Web
73 // instance. 119 // instance.
74 class GoogleUpdateFactory { 120 class GoogleUpdateFactory {
75 public: 121 public:
76 virtual ~GoogleUpdateFactory() {} 122 virtual ~GoogleUpdateFactory() {}
77 virtual HRESULT Create( 123 virtual HRESULT Create(
78 base::win::ScopedComPtr<IGoogleUpdate3Web>* google_update) = 0; 124 base::win::ScopedComPtr<IGoogleUpdate3Web>* google_update) = 0;
79 }; 125 };
80 126
81 class MockCurrentState : public CComObjectRootEx<CComSingleThreadModel>, 127 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 457 // in setting up expectations until a consumer obtains it via get_appWeb, at
412 // which time it is owned by the consumer. 458 // which time it is owned by the consumer.
413 CComObject<MockApp>* MakeApp(const base::char16* app_guid) { 459 CComObject<MockApp>* MakeApp(const base::char16* app_guid) {
414 // The bundle will be called on to create the installed app. 460 // The bundle will be called on to create the installed app.
415 EXPECT_CALL(*this, createInstalledApp(StrEq(app_guid))) 461 EXPECT_CALL(*this, createInstalledApp(StrEq(app_guid)))
416 .WillOnce(Return(S_OK)); 462 .WillOnce(Return(S_OK));
417 463
418 CComObject<MockApp>* mock_app = nullptr; 464 CComObject<MockApp>* mock_app = nullptr;
419 EXPECT_EQ(S_OK, CComObject<MockApp>::CreateInstance(&mock_app)); 465 EXPECT_EQ(S_OK, CComObject<MockApp>::CreateInstance(&mock_app));
420 466
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 467 // Note: to support multiple apps, get_appWeb expectations should use
423 // successive indices. 468 // successive indices.
424 mock_app->AddRef(); 469 app_ = mock_app;
425 EXPECT_CALL(*this, get_appWeb(0, _)) 470 EXPECT_CALL(*this, get_appWeb(0, _))
426 .WillOnce(DoAll(SetArgPointee<1>(mock_app), 471 .WillRepeatedly(
427 Return(S_OK))); 472 DoAll(SetArgPointee<1>(mock_app),
473 InvokeWithoutArgs(mock_app, &CComObject<MockApp>::AddRef)));
428 474
429 return mock_app; 475 return mock_app;
430 } 476 }
431 477
432 private: 478 private:
479 base::win::ScopedComPtr<IAppWeb> app_;
480
433 DISALLOW_COPY_AND_ASSIGN(MockAppBundle); 481 DISALLOW_COPY_AND_ASSIGN(MockAppBundle);
434 }; 482 };
435 483
436 // A mock IGoogleUpdate3Web that can handle a call to initialize and 484 // A mock IGoogleUpdate3Web that can handle a call to initialize and
437 // createAppBundleWeb by consumers. 485 // createAppBundleWeb by consumers.
438 class MockGoogleUpdate : public CComObjectRootEx<CComSingleThreadModel>, 486 class MockGoogleUpdate : public CComObjectRootEx<CComSingleThreadModel>,
439 public IGoogleUpdate3Web { 487 public IGoogleUpdate3Web {
440 public: 488 public:
441 BEGIN_COM_MAP(MockGoogleUpdate) 489 BEGIN_COM_MAP(MockGoogleUpdate)
442 COM_INTERFACE_ENTRY(IGoogleUpdate3Web) 490 COM_INTERFACE_ENTRY(IGoogleUpdate3Web)
(...skipping 27 matching lines...) Expand all
470 // at which time it is owned by the consumer. 518 // at which time it is owned by the consumer.
471 CComObject<MockAppBundle>* MakeAppBundle() { 519 CComObject<MockAppBundle>* MakeAppBundle() {
472 CComObject<MockAppBundle>* mock_app_bundle = nullptr; 520 CComObject<MockAppBundle>* mock_app_bundle = nullptr;
473 EXPECT_EQ(S_OK, 521 EXPECT_EQ(S_OK,
474 CComObject<MockAppBundle>::CreateInstance(&mock_app_bundle)); 522 CComObject<MockAppBundle>::CreateInstance(&mock_app_bundle));
475 EXPECT_CALL(*mock_app_bundle, initialize()) 523 EXPECT_CALL(*mock_app_bundle, initialize())
476 .WillOnce(Return(S_OK)); 524 .WillOnce(Return(S_OK));
477 // Give this instance a ref to the bundle which it will return when created. 525 // Give this instance a ref to the bundle which it will return when created.
478 mock_app_bundle->AddRef(); 526 mock_app_bundle->AddRef();
479 EXPECT_CALL(*this, createAppBundleWeb(_)) 527 EXPECT_CALL(*this, createAppBundleWeb(_))
528 .InSequence(sequence_)
480 .WillOnce(DoAll(SetArgPointee<0>(mock_app_bundle), Return(S_OK))); 529 .WillOnce(DoAll(SetArgPointee<0>(mock_app_bundle), Return(S_OK)));
481 return mock_app_bundle; 530 return mock_app_bundle;
482 } 531 }
483 532
484 private: 533 private:
534 Sequence sequence_;
535
485 DISALLOW_COPY_AND_ASSIGN(MockGoogleUpdate); 536 DISALLOW_COPY_AND_ASSIGN(MockGoogleUpdate);
486 }; 537 };
487 538
488 // A mock factory for creating an IGoogleUpdate3Web instance. 539 // A mock factory for creating an IGoogleUpdate3Web instance.
489 class MockGoogleUpdateFactory : public GoogleUpdateFactory { 540 class MockGoogleUpdateFactory : public GoogleUpdateFactory {
490 public: 541 public:
491 MockGoogleUpdateFactory() {} 542 MockGoogleUpdateFactory() {}
492 MOCK_METHOD1(Create, HRESULT(base::win::ScopedComPtr<IGoogleUpdate3Web>*)); 543 MOCK_METHOD1(Create, HRESULT(base::win::ScopedComPtr<IGoogleUpdate3Web>*));
493 544
494 // Returns a mock IGoogleUpdate3Web object that will be returned by the 545 // 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. 575 // Configure all mock functions that return HRESULT to return failure.
525 ::testing::DefaultValue<HRESULT>::Set(E_FAIL); 576 ::testing::DefaultValue<HRESULT>::Set(E_FAIL);
526 } 577 }
527 578
528 static void TearDownTestCase() { ::testing::DefaultValue<HRESULT>::Clear(); } 579 static void TearDownTestCase() { ::testing::DefaultValue<HRESULT>::Clear(); }
529 580
530 protected: 581 protected:
531 GoogleUpdateWinTest() 582 GoogleUpdateWinTest()
532 : task_runner_(new base::TestSimpleTaskRunner()), 583 : task_runner_(new base::TestSimpleTaskRunner()),
533 task_runner_handle_(task_runner_), 584 task_runner_handle_(task_runner_),
534 system_level_install_(GetParam()) {} 585 system_level_install_(GetParam()),
586 fake_git_(nullptr) {}
535 587
536 void SetUp() override { 588 void SetUp() override {
537 ::testing::TestWithParam<bool>::SetUp(); 589 ::testing::TestWithParam<bool>::SetUp();
538 590
539 // Override FILE_EXE so that it looks like the test is running from the 591 // 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). 592 // standard install location for this mode (system-level or user-level).
541 base::FilePath file_exe; 593 base::FilePath file_exe;
542 ASSERT_TRUE(PathService::Get(base::FILE_EXE, &file_exe)); 594 ASSERT_TRUE(PathService::Get(base::FILE_EXE, &file_exe));
543 base::FilePath install_dir(installer::GetChromeInstallPath( 595 base::FilePath install_dir(installer::GetChromeInstallPath(
544 system_level_install_, BrowserDistribution::GetDistribution())); 596 system_level_install_, BrowserDistribution::GetDistribution()));
(...skipping 30 matching lines...) Expand all
575 ASSERT_EQ(ERROR_SUCCESS, 627 ASSERT_EQ(ERROR_SUCCESS,
576 key.Create(root, kClientState, KEY_WRITE | KEY_WOW64_32KEY)); 628 key.Create(root, kClientState, KEY_WRITE | KEY_WOW64_32KEY));
577 ASSERT_EQ(ERROR_SUCCESS, 629 ASSERT_EQ(ERROR_SUCCESS,
578 key.CreateKey(kChromeGuid, KEY_WRITE | KEY_WOW64_32KEY)); 630 key.CreateKey(kChromeGuid, KEY_WRITE | KEY_WOW64_32KEY));
579 ASSERT_EQ(ERROR_SUCCESS, 631 ASSERT_EQ(ERROR_SUCCESS,
580 key.WriteValue(L"UninstallArguments", 632 key.WriteValue(L"UninstallArguments",
581 L"--uninstall --multi-install --chrome")); 633 L"--uninstall --multi-install --chrome"));
582 634
583 // Provide an IGoogleUpdate3Web class factory so that this test can provide 635 // Provide an IGoogleUpdate3Web class factory so that this test can provide
584 // a mocked-out instance. 636 // a mocked-out instance.
585 SetGoogleUpdateFactoryForTesting( 637 SetUpdateCheckFactoriesForTesting(
638 base::Bind(&GoogleUpdateWinTest::GetFakeGit, base::Unretained(this)),
586 base::Bind(&GoogleUpdateFactory::Create, 639 base::Bind(&GoogleUpdateFactory::Create,
587 base::Unretained(&mock_google_update_factory_))); 640 base::Unretained(&mock_google_update_factory_)));
588 641
589 // Compute a newer version. 642 // Compute a newer version.
590 base::Version current_version(CHROME_VERSION_STRING); 643 base::Version current_version(CHROME_VERSION_STRING);
591 new_version_ = base::StringPrintf(L"%u.%u.%u.%u", 644 new_version_ = base::StringPrintf(L"%u.%u.%u.%u",
592 current_version.components()[0], 645 current_version.components()[0],
593 current_version.components()[1], 646 current_version.components()[1],
594 current_version.components()[2] + 1, 647 current_version.components()[2] + 1,
595 current_version.components()[3]); 648 current_version.components()[3]);
596 } 649 }
597 650
598 // Creates app bundle and app mocks that will be used to simulate Google 651 // Creates app bundle and app mocks that will be used to simulate Google
599 // Update. 652 // Update.
600 void MakeGoogleUpdateMocks(CComObject<MockAppBundle>** mock_app_bundle, 653 void MakeGoogleUpdateMocks(CComObject<MockAppBundle>** mock_app_bundle,
601 CComObject<MockApp>** mock_app) { 654 CComObject<MockApp>** mock_app) {
602 CComObject<MockGoogleUpdate>* google_update = 655 CComObject<MockGoogleUpdate>* google_update =
603 mock_google_update_factory_.MakeServerMock(); 656 mock_google_update_factory_.MakeServerMock();
604 CComObject<MockAppBundle>* app_bundle = google_update->MakeAppBundle(); 657 CComObject<MockAppBundle>* app_bundle = google_update->MakeAppBundle();
605 CComObject<MockApp>* app = app_bundle->MakeApp(kChromeBinariesGuid); 658 CComObject<MockApp>* app = app_bundle->MakeApp(kChromeBinariesGuid);
606 659
607 if (mock_app_bundle) 660 if (mock_app_bundle)
608 *mock_app_bundle = app_bundle; 661 *mock_app_bundle = app_bundle;
609 if (mock_app) 662 if (mock_app)
610 *mock_app = app; 663 *mock_app = app;
611 } 664 }
612 665
613 void TearDown() override { 666 void TearDown() override {
667 // Be sure all objects were removed from the Global Interface Table.
668 if (fake_git_) {
669 ASSERT_EQ(0U, fake_git_->size());
Peter Kasting 2016/08/03 01:24:34 Nit: You could also elect to provide .empty() in p
grt (UTC plus 2) 2016/08/03 05:36:31 Done.
670 git_.Release();
671 fake_git_ = nullptr;
672 }
673
614 // Remove the test's IGoogleUpdate on-demand update class factory. 674 // Remove the test's IGoogleUpdate on-demand update class factory.
615 SetGoogleUpdateFactoryForTesting(GoogleUpdate3ClassFactory()); 675 SetUpdateCheckFactoriesForTesting(GlobalInterfaceTableClassFactory(),
676 GoogleUpdate3ClassFactory());
616 ::testing::TestWithParam<bool>::TearDown(); 677 ::testing::TestWithParam<bool>::TearDown();
617 } 678 }
618 679
680 HRESULT GetFakeGit(base::win::ScopedComPtr<IGlobalInterfaceTable>* git) {
Peter Kasting 2016/08/03 01:24:34 Seems like this should return void.
grt (UTC plus 2) 2016/08/03 05:36:31 This is bound into a GlobalInterfaceTableClassFact
681 if (!fake_git_) {
682 EXPECT_EQ(S_OK, CComObject<FakeGit>::CreateInstance(&fake_git_));
683 EXPECT_NE(nullptr, fake_git_);
684 git_ = fake_git_;
685 }
686 *git = git_;
687 return S_OK;
688 }
689
619 static const base::char16 kClients[]; 690 static const base::char16 kClients[];
620 static const base::char16 kClientState[]; 691 static const base::char16 kClientState[];
621 static const base::char16 kChromeGuid[]; 692 static const base::char16 kChromeGuid[];
622 static const base::char16 kChromeBinariesGuid[]; 693 static const base::char16 kChromeBinariesGuid[];
623 694
695 base::win::ScopedCOMInitializer com_initializer_;
624 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 696 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
625 base::ThreadTaskRunnerHandle task_runner_handle_; 697 base::ThreadTaskRunnerHandle task_runner_handle_;
626 bool system_level_install_; 698 bool system_level_install_;
627 std::unique_ptr<base::ScopedPathOverride> file_exe_override_; 699 std::unique_ptr<base::ScopedPathOverride> file_exe_override_;
628 std::unique_ptr<base::ScopedPathOverride> program_files_override_; 700 std::unique_ptr<base::ScopedPathOverride> program_files_override_;
629 std::unique_ptr<base::ScopedPathOverride> program_files_x86_override_; 701 std::unique_ptr<base::ScopedPathOverride> program_files_x86_override_;
630 std::unique_ptr<base::ScopedPathOverride> local_app_data_override_; 702 std::unique_ptr<base::ScopedPathOverride> local_app_data_override_;
631 registry_util::RegistryOverrideManager registry_override_manager_; 703 registry_util::RegistryOverrideManager registry_override_manager_;
632 704
705 CComObject<FakeGit>* fake_git_;
706 base::win::ScopedComPtr<IGlobalInterfaceTable> git_;
707
633 // A mock object, the OnUpdateCheckCallback method of which will be invoked 708 // A mock object, the OnUpdateCheckCallback method of which will be invoked
634 // each time the update check machinery invokes the given UpdateCheckCallback. 709 // each time the update check machinery invokes the given UpdateCheckCallback.
635 StrictMock<MockUpdateCheckDelegate> mock_update_check_delegate_; 710 StrictMock<MockUpdateCheckDelegate> mock_update_check_delegate_;
636 711
637 // A mock object that provides a GoogleUpdate3ClassFactory by which the test 712 // A mock object that provides a GoogleUpdate3ClassFactory by which the test
638 // fixture's IGoogleUpdate3Web simulator is provided to the update check 713 // fixture's IGoogleUpdate3Web simulator is provided to the update check
639 // machinery. 714 // machinery.
640 StrictMock<MockGoogleUpdateFactory> mock_google_update_factory_; 715 StrictMock<MockGoogleUpdateFactory> mock_google_update_factory_;
641 716
642 // The new version that the fixture will pretend is available. 717 // The new version that the fixture will pretend is available.
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 } 982 }
908 BeginUpdateCheck(task_runner_, std::string(), true, 0, 983 BeginUpdateCheck(task_runner_, std::string(), true, 0,
909 mock_update_check_delegate_.AsWeakPtr()); 984 mock_update_check_delegate_.AsWeakPtr());
910 task_runner_->RunUntilIdle(); 985 task_runner_->RunUntilIdle();
911 } 986 }
912 987
913 // Test that a retry after a USING_EXTERNAL_UPDATER failure succeeds. 988 // Test that a retry after a USING_EXTERNAL_UPDATER failure succeeds.
914 TEST_P(GoogleUpdateWinTest, RetryAfterExternalUpdaterError) { 989 TEST_P(GoogleUpdateWinTest, RetryAfterExternalUpdaterError) {
915 static const HRESULT GOOPDATE_E_APP_USING_EXTERNAL_UPDATER = 0xa043081d; 990 static const HRESULT GOOPDATE_E_APP_USING_EXTERNAL_UPDATER = 0xa043081d;
916 991
917 CComObject<MockAppBundle>* mock_app_bundle = 992 CComObject<MockGoogleUpdate>* google_update =
918 mock_google_update_factory_.MakeServerMock()->MakeAppBundle(); 993 mock_google_update_factory_.MakeServerMock();
994 CComObject<MockAppBundle>* mock_app_bundle = google_update->MakeAppBundle();
919 995
920 // The first attempt will fail in createInstalledApp indicating that an update 996 // The first attempt will fail in createInstalledApp indicating that an update
921 // is already in progress. 997 // is already in progress.
922 Sequence bundle_seq;
923 EXPECT_CALL(*mock_app_bundle, createInstalledApp(StrEq(kChromeBinariesGuid))) 998 EXPECT_CALL(*mock_app_bundle, createInstalledApp(StrEq(kChromeBinariesGuid)))
924 .InSequence(bundle_seq)
925 .WillOnce(Return(GOOPDATE_E_APP_USING_EXTERNAL_UPDATER)); 999 .WillOnce(Return(GOOPDATE_E_APP_USING_EXTERNAL_UPDATER));
926 1000
927 // Expect a retry on the same instance. 1001 // Expect a retry on a new bundle.
928 EXPECT_CALL(*mock_app_bundle, createInstalledApp(StrEq(kChromeBinariesGuid))) 1002 mock_app_bundle = google_update->MakeAppBundle();
929 .InSequence(bundle_seq) 1003 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 1004
939 // Expect the bundle to be called on to start the update. 1005 // Expect the bundle to be called on to start the update.
940 EXPECT_CALL(*mock_app_bundle, checkForUpdate()).WillOnce(Return(S_OK)); 1006 EXPECT_CALL(*mock_app_bundle, checkForUpdate()).WillOnce(Return(S_OK));
941 1007
942 mock_app->PushState(STATE_INIT); 1008 mock_app->PushState(STATE_INIT);
943 mock_app->PushState(STATE_CHECKING_FOR_UPDATE); 1009 mock_app->PushState(STATE_CHECKING_FOR_UPDATE);
944 mock_app->PushState(STATE_NO_UPDATE); 1010 mock_app->PushState(STATE_NO_UPDATE);
945 1011
946 // Expect the update check to succeed. 1012 // Expect the update check to succeed.
947 EXPECT_CALL(mock_update_check_delegate_, 1013 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, 1075 BeginUpdateCheck(task_runner_, std::string(), true, 0,
1010 mock_update_check_delegate_.AsWeakPtr()); 1076 mock_update_check_delegate_.AsWeakPtr());
1011 BeginUpdateCheck(task_runner_, std::string(), true, 0, 1077 BeginUpdateCheck(task_runner_, std::string(), true, 0,
1012 mock_update_check_delegate_2.AsWeakPtr()); 1078 mock_update_check_delegate_2.AsWeakPtr());
1013 task_runner_->RunUntilIdle(); 1079 task_runner_->RunUntilIdle();
1014 } 1080 }
1015 1081
1016 INSTANTIATE_TEST_CASE_P(UserLevel, GoogleUpdateWinTest, Values(false)); 1082 INSTANTIATE_TEST_CASE_P(UserLevel, GoogleUpdateWinTest, Values(false));
1017 1083
1018 INSTANTIATE_TEST_CASE_P(SystemLevel, GoogleUpdateWinTest, Values(true)); 1084 INSTANTIATE_TEST_CASE_P(SystemLevel, GoogleUpdateWinTest, Values(true));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698