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

Side by Side Diff: chrome/browser/component_updater/cros_component_installer_unittest.cc

Issue 2898063002: Hold cros_component_installers in browser_process. (Closed)
Patch Set: remove dead code Created 3 years, 7 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 | « chrome/browser/component_updater/cros_component_installer.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/component_updater/cros_component_installer.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "base/run_loop.h"
9 #include "base/test/test_simple_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h"
11 #include "chrome/browser/browser_process_platform_part_chromeos.h"
12 #include "chrome/test/base/testing_browser_process.h"
13 #include "components/component_updater/mock_component_updater_service.h"
14 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "testing/platform_test.h"
17
18 namespace component_updater {
19
20 class CrOSMockComponentUpdateService
21 : public component_updater::MockComponentUpdateService {
22 public:
23 CrOSMockComponentUpdateService() {}
24 ~CrOSMockComponentUpdateService() override {}
25 scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() override {
26 return base::ThreadTaskRunnerHandle::Get();
27 }
28
29 private:
30 DISALLOW_COPY_AND_ASSIGN(CrOSMockComponentUpdateService);
31 };
32
33 class CrOSComponentInstallerTest : public PlatformTest {
34 public:
35 CrOSComponentInstallerTest() {}
36 void SetUp() override { PlatformTest::SetUp(); }
37
38 private:
39 content::TestBrowserThreadBundle thread_bundle_;
40 DISALLOW_COPY_AND_ASSIGN(CrOSComponentInstallerTest);
41 };
42
43 class FakeInstallerTraits : public ComponentInstallerTraits {
44 public:
45 ~FakeInstallerTraits() override {}
46
47 bool VerifyInstallation(const base::DictionaryValue& manifest,
48 const base::FilePath& dir) const override {
49 return true;
50 }
51
52 bool SupportsGroupPolicyEnabledComponentUpdates() const override {
53 return true;
54 }
55
56 bool RequiresNetworkEncryption() const override { return true; }
57
58 update_client::CrxInstaller::Result OnCustomInstall(
59 const base::DictionaryValue& manifest,
60 const base::FilePath& install_dir) override {
61 return update_client::CrxInstaller::Result(0);
62 }
63
64 void ComponentReady(
65 const base::Version& version,
66 const base::FilePath& install_dir,
67 std::unique_ptr<base::DictionaryValue> manifest) override {}
68
69 base::FilePath GetRelativeInstallDir() const override {
70 return base::FilePath(FILE_PATH_LITERAL("fake"));
71 }
72
73 void GetHash(std::vector<uint8_t>* hash) const override {}
74
75 std::string GetName() const override { return "fake name"; }
76
77 update_client::InstallerAttributes GetInstallerAttributes() const override {
78 update_client::InstallerAttributes installer_attributes;
79 return installer_attributes;
80 }
81
82 std::vector<std::string> GetMimeTypes() const override {
83 return std::vector<std::string>();
84 }
85 };
86
87 void install_callback(update_client::Error error) {}
88
89 TEST_F(CrOSComponentInstallerTest, BPPPCompatibleCrOSComponent) {
90 auto* bppp = new BrowserProcessPlatformPart();
91 ASSERT_EQ(bppp->IsCompatibleCrOSComponent("a"), false);
92 bppp->AddCompatibleCrOSComponent("a");
93 ASSERT_EQ(bppp->IsCompatibleCrOSComponent("a"), true);
94 }
95
96 TEST_F(CrOSComponentInstallerTest, RegisterComponentFail) {
97 std::unique_ptr<CrOSMockComponentUpdateService> cus =
98 base::MakeUnique<CrOSMockComponentUpdateService>();
99 EXPECT_CALL(*cus, RegisterComponent(testing::_)).Times(0);
100 component_updater::CrOSComponent::InstallCrOSComponent(
101 "a-component-not-exist", base::Bind(install_callback));
102 base::RunLoop().RunUntilIdle();
103 }
104
105 } // namespace component_updater
OLDNEW
« no previous file with comments | « chrome/browser/component_updater/cros_component_installer.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698