OLD | NEW |
(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 #include "base/memory/ptr_util.h" |
| 7 #include "base/run_loop.h" |
| 8 #include "base/test/test_simple_task_runner.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "build/build_config.h" |
| 11 #include "chrome/test/base/testing_browser_process.h" |
| 12 #include "components/component_updater/mock_component_updater_service.h" |
| 13 #include "content/public/test/test_browser_thread_bundle.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "testing/platform_test.h" |
| 16 |
| 17 namespace component_updater { |
| 18 |
| 19 class CrOSMockComponentUpdateService |
| 20 : public component_updater::MockComponentUpdateService { |
| 21 public: |
| 22 CrOSMockComponentUpdateService() {} |
| 23 ~CrOSMockComponentUpdateService() override {} |
| 24 |
| 25 scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() override { |
| 26 return base::ThreadTaskRunnerHandle::Get(); |
| 27 } |
| 28 |
| 29 private: |
| 30 content::TestBrowserThreadBundle thread_bundle_; |
| 31 DISALLOW_COPY_AND_ASSIGN(CrOSMockComponentUpdateService); |
| 32 }; |
| 33 |
| 34 class CrOSComponentInstallerTest : public PlatformTest { |
| 35 public: |
| 36 CrOSComponentInstallerTest() {} |
| 37 |
| 38 void SetUp() override { PlatformTest::SetUp(); } |
| 39 |
| 40 private: |
| 41 DISALLOW_COPY_AND_ASSIGN(CrOSComponentInstallerTest); |
| 42 }; |
| 43 |
| 44 #if defined(OS_CHROMEOS) |
| 45 TEST_F(CrOSComponentInstallerTest, RegisterESCPR) { |
| 46 std::unique_ptr<CrOSMockComponentUpdateService> cus = |
| 47 base::MakeUnique<CrOSMockComponentUpdateService>(); |
| 48 EXPECT_CALL(*cus, RegisterComponent(testing::_)).Times(1); |
| 49 component_updater::RegisterCrOSComponent(cus.get(), "escpr"); |
| 50 base::RunLoop().RunUntilIdle(); |
| 51 } |
| 52 TEST_F(CrOSComponentInstallerTest, RegisterFakeComponent) { |
| 53 std::unique_ptr<CrOSMockComponentUpdateService> cus = |
| 54 base::MakeUnique<CrOSMockComponentUpdateService>(); |
| 55 EXPECT_CALL(*cus, RegisterComponent(testing::_)).Times(0); |
| 56 RegisterCrOSComponent(cus.get(), "arandomname"); |
| 57 base::RunLoop().RunUntilIdle(); |
| 58 } |
| 59 #endif // defined(OS_CHROMEOS) |
| 60 |
| 61 } // namespace component_updater |
OLD | NEW |