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