Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <iterator> | 5 #include <iterator> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/message_loop/message_loop.h" | |
| 14 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 15 #include "base/test/sequenced_worker_pool_owner.h" | 14 #include "base/task_scheduler/post_task.h" |
| 15 #include "base/test/scoped_task_environment.h" | |
| 16 #include "base/version.h" | 16 #include "base/version.h" |
| 17 #include "components/component_updater/component_updater_service.h" | 17 #include "components/component_updater/component_updater_service.h" |
| 18 #include "components/component_updater/component_updater_service_internal.h" | 18 #include "components/component_updater/component_updater_service_internal.h" |
| 19 #include "components/component_updater/default_component_installer.h" | 19 #include "components/component_updater/default_component_installer.h" |
| 20 #include "components/update_client/crx_update_item.h" | 20 #include "components/update_client/crx_update_item.h" |
| 21 #include "components/update_client/test_configurator.h" | 21 #include "components/update_client/test_configurator.h" |
| 22 #include "components/update_client/update_client.h" | 22 #include "components/update_client/update_client.h" |
| 23 #include "components/update_client/update_client_errors.h" | 23 #include "components/update_client/update_client_errors.h" |
| 24 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 ComponentUpdateService* component_updater() { | 129 ComponentUpdateService* component_updater() { |
| 130 return component_updater_.get(); | 130 return component_updater_.get(); |
| 131 } | 131 } |
| 132 scoped_refptr<TestConfigurator> configurator() const { return config_; } | 132 scoped_refptr<TestConfigurator> configurator() const { return config_; } |
| 133 base::Closure quit_closure() const { return quit_closure_; } | 133 base::Closure quit_closure() const { return quit_closure_; } |
| 134 | 134 |
| 135 protected: | 135 protected: |
| 136 void RunThreads(); | 136 void RunThreads(); |
| 137 | 137 |
| 138 private: | 138 private: |
| 139 static const int kNumWorkerThreads_ = 2; | 139 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 140 | |
| 141 base::MessageLoopForUI message_loop_; | |
| 142 base::RunLoop runloop_; | 140 base::RunLoop runloop_; |
| 143 base::Closure quit_closure_; | 141 base::Closure quit_closure_; |
| 144 | 142 |
| 145 std::unique_ptr<base::SequencedWorkerPoolOwner> worker_pool_; | 143 std::unique_ptr<base::SequencedWorkerPoolOwner> worker_pool_; |
|
waffles
2017/05/12 20:02:33
Looks like we were getting the declaration of this
fdoray
2017/05/16 12:42:02
Done.
| |
| 146 | 144 |
| 147 scoped_refptr<TestConfigurator> config_; | 145 scoped_refptr<TestConfigurator> config_; |
| 148 scoped_refptr<MockUpdateClient> update_client_; | 146 scoped_refptr<MockUpdateClient> update_client_; |
| 149 std::unique_ptr<ComponentUpdateService> component_updater_; | 147 std::unique_ptr<ComponentUpdateService> component_updater_; |
| 150 }; | 148 }; |
| 151 | 149 |
| 152 DefaultComponentInstallerTest::DefaultComponentInstallerTest() | 150 DefaultComponentInstallerTest::DefaultComponentInstallerTest() |
| 153 : worker_pool_( | 151 : scoped_task_environment_( |
| 154 new base::SequencedWorkerPoolOwner(kNumWorkerThreads_, "test")) { | 152 base::test::ScopedTaskEnvironment::MainThreadType::UI) { |
| 155 quit_closure_ = runloop_.QuitClosure(); | 153 quit_closure_ = runloop_.QuitClosure(); |
| 156 | 154 |
| 157 auto pool = worker_pool_->pool(); | |
| 158 config_ = new TestConfigurator( | 155 config_ = new TestConfigurator( |
| 159 pool->GetSequencedTaskRunner(pool->GetSequenceToken()), | 156 base::CreateSequencedTaskRunnerWithTraits({base::MayBlock()}), |
| 160 message_loop_.task_runner()); | 157 base::ThreadTaskRunnerHandle::Get()); |
| 161 | 158 |
| 162 update_client_ = new MockUpdateClient(); | 159 update_client_ = new MockUpdateClient(); |
| 163 EXPECT_CALL(update_client(), AddObserver(_)).Times(1); | 160 EXPECT_CALL(update_client(), AddObserver(_)).Times(1); |
| 164 component_updater_.reset(new CrxUpdateService(config_, update_client_)); | 161 component_updater_.reset(new CrxUpdateService(config_, update_client_)); |
| 165 } | 162 } |
| 166 | 163 |
| 167 DefaultComponentInstallerTest::~DefaultComponentInstallerTest() { | 164 DefaultComponentInstallerTest::~DefaultComponentInstallerTest() { |
| 168 EXPECT_CALL(update_client(), RemoveObserver(_)).Times(1); | 165 EXPECT_CALL(update_client(), RemoveObserver(_)).Times(1); |
| 169 component_updater_.reset(); | 166 component_updater_.reset(); |
| 170 } | 167 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 component.pk_hash); | 227 component.pk_hash); |
| 231 EXPECT_EQ(base::Version("0.0.0.0"), component.version); | 228 EXPECT_EQ(base::Version("0.0.0.0"), component.version); |
| 232 EXPECT_TRUE(component.fingerprint.empty()); | 229 EXPECT_TRUE(component.fingerprint.empty()); |
| 233 EXPECT_STREQ("fake name", component.name.c_str()); | 230 EXPECT_STREQ("fake name", component.name.c_str()); |
| 234 EXPECT_EQ(expected_attrs, component.installer_attributes); | 231 EXPECT_EQ(expected_attrs, component.installer_attributes); |
| 235 EXPECT_TRUE(component.requires_network_encryption); | 232 EXPECT_TRUE(component.requires_network_encryption); |
| 236 EXPECT_TRUE(component.supports_group_policy_enable_component_updates); | 233 EXPECT_TRUE(component.supports_group_policy_enable_component_updates); |
| 237 } | 234 } |
| 238 | 235 |
| 239 } // namespace component_updater | 236 } // namespace component_updater |
| OLD | NEW |