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/test_reg_util_win.h" | 22 #include "base/test/test_reg_util_win.h" |
23 #include "base/test/test_simple_task_runner.h" | 23 #include "base/test/test_simple_task_runner.h" |
24 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
25 #include "base/version.h" | 25 #include "base/version.h" |
26 #include "base/win/registry.h" | 26 #include "base/win/registry.h" |
27 #include "base/win/scoped_comptr.h" | 27 #include "base/win/scoped_comptr.h" |
28 #include "chrome/common/chrome_version.h" | 28 #include "chrome/common/chrome_version.h" |
| 29 #include "chrome/install_static/test/scoped_install_details.h" |
29 #include "chrome/installer/util/browser_distribution.h" | 30 #include "chrome/installer/util/browser_distribution.h" |
30 #include "chrome/installer/util/google_update_settings.h" | 31 #include "chrome/installer/util/google_update_settings.h" |
31 #include "chrome/installer/util/helper.h" | 32 #include "chrome/installer/util/helper.h" |
32 #include "google_update/google_update_idl.h" | 33 #include "google_update/google_update_idl.h" |
33 #include "testing/gmock/include/gmock/gmock.h" | 34 #include "testing/gmock/include/gmock/gmock.h" |
34 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
35 #include "ui/base/win/atl_module.h" | 36 #include "ui/base/win/atl_module.h" |
36 | 37 |
37 using ::testing::DoAll; | 38 using ::testing::DoAll; |
38 using ::testing::HasSubstr; | 39 using ::testing::HasSubstr; |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 // Configure all mock functions that return HRESULT to return failure. | 525 // Configure all mock functions that return HRESULT to return failure. |
525 ::testing::DefaultValue<HRESULT>::Set(E_FAIL); | 526 ::testing::DefaultValue<HRESULT>::Set(E_FAIL); |
526 } | 527 } |
527 | 528 |
528 static void TearDownTestCase() { ::testing::DefaultValue<HRESULT>::Clear(); } | 529 static void TearDownTestCase() { ::testing::DefaultValue<HRESULT>::Clear(); } |
529 | 530 |
530 protected: | 531 protected: |
531 GoogleUpdateWinTest() | 532 GoogleUpdateWinTest() |
532 : task_runner_(new base::TestSimpleTaskRunner()), | 533 : task_runner_(new base::TestSimpleTaskRunner()), |
533 task_runner_handle_(task_runner_), | 534 task_runner_handle_(task_runner_), |
534 system_level_install_(GetParam()) {} | 535 system_level_install_(GetParam()), |
| 536 scoped_install_details_(system_level_install_, 0, true) {} |
535 | 537 |
536 void SetUp() override { | 538 void SetUp() override { |
537 ::testing::TestWithParam<bool>::SetUp(); | 539 ::testing::TestWithParam<bool>::SetUp(); |
538 | 540 |
539 // Override FILE_EXE so that it looks like the test is running from the | 541 // 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). | 542 // standard install location for this mode (system-level or user-level). |
541 base::FilePath file_exe; | 543 base::FilePath file_exe; |
542 ASSERT_TRUE(PathService::Get(base::FILE_EXE, &file_exe)); | 544 ASSERT_TRUE(PathService::Get(base::FILE_EXE, &file_exe)); |
543 base::FilePath install_dir(installer::GetChromeInstallPath( | 545 base::FilePath install_dir(installer::GetChromeInstallPath( |
544 system_level_install_, BrowserDistribution::GetDistribution())); | 546 system_level_install_, BrowserDistribution::GetDistribution())); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 ::testing::TestWithParam<bool>::TearDown(); | 619 ::testing::TestWithParam<bool>::TearDown(); |
618 } | 620 } |
619 | 621 |
620 static const base::char16 kClients[]; | 622 static const base::char16 kClients[]; |
621 static const base::char16 kClientState[]; | 623 static const base::char16 kClientState[]; |
622 static const base::char16 kChromeGuid[]; | 624 static const base::char16 kChromeGuid[]; |
623 | 625 |
624 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; | 626 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; |
625 base::ThreadTaskRunnerHandle task_runner_handle_; | 627 base::ThreadTaskRunnerHandle task_runner_handle_; |
626 bool system_level_install_; | 628 bool system_level_install_; |
| 629 install_static::ScopedInstallDetails scoped_install_details_; |
627 std::unique_ptr<base::ScopedPathOverride> file_exe_override_; | 630 std::unique_ptr<base::ScopedPathOverride> file_exe_override_; |
628 std::unique_ptr<base::ScopedPathOverride> program_files_override_; | 631 std::unique_ptr<base::ScopedPathOverride> program_files_override_; |
629 std::unique_ptr<base::ScopedPathOverride> program_files_x86_override_; | 632 std::unique_ptr<base::ScopedPathOverride> program_files_x86_override_; |
630 std::unique_ptr<base::ScopedPathOverride> local_app_data_override_; | 633 std::unique_ptr<base::ScopedPathOverride> local_app_data_override_; |
631 registry_util::RegistryOverrideManager registry_override_manager_; | 634 registry_util::RegistryOverrideManager registry_override_manager_; |
632 | 635 |
633 // A mock object, the OnUpdateCheckCallback method of which will be invoked | 636 // A mock object, the OnUpdateCheckCallback method of which will be invoked |
634 // each time the update check machinery invokes the given UpdateCheckCallback. | 637 // each time the update check machinery invokes the given UpdateCheckCallback. |
635 StrictMock<MockUpdateCheckDelegate> mock_update_check_delegate_; | 638 StrictMock<MockUpdateCheckDelegate> mock_update_check_delegate_; |
636 | 639 |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 BeginUpdateCheck(task_runner_, std::string(), true, 0, | 1010 BeginUpdateCheck(task_runner_, std::string(), true, 0, |
1008 mock_update_check_delegate_.AsWeakPtr()); | 1011 mock_update_check_delegate_.AsWeakPtr()); |
1009 BeginUpdateCheck(task_runner_, std::string(), true, 0, | 1012 BeginUpdateCheck(task_runner_, std::string(), true, 0, |
1010 mock_update_check_delegate_2.AsWeakPtr()); | 1013 mock_update_check_delegate_2.AsWeakPtr()); |
1011 task_runner_->RunUntilIdle(); | 1014 task_runner_->RunUntilIdle(); |
1012 } | 1015 } |
1013 | 1016 |
1014 INSTANTIATE_TEST_CASE_P(UserLevel, GoogleUpdateWinTest, Values(false)); | 1017 INSTANTIATE_TEST_CASE_P(UserLevel, GoogleUpdateWinTest, Values(false)); |
1015 | 1018 |
1016 INSTANTIATE_TEST_CASE_P(SystemLevel, GoogleUpdateWinTest, Values(true)); | 1019 INSTANTIATE_TEST_CASE_P(SystemLevel, GoogleUpdateWinTest, Values(true)); |
OLD | NEW |