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

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

Issue 2707063002: Universial component install for chrome os. (Closed)
Patch Set: add comment for usage in details. Created 3 years, 9 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
OLDNEW
(Empty)
1 // Copyright (c) 2012 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/metrics/field_trial.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 "chrome/test/base/testing_browser_process.h"
11 #include "components/component_updater/mock_component_updater_service.h"
12 #include "content/public/test/test_browser_thread_bundle.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "testing/platform_test.h"
15
16 namespace component_updater {
17
18 class CrOSMockComponentUpdateService
19 : public component_updater::MockComponentUpdateService {
20 public:
21 CrOSMockComponentUpdateService() {}
22 ~CrOSMockComponentUpdateService() override {}
23
24 scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() override {
25 return base::ThreadTaskRunnerHandle::Get();
26 }
27
28 private:
29 content::TestBrowserThreadBundle thread_bundle_;
30 DISALLOW_COPY_AND_ASSIGN(CrOSMockComponentUpdateService);
31 };
32
33 class CrOSComponentInstallerTest : public PlatformTest {
34 public:
35 CrOSComponentInstallerTest() {}
36
37 void SetUp() override { PlatformTest::SetUp(); }
38
39 private:
40 DISALLOW_COPY_AND_ASSIGN(CrOSComponentInstallerTest);
41 };
42
43 TEST_F(CrOSComponentInstallerTest, ComponentUpdateService) {
44 std::unique_ptr<CrOSMockComponentUpdateService> cus(
45 new CrOSMockComponentUpdateService());
46 EXPECT_CALL(*cus, RegisterComponent(testing::_)).Times(1);
47
48 ComponentConfig config;
49 config.name = "cups";
50 config.dir = "cups";
51 config.sha2hashstr =
52 "00001111222233334444555566667777000011112222333344445555AAAAFFFF";
53 RegisterCrOSComponent(cus.get(), result);
54 base::RunLoop().RunUntilIdle();
55 }
56 #if defined(OS_CHROMEOS)
57 TEST_F(CrOSComponentInstallerTest, RegisterESCPR) {
58 std::unique_ptr<CrOSMockComponentUpdateService> cus(
59 new CrOSMockComponentUpdateService());
60 EXPECT_CALL(*cus, RegisterComponent(testing::_)).Times(1);
61 RegisterCrOSComponent(cus.get(), "escpr");
62 base::RunLoop().RunUntilIdle();
63 }
64 TEST_F(CrOSComponentInstallerTest, RegisterFakeComponent) {
65 std::unique_ptr<CrOSMockComponentUpdateService> cus(
66 new CrOSMockComponentUpdateService());
67 EXPECT_CALL(*cus, RegisterComponent(testing::_)).Times(0);
68 RegisterCrOSComponent(cus.get(), "arandomname");
69 base::RunLoop().RunUntilIdle();
70 }
71 #endif // defined(OS_CHROMEOS)
72 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698