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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 const CrxDataCallback& crx_data_callback, | 66 const CrxDataCallback& crx_data_callback, |
67 const CompletionCallback& completion_callback)); | 67 const CompletionCallback& completion_callback)); |
68 MOCK_METHOD3(Update, | 68 MOCK_METHOD3(Update, |
69 void(const std::vector<std::string>& ids, | 69 void(const std::vector<std::string>& ids, |
70 const CrxDataCallback& crx_data_callback, | 70 const CrxDataCallback& crx_data_callback, |
71 const CompletionCallback& completion_callback)); | 71 const CompletionCallback& completion_callback)); |
72 MOCK_CONST_METHOD2(GetCrxUpdateState, | 72 MOCK_CONST_METHOD2(GetCrxUpdateState, |
73 bool(const std::string& id, CrxUpdateItem* update_item)); | 73 bool(const std::string& id, CrxUpdateItem* update_item)); |
74 MOCK_CONST_METHOD1(IsUpdating, bool(const std::string& id)); | 74 MOCK_CONST_METHOD1(IsUpdating, bool(const std::string& id)); |
75 MOCK_METHOD0(Stop, void()); | 75 MOCK_METHOD0(Stop, void()); |
76 MOCK_METHOD3(SendUninstallPing, | 76 MOCK_METHOD3( |
77 void(const std::string& id, const Version& version, int reason)); | 77 SendUninstallPing, |
| 78 void(const std::string& id, const base::Version& version, int reason)); |
78 | 79 |
79 private: | 80 private: |
80 ~MockUpdateClient() override; | 81 ~MockUpdateClient() override; |
81 }; | 82 }; |
82 | 83 |
83 class MockServiceObserver : public ServiceObserver { | 84 class MockServiceObserver : public ServiceObserver { |
84 public: | 85 public: |
85 MockServiceObserver(); | 86 MockServiceObserver(); |
86 ~MockServiceObserver() override; | 87 ~MockServiceObserver() override; |
87 | 88 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 using update_client::abag_hash; | 249 using update_client::abag_hash; |
249 | 250 |
250 const std::string id1 = "abagagagagagagagagagagagagagagag"; | 251 const std::string id1 = "abagagagagagagagagagagagagagagag"; |
251 const std::string id2 = "jebgalgnebhfojomionfpkfelancnnkf"; | 252 const std::string id2 = "jebgalgnebhfojomionfpkfelancnnkf"; |
252 std::vector<std::string> ids; | 253 std::vector<std::string> ids; |
253 ids.push_back(id1); | 254 ids.push_back(id1); |
254 ids.push_back(id2); | 255 ids.push_back(id2); |
255 | 256 |
256 CrxComponent crx_component1; | 257 CrxComponent crx_component1; |
257 crx_component1.pk_hash.assign(abag_hash, abag_hash + arraysize(abag_hash)); | 258 crx_component1.pk_hash.assign(abag_hash, abag_hash + arraysize(abag_hash)); |
258 crx_component1.version = Version("1.0"); | 259 crx_component1.version = base::Version("1.0"); |
259 crx_component1.installer = installer; | 260 crx_component1.installer = installer; |
260 | 261 |
261 CrxComponent crx_component2; | 262 CrxComponent crx_component2; |
262 crx_component2.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash)); | 263 crx_component2.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash)); |
263 crx_component2.version = Version("0.9"); | 264 crx_component2.version = base::Version("0.9"); |
264 crx_component2.installer = installer; | 265 crx_component2.installer = installer; |
265 | 266 |
266 // Quit after two update checks have fired. | 267 // Quit after two update checks have fired. |
267 LoopHandler loop_handler(2, quit_closure()); | 268 LoopHandler loop_handler(2, quit_closure()); |
268 EXPECT_CALL(update_client(), Update(ids, _, _)) | 269 EXPECT_CALL(update_client(), Update(ids, _, _)) |
269 .WillRepeatedly(Invoke(&loop_handler, &LoopHandler::OnUpdate)); | 270 .WillRepeatedly(Invoke(&loop_handler, &LoopHandler::OnUpdate)); |
270 | 271 |
271 EXPECT_CALL(update_client(), IsUpdating(id1)).Times(1); | 272 EXPECT_CALL(update_client(), IsUpdating(id1)).Times(1); |
272 EXPECT_CALL(update_client(), Stop()).Times(1); | 273 EXPECT_CALL(update_client(), Stop()).Times(1); |
273 | 274 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 // component was not registered, the call is ignored for UMA metrics. | 321 // component was not registered, the call is ignored for UMA metrics. |
321 OnDemandTester ondemand_tester_component_not_registered; | 322 OnDemandTester ondemand_tester_component_not_registered; |
322 ondemand_tester_component_not_registered.OnDemand( | 323 ondemand_tester_component_not_registered.OnDemand( |
323 &cus, "ihfokbkgjpifnbbojhneepfflplebdkc"); | 324 &cus, "ihfokbkgjpifnbbojhneepfflplebdkc"); |
324 | 325 |
325 const std::string id = "jebgalgnebhfojomionfpkfelancnnkf"; | 326 const std::string id = "jebgalgnebhfojomionfpkfelancnnkf"; |
326 | 327 |
327 using update_client::jebg_hash; | 328 using update_client::jebg_hash; |
328 CrxComponent crx_component; | 329 CrxComponent crx_component; |
329 crx_component.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash)); | 330 crx_component.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash)); |
330 crx_component.version = Version("0.9"); | 331 crx_component.version = base::Version("0.9"); |
331 crx_component.installer = new MockInstaller(); | 332 crx_component.installer = new MockInstaller(); |
332 | 333 |
333 LoopHandler loop_handler(1); | 334 LoopHandler loop_handler(1); |
334 EXPECT_CALL(update_client(), | 335 EXPECT_CALL(update_client(), |
335 Install("jebgalgnebhfojomionfpkfelancnnkf", _, _)) | 336 Install("jebgalgnebhfojomionfpkfelancnnkf", _, _)) |
336 .WillOnce(Invoke(&loop_handler, &LoopHandler::OnInstall)); | 337 .WillOnce(Invoke(&loop_handler, &LoopHandler::OnInstall)); |
337 EXPECT_CALL(update_client(), Stop()).Times(1); | 338 EXPECT_CALL(update_client(), Stop()).Times(1); |
338 | 339 |
339 EXPECT_TRUE(cus.RegisterComponent(crx_component)); | 340 EXPECT_TRUE(cus.RegisterComponent(crx_component)); |
340 OnDemandTester ondemand_tester; | 341 OnDemandTester ondemand_tester; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 base::HistogramTester ht; | 379 base::HistogramTester ht; |
379 | 380 |
380 auto config = configurator(); | 381 auto config = configurator(); |
381 config->SetInitialDelay(3600); | 382 config->SetInitialDelay(3600); |
382 | 383 |
383 scoped_refptr<MockInstaller> installer(new MockInstaller()); | 384 scoped_refptr<MockInstaller> installer(new MockInstaller()); |
384 | 385 |
385 using update_client::jebg_hash; | 386 using update_client::jebg_hash; |
386 CrxComponent crx_component; | 387 CrxComponent crx_component; |
387 crx_component.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash)); | 388 crx_component.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash)); |
388 crx_component.version = Version("0.9"); | 389 crx_component.version = base::Version("0.9"); |
389 crx_component.installer = installer; | 390 crx_component.installer = installer; |
390 | 391 |
391 LoopHandler loop_handler(1, quit_closure()); | 392 LoopHandler loop_handler(1, quit_closure()); |
392 EXPECT_CALL(update_client(), | 393 EXPECT_CALL(update_client(), |
393 Install("jebgalgnebhfojomionfpkfelancnnkf", _, _)) | 394 Install("jebgalgnebhfojomionfpkfelancnnkf", _, _)) |
394 .WillOnce(Invoke(&loop_handler, &LoopHandler::OnInstall)); | 395 .WillOnce(Invoke(&loop_handler, &LoopHandler::OnInstall)); |
395 EXPECT_CALL(update_client(), Stop()).Times(1); | 396 EXPECT_CALL(update_client(), Stop()).Times(1); |
396 | 397 |
397 EXPECT_TRUE(component_updater().RegisterComponent(crx_component)); | 398 EXPECT_TRUE(component_updater().RegisterComponent(crx_component)); |
398 component_updater().MaybeThrottle( | 399 component_updater().MaybeThrottle( |
399 "jebgalgnebhfojomionfpkfelancnnkf", | 400 "jebgalgnebhfojomionfpkfelancnnkf", |
400 base::Bind(&ComponentUpdaterTest::ReadyCallback)); | 401 base::Bind(&ComponentUpdaterTest::ReadyCallback)); |
401 | 402 |
402 RunThreads(); | 403 RunThreads(); |
403 | 404 |
404 ht.ExpectUniqueSample("ComponentUpdater.Calls", 0, 1); | 405 ht.ExpectUniqueSample("ComponentUpdater.Calls", 0, 1); |
405 ht.ExpectUniqueSample("ComponentUpdater.UpdateCompleteResult", 0, 1); | 406 ht.ExpectUniqueSample("ComponentUpdater.UpdateCompleteResult", 0, 1); |
406 ht.ExpectTotalCount("ComponentUpdater.UpdateCompleteTime", 1); | 407 ht.ExpectTotalCount("ComponentUpdater.UpdateCompleteTime", 1); |
407 } | 408 } |
408 | 409 |
409 } // namespace component_updater | 410 } // namespace component_updater |
OLD | NEW |