| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/component_updater/component_updater_service.h" | 5 #include "components/component_updater/component_updater_service.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 279 |
| 280 ht.ExpectUniqueSample("ComponentUpdater.Calls", 1, 2); | 280 ht.ExpectUniqueSample("ComponentUpdater.Calls", 1, 2); |
| 281 ht.ExpectUniqueSample("ComponentUpdater.UpdateCompleteResult", 0, 2); | 281 ht.ExpectUniqueSample("ComponentUpdater.UpdateCompleteResult", 0, 2); |
| 282 ht.ExpectTotalCount("ComponentUpdater.UpdateCompleteTime", 2); | 282 ht.ExpectTotalCount("ComponentUpdater.UpdateCompleteTime", 2); |
| 283 } | 283 } |
| 284 | 284 |
| 285 // Tests that on-demand updates invoke UpdateClient::Install. | 285 // Tests that on-demand updates invoke UpdateClient::Install. |
| 286 TEST_F(ComponentUpdaterTest, OnDemandUpdate) { | 286 TEST_F(ComponentUpdaterTest, OnDemandUpdate) { |
| 287 class LoopHandler { | 287 class LoopHandler { |
| 288 public: | 288 public: |
| 289 LoopHandler(int max_cnt) | 289 LoopHandler(int max_cnt) : max_cnt_(max_cnt) {} |
| 290 : max_cnt_(max_cnt) {} | |
| 291 | 290 |
| 292 void OnInstall( | 291 void OnInstall( |
| 293 const std::string& ids, | 292 const std::string& ids, |
| 294 const UpdateClient::CrxDataCallback& crx_data_callback, | 293 const UpdateClient::CrxDataCallback& crx_data_callback, |
| 295 const UpdateClient::CompletionCallback& completion_callback) { | 294 const UpdateClient::CompletionCallback& completion_callback) { |
| 296 completion_callback.Run(0); | 295 completion_callback.Run(0); |
| 297 static int cnt = 0; | 296 static int cnt = 0; |
| 298 ++cnt; | 297 ++cnt; |
| 299 if (cnt >= max_cnt_) { | 298 if (cnt >= max_cnt_) { |
| 300 base::ThreadTaskRunnerHandle::Get()->PostTask( | 299 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 base::Bind(&ComponentUpdaterTest::ReadyCallback)); | 399 base::Bind(&ComponentUpdaterTest::ReadyCallback)); |
| 401 | 400 |
| 402 RunThreads(); | 401 RunThreads(); |
| 403 | 402 |
| 404 ht.ExpectUniqueSample("ComponentUpdater.Calls", 0, 1); | 403 ht.ExpectUniqueSample("ComponentUpdater.Calls", 0, 1); |
| 405 ht.ExpectUniqueSample("ComponentUpdater.UpdateCompleteResult", 0, 1); | 404 ht.ExpectUniqueSample("ComponentUpdater.UpdateCompleteResult", 0, 1); |
| 406 ht.ExpectTotalCount("ComponentUpdater.UpdateCompleteTime", 1); | 405 ht.ExpectTotalCount("ComponentUpdater.UpdateCompleteTime", 1); |
| 407 } | 406 } |
| 408 | 407 |
| 409 } // namespace component_updater | 408 } // namespace component_updater |
| OLD | NEW |