Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/component_updater/cros_component_installer.h" | 5 #include "chrome/browser/component_updater/cros_component_installer.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/test/test_simple_task_runner.h" | 9 #include "base/test/test_simple_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 return base::ThreadTaskRunnerHandle::Get(); | 26 return base::ThreadTaskRunnerHandle::Get(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 private: | 29 private: |
| 30 DISALLOW_COPY_AND_ASSIGN(CrOSMockComponentUpdateService); | 30 DISALLOW_COPY_AND_ASSIGN(CrOSMockComponentUpdateService); |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 class CrOSComponentInstallerTest : public PlatformTest { | 33 class CrOSComponentInstallerTest : public PlatformTest { |
| 34 public: | 34 public: |
| 35 CrOSComponentInstallerTest() {} | 35 CrOSComponentInstallerTest() {} |
| 36 void SetUp() override { PlatformTest::SetUp(); } | 36 void SetUp() override { |
| 37 PlatformTest::SetUp(); | |
| 38 bppp_ = std::make_shared<BrowserProcessPlatformPart>(); | |
| 39 } | |
| 40 std::shared_ptr<BrowserProcessPlatformPart> GetBPPP() { return bppp_; } | |
| 37 | 41 |
| 38 private: | 42 private: |
| 39 content::TestBrowserThreadBundle thread_bundle_; | 43 content::TestBrowserThreadBundle thread_bundle_; |
| 44 std::shared_ptr<BrowserProcessPlatformPart> bppp_; | |
| 45 | |
| 40 DISALLOW_COPY_AND_ASSIGN(CrOSComponentInstallerTest); | 46 DISALLOW_COPY_AND_ASSIGN(CrOSComponentInstallerTest); |
| 41 }; | 47 }; |
| 42 | 48 |
| 43 class FakeInstallerTraits : public ComponentInstallerTraits { | 49 class FakeInstallerTraits : public ComponentInstallerTraits { |
| 44 public: | 50 public: |
| 45 ~FakeInstallerTraits() override {} | 51 ~FakeInstallerTraits() override {} |
| 46 | 52 |
| 47 bool VerifyInstallation(const base::DictionaryValue& manifest, | 53 bool VerifyInstallation(const base::DictionaryValue& manifest, |
| 48 const base::FilePath& dir) const override { | 54 const base::FilePath& dir) const override { |
| 49 return true; | 55 return true; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 80 } | 86 } |
| 81 | 87 |
| 82 std::vector<std::string> GetMimeTypes() const override { | 88 std::vector<std::string> GetMimeTypes() const override { |
| 83 return std::vector<std::string>(); | 89 return std::vector<std::string>(); |
| 84 } | 90 } |
| 85 }; | 91 }; |
| 86 | 92 |
| 87 void install_callback(update_client::Error error) {} | 93 void install_callback(update_client::Error error) {} |
| 88 | 94 |
| 89 TEST_F(CrOSComponentInstallerTest, BPPPCompatibleCrOSComponent) { | 95 TEST_F(CrOSComponentInstallerTest, BPPPCompatibleCrOSComponent) { |
| 90 auto* bppp = new BrowserProcessPlatformPart(); | 96 ASSERT_EQ(GetBPPP()->IsCompatibleCrOSComponent("a"), false); |
|
sky
2017/05/26 03:11:12
I'm suggesting you do this:
BrowserProcessPlatf
xiaochu
2017/05/26 03:21:21
Done.
| |
| 91 ASSERT_EQ(bppp->IsCompatibleCrOSComponent("a"), false); | 97 GetBPPP()->AddCompatibleCrOSComponent("a"); |
| 92 bppp->AddCompatibleCrOSComponent("a"); | 98 ASSERT_EQ(GetBPPP()->IsCompatibleCrOSComponent("a"), true); |
| 93 ASSERT_EQ(bppp->IsCompatibleCrOSComponent("a"), true); | |
| 94 } | 99 } |
| 95 | 100 |
| 96 TEST_F(CrOSComponentInstallerTest, RegisterComponentFail) { | 101 TEST_F(CrOSComponentInstallerTest, RegisterComponentFail) { |
| 97 std::unique_ptr<CrOSMockComponentUpdateService> cus = | 102 std::unique_ptr<CrOSMockComponentUpdateService> cus = |
| 98 base::MakeUnique<CrOSMockComponentUpdateService>(); | 103 base::MakeUnique<CrOSMockComponentUpdateService>(); |
| 99 EXPECT_CALL(*cus, RegisterComponent(testing::_)).Times(0); | 104 EXPECT_CALL(*cus, RegisterComponent(testing::_)).Times(0); |
| 100 component_updater::CrOSComponent::InstallCrOSComponent( | 105 component_updater::CrOSComponent::InstallCrOSComponent( |
| 101 "a-component-not-exist", base::Bind(install_callback)); | 106 "a-component-not-exist", base::Bind(install_callback)); |
| 102 base::RunLoop().RunUntilIdle(); | 107 base::RunLoop().RunUntilIdle(); |
| 103 } | 108 } |
| 104 | 109 |
| 105 } // namespace component_updater | 110 } // namespace component_updater |
| OLD | NEW |