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

Side by Side Diff: components/update_client/update_client_unittest.cc

Issue 2256363002: Attempt to remove non-namespaced base::Version usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased against master. Created 4 years, 4 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
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 <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // Tests the scenario where one update check is done for one CRX. The CRX 203 // Tests the scenario where one update check is done for one CRX. The CRX
204 // has no update. 204 // has no update.
205 TEST_F(UpdateClientTest, OneCrxNoUpdate) { 205 TEST_F(UpdateClientTest, OneCrxNoUpdate) {
206 class DataCallbackFake { 206 class DataCallbackFake {
207 public: 207 public:
208 static void Callback(const std::vector<std::string>& ids, 208 static void Callback(const std::vector<std::string>& ids,
209 std::vector<CrxComponent>* components) { 209 std::vector<CrxComponent>* components) {
210 CrxComponent crx; 210 CrxComponent crx;
211 crx.name = "test_jebg"; 211 crx.name = "test_jebg";
212 crx.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash)); 212 crx.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash));
213 crx.version = Version("0.9"); 213 crx.version = base::Version("0.9");
214 crx.installer = new TestInstaller; 214 crx.installer = new TestInstaller;
215 components->push_back(crx); 215 components->push_back(crx);
216 } 216 }
217 }; 217 };
218 218
219 class CompletionCallbackFake { 219 class CompletionCallbackFake {
220 public: 220 public:
221 static void Callback(const base::Closure& quit_closure, int error) { 221 static void Callback(const base::Closure& quit_closure, int error) {
222 EXPECT_EQ(0, error); 222 EXPECT_EQ(0, error);
223 quit_closure.Run(); 223 quit_closure.Run();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // Tests the scenario where two CRXs are checked for updates. On CRX has 304 // Tests the scenario where two CRXs are checked for updates. On CRX has
305 // an update, the other CRX does not. 305 // an update, the other CRX does not.
306 TEST_F(UpdateClientTest, TwoCrxUpdateNoUpdate) { 306 TEST_F(UpdateClientTest, TwoCrxUpdateNoUpdate) {
307 class DataCallbackFake { 307 class DataCallbackFake {
308 public: 308 public:
309 static void Callback(const std::vector<std::string>& ids, 309 static void Callback(const std::vector<std::string>& ids,
310 std::vector<CrxComponent>* components) { 310 std::vector<CrxComponent>* components) {
311 CrxComponent crx1; 311 CrxComponent crx1;
312 crx1.name = "test_jebg"; 312 crx1.name = "test_jebg";
313 crx1.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash)); 313 crx1.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash));
314 crx1.version = Version("0.9"); 314 crx1.version = base::Version("0.9");
315 crx1.installer = new TestInstaller; 315 crx1.installer = new TestInstaller;
316 316
317 CrxComponent crx2; 317 CrxComponent crx2;
318 crx2.name = "test_abag"; 318 crx2.name = "test_abag";
319 crx2.pk_hash.assign(abag_hash, abag_hash + arraysize(abag_hash)); 319 crx2.pk_hash.assign(abag_hash, abag_hash + arraysize(abag_hash));
320 crx2.version = Version("2.2"); 320 crx2.version = base::Version("2.2");
321 crx2.installer = new TestInstaller; 321 crx2.installer = new TestInstaller;
322 322
323 components->push_back(crx1); 323 components->push_back(crx1);
324 components->push_back(crx2); 324 components->push_back(crx2);
325 } 325 }
326 }; 326 };
327 327
328 class CompletionCallbackFake { 328 class CompletionCallbackFake {
329 public: 329 public:
330 static void Callback(const base::Closure& quit_closure, int error) { 330 static void Callback(const base::Closure& quit_closure, int error) {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 491
492 // Tests the update check for two CRXs scenario. Both CRXs have updates. 492 // Tests the update check for two CRXs scenario. Both CRXs have updates.
493 TEST_F(UpdateClientTest, TwoCrxUpdate) { 493 TEST_F(UpdateClientTest, TwoCrxUpdate) {
494 class DataCallbackFake { 494 class DataCallbackFake {
495 public: 495 public:
496 static void Callback(const std::vector<std::string>& ids, 496 static void Callback(const std::vector<std::string>& ids,
497 std::vector<CrxComponent>* components) { 497 std::vector<CrxComponent>* components) {
498 CrxComponent crx1; 498 CrxComponent crx1;
499 crx1.name = "test_jebg"; 499 crx1.name = "test_jebg";
500 crx1.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash)); 500 crx1.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash));
501 crx1.version = Version("0.9"); 501 crx1.version = base::Version("0.9");
502 crx1.installer = new TestInstaller; 502 crx1.installer = new TestInstaller;
503 503
504 CrxComponent crx2; 504 CrxComponent crx2;
505 crx2.name = "test_ihfo"; 505 crx2.name = "test_ihfo";
506 crx2.pk_hash.assign(ihfo_hash, ihfo_hash + arraysize(ihfo_hash)); 506 crx2.pk_hash.assign(ihfo_hash, ihfo_hash + arraysize(ihfo_hash));
507 crx2.version = Version("0.8"); 507 crx2.version = base::Version("0.8");
508 crx2.installer = new TestInstaller; 508 crx2.installer = new TestInstaller;
509 509
510 components->push_back(crx1); 510 components->push_back(crx1);
511 components->push_back(crx2); 511 components->push_back(crx2);
512 } 512 }
513 }; 513 };
514 514
515 class CompletionCallbackFake { 515 class CompletionCallbackFake {
516 public: 516 public:
517 static void Callback(const base::Closure& quit_closure, int error) { 517 static void Callback(const base::Closure& quit_closure, int error) {
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 // CRX. The update for the first CRX fails. The update client waits before 740 // CRX. The update for the first CRX fails. The update client waits before
741 // attempting the update for the second CRX. This update succeeds. 741 // attempting the update for the second CRX. This update succeeds.
742 TEST_F(UpdateClientTest, TwoCrxUpdateDownloadTimeout) { 742 TEST_F(UpdateClientTest, TwoCrxUpdateDownloadTimeout) {
743 class DataCallbackFake { 743 class DataCallbackFake {
744 public: 744 public:
745 static void Callback(const std::vector<std::string>& ids, 745 static void Callback(const std::vector<std::string>& ids,
746 std::vector<CrxComponent>* components) { 746 std::vector<CrxComponent>* components) {
747 CrxComponent crx1; 747 CrxComponent crx1;
748 crx1.name = "test_jebg"; 748 crx1.name = "test_jebg";
749 crx1.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash)); 749 crx1.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash));
750 crx1.version = Version("0.9"); 750 crx1.version = base::Version("0.9");
751 crx1.installer = new TestInstaller; 751 crx1.installer = new TestInstaller;
752 752
753 CrxComponent crx2; 753 CrxComponent crx2;
754 crx2.name = "test_ihfo"; 754 crx2.name = "test_ihfo";
755 crx2.pk_hash.assign(ihfo_hash, ihfo_hash + arraysize(ihfo_hash)); 755 crx2.pk_hash.assign(ihfo_hash, ihfo_hash + arraysize(ihfo_hash));
756 crx2.version = Version("0.8"); 756 crx2.version = base::Version("0.8");
757 crx2.installer = new TestInstaller; 757 crx2.installer = new TestInstaller;
758 758
759 components->push_back(crx1); 759 components->push_back(crx1);
760 components->push_back(crx2); 760 components->push_back(crx2);
761 } 761 }
762 }; 762 };
763 763
764 class CompletionCallbackFake { 764 class CompletionCallbackFake {
765 public: 765 public:
766 static void Callback(const base::Closure& quit_closure, int error) { 766 static void Callback(const base::Closure& quit_closure, int error) {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 static scoped_refptr<CrxInstaller> installer( 995 static scoped_refptr<CrxInstaller> installer(
996 new VersionedTestInstaller()); 996 new VersionedTestInstaller());
997 997
998 ++num_calls; 998 ++num_calls;
999 999
1000 CrxComponent crx; 1000 CrxComponent crx;
1001 crx.name = "test_ihfo"; 1001 crx.name = "test_ihfo";
1002 crx.pk_hash.assign(ihfo_hash, ihfo_hash + arraysize(ihfo_hash)); 1002 crx.pk_hash.assign(ihfo_hash, ihfo_hash + arraysize(ihfo_hash));
1003 crx.installer = installer; 1003 crx.installer = installer;
1004 if (num_calls == 1) { 1004 if (num_calls == 1) {
1005 crx.version = Version("0.8"); 1005 crx.version = base::Version("0.8");
1006 } else if (num_calls == 2) { 1006 } else if (num_calls == 2) {
1007 crx.version = Version("1.0"); 1007 crx.version = base::Version("1.0");
1008 } else { 1008 } else {
1009 NOTREACHED(); 1009 NOTREACHED();
1010 } 1010 }
1011 1011
1012 components->push_back(crx); 1012 components->push_back(crx);
1013 } 1013 }
1014 }; 1014 };
1015 1015
1016 class CompletionCallbackFake { 1016 class CompletionCallbackFake {
1017 public: 1017 public:
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 1293
1294 EXPECT_CALL(*installer, OnUpdateError(_)).Times(0); 1294 EXPECT_CALL(*installer, OnUpdateError(_)).Times(0);
1295 EXPECT_CALL(*installer, Install(_, _)) 1295 EXPECT_CALL(*installer, Install(_, _))
1296 .WillOnce(DoAll(Invoke(MockInstaller::OnInstall), Return(false))); 1296 .WillOnce(DoAll(Invoke(MockInstaller::OnInstall), Return(false)));
1297 EXPECT_CALL(*installer, GetInstalledFile(_, _)).Times(0); 1297 EXPECT_CALL(*installer, GetInstalledFile(_, _)).Times(0);
1298 EXPECT_CALL(*installer, Uninstall()).Times(0); 1298 EXPECT_CALL(*installer, Uninstall()).Times(0);
1299 1299
1300 CrxComponent crx; 1300 CrxComponent crx;
1301 crx.name = "test_jebg"; 1301 crx.name = "test_jebg";
1302 crx.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash)); 1302 crx.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash));
1303 crx.version = Version("0.9"); 1303 crx.version = base::Version("0.9");
1304 crx.installer = installer; 1304 crx.installer = installer;
1305 components->push_back(crx); 1305 components->push_back(crx);
1306 } 1306 }
1307 }; 1307 };
1308 1308
1309 class CompletionCallbackFake { 1309 class CompletionCallbackFake {
1310 public: 1310 public:
1311 static void Callback(const base::Closure& quit_closure, int error) { 1311 static void Callback(const base::Closure& quit_closure, int error) {
1312 EXPECT_EQ(0, error); 1312 EXPECT_EQ(0, error);
1313 quit_closure.Run(); 1313 quit_closure.Run();
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 static scoped_refptr<CrxInstaller> installer( 1473 static scoped_refptr<CrxInstaller> installer(
1474 new VersionedTestInstaller()); 1474 new VersionedTestInstaller());
1475 1475
1476 ++num_calls; 1476 ++num_calls;
1477 1477
1478 CrxComponent crx; 1478 CrxComponent crx;
1479 crx.name = "test_ihfo"; 1479 crx.name = "test_ihfo";
1480 crx.pk_hash.assign(ihfo_hash, ihfo_hash + arraysize(ihfo_hash)); 1480 crx.pk_hash.assign(ihfo_hash, ihfo_hash + arraysize(ihfo_hash));
1481 crx.installer = installer; 1481 crx.installer = installer;
1482 if (num_calls == 1) { 1482 if (num_calls == 1) {
1483 crx.version = Version("0.8"); 1483 crx.version = base::Version("0.8");
1484 } else if (num_calls == 2) { 1484 } else if (num_calls == 2) {
1485 crx.version = Version("1.0"); 1485 crx.version = base::Version("1.0");
1486 } else { 1486 } else {
1487 NOTREACHED(); 1487 NOTREACHED();
1488 } 1488 }
1489 1489
1490 components->push_back(crx); 1490 components->push_back(crx);
1491 } 1491 }
1492 }; 1492 };
1493 1493
1494 class CompletionCallbackFake { 1494 class CompletionCallbackFake {
1495 public: 1495 public:
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1764 // done for one CRX. The second update check call is queued up and will run 1764 // done for one CRX. The second update check call is queued up and will run
1765 // after the first check has completed. The CRX has no updates. 1765 // after the first check has completed. The CRX has no updates.
1766 TEST_F(UpdateClientTest, OneCrxNoUpdateQueuedCall) { 1766 TEST_F(UpdateClientTest, OneCrxNoUpdateQueuedCall) {
1767 class DataCallbackFake { 1767 class DataCallbackFake {
1768 public: 1768 public:
1769 static void Callback(const std::vector<std::string>& ids, 1769 static void Callback(const std::vector<std::string>& ids,
1770 std::vector<CrxComponent>* components) { 1770 std::vector<CrxComponent>* components) {
1771 CrxComponent crx; 1771 CrxComponent crx;
1772 crx.name = "test_jebg"; 1772 crx.name = "test_jebg";
1773 crx.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash)); 1773 crx.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash));
1774 crx.version = Version("0.9"); 1774 crx.version = base::Version("0.9");
1775 crx.installer = new TestInstaller; 1775 crx.installer = new TestInstaller;
1776 components->push_back(crx); 1776 components->push_back(crx);
1777 } 1777 }
1778 }; 1778 };
1779 1779
1780 class CompletionCallbackFake { 1780 class CompletionCallbackFake {
1781 public: 1781 public:
1782 static void Callback(const base::Closure& quit_closure, int error) { 1782 static void Callback(const base::Closure& quit_closure, int error) {
1783 static int num_call = 0; 1783 static int num_call = 0;
1784 ++num_call; 1784 ++num_call;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 1869
1870 // Tests the install of one CRX. 1870 // Tests the install of one CRX.
1871 TEST_F(UpdateClientTest, OneCrxInstall) { 1871 TEST_F(UpdateClientTest, OneCrxInstall) {
1872 class DataCallbackFake { 1872 class DataCallbackFake {
1873 public: 1873 public:
1874 static void Callback(const std::vector<std::string>& ids, 1874 static void Callback(const std::vector<std::string>& ids,
1875 std::vector<CrxComponent>* components) { 1875 std::vector<CrxComponent>* components) {
1876 CrxComponent crx; 1876 CrxComponent crx;
1877 crx.name = "test_jebg"; 1877 crx.name = "test_jebg";
1878 crx.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash)); 1878 crx.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash));
1879 crx.version = Version("0.0"); 1879 crx.version = base::Version("0.0");
1880 crx.installer = new TestInstaller; 1880 crx.installer = new TestInstaller;
1881 1881
1882 components->push_back(crx); 1882 components->push_back(crx);
1883 } 1883 }
1884 }; 1884 };
1885 1885
1886 class CompletionCallbackFake { 1886 class CompletionCallbackFake {
1887 public: 1887 public:
1888 static void Callback(const base::Closure& quit_closure, int error) { 1888 static void Callback(const base::Closure& quit_closure, int error) {
1889 EXPECT_EQ(0, error); 1889 EXPECT_EQ(0, error);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 2046
2047 // Tests that overlapping installs of the same CRX result in an error. 2047 // Tests that overlapping installs of the same CRX result in an error.
2048 TEST_F(UpdateClientTest, ConcurrentInstallSameCRX) { 2048 TEST_F(UpdateClientTest, ConcurrentInstallSameCRX) {
2049 class DataCallbackFake { 2049 class DataCallbackFake {
2050 public: 2050 public:
2051 static void Callback(const std::vector<std::string>& ids, 2051 static void Callback(const std::vector<std::string>& ids,
2052 std::vector<CrxComponent>* components) { 2052 std::vector<CrxComponent>* components) {
2053 CrxComponent crx; 2053 CrxComponent crx;
2054 crx.name = "test_jebg"; 2054 crx.name = "test_jebg";
2055 crx.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash)); 2055 crx.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash));
2056 crx.version = Version("0.0"); 2056 crx.version = base::Version("0.0");
2057 crx.installer = new TestInstaller; 2057 crx.installer = new TestInstaller;
2058 2058
2059 components->push_back(crx); 2059 components->push_back(crx);
2060 } 2060 }
2061 }; 2061 };
2062 2062
2063 class CompletionCallbackFake { 2063 class CompletionCallbackFake {
2064 public: 2064 public:
2065 static void Callback(const base::Closure& quit_closure, int error) { 2065 static void Callback(const base::Closure& quit_closure, int error) {
2066 static int num_call = 0; 2066 static int num_call = 0;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2279 } 2279 }
2280 2280
2281 TEST_F(UpdateClientTest, RetryAfter) { 2281 TEST_F(UpdateClientTest, RetryAfter) {
2282 class DataCallbackFake { 2282 class DataCallbackFake {
2283 public: 2283 public:
2284 static void Callback(const std::vector<std::string>& ids, 2284 static void Callback(const std::vector<std::string>& ids,
2285 std::vector<CrxComponent>* components) { 2285 std::vector<CrxComponent>* components) {
2286 CrxComponent crx; 2286 CrxComponent crx;
2287 crx.name = "test_jebg"; 2287 crx.name = "test_jebg";
2288 crx.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash)); 2288 crx.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash));
2289 crx.version = Version("0.9"); 2289 crx.version = base::Version("0.9");
2290 crx.installer = new TestInstaller; 2290 crx.installer = new TestInstaller;
2291 components->push_back(crx); 2291 components->push_back(crx);
2292 } 2292 }
2293 }; 2293 };
2294 2294
2295 class CompletionCallbackFake { 2295 class CompletionCallbackFake {
2296 public: 2296 public:
2297 static void Callback(const base::Closure& quit_closure, int error) { 2297 static void Callback(const base::Closure& quit_closure, int error) {
2298 static int num_call = 0; 2298 static int num_call = 0;
2299 ++num_call; 2299 ++num_call;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2455 // component has an update. The server does not honor the "updatedisabled" 2455 // component has an update. The server does not honor the "updatedisabled"
2456 // attribute and returns updates for both components. 2456 // attribute and returns updates for both components.
2457 TEST_F(UpdateClientTest, TwoCrxUpdateOneUpdateDisabled) { 2457 TEST_F(UpdateClientTest, TwoCrxUpdateOneUpdateDisabled) {
2458 class DataCallbackFake { 2458 class DataCallbackFake {
2459 public: 2459 public:
2460 static void Callback(const std::vector<std::string>& ids, 2460 static void Callback(const std::vector<std::string>& ids,
2461 std::vector<CrxComponent>* components) { 2461 std::vector<CrxComponent>* components) {
2462 CrxComponent crx1; 2462 CrxComponent crx1;
2463 crx1.name = "test_jebg"; 2463 crx1.name = "test_jebg";
2464 crx1.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash)); 2464 crx1.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash));
2465 crx1.version = Version("0.9"); 2465 crx1.version = base::Version("0.9");
2466 crx1.installer = new TestInstaller; 2466 crx1.installer = new TestInstaller;
2467 crx1.supports_group_policy_enable_component_updates = true; 2467 crx1.supports_group_policy_enable_component_updates = true;
2468 2468
2469 CrxComponent crx2; 2469 CrxComponent crx2;
2470 crx2.name = "test_ihfo"; 2470 crx2.name = "test_ihfo";
2471 crx2.pk_hash.assign(ihfo_hash, ihfo_hash + arraysize(ihfo_hash)); 2471 crx2.pk_hash.assign(ihfo_hash, ihfo_hash + arraysize(ihfo_hash));
2472 crx2.version = Version("0.8"); 2472 crx2.version = base::Version("0.8");
2473 crx2.installer = new TestInstaller; 2473 crx2.installer = new TestInstaller;
2474 2474
2475 components->push_back(crx1); 2475 components->push_back(crx1);
2476 components->push_back(crx2); 2476 components->push_back(crx2);
2477 } 2477 }
2478 }; 2478 };
2479 2479
2480 class CompletionCallbackFake { 2480 class CompletionCallbackFake {
2481 public: 2481 public:
2482 static void Callback(const base::Closure& quit_closure, int error) { 2482 static void Callback(const base::Closure& quit_closure, int error) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2693 update_client->Update( 2693 update_client->Update(
2694 ids, base::Bind(&DataCallbackFake::Callback), 2694 ids, base::Bind(&DataCallbackFake::Callback),
2695 base::Bind(&CompletionCallbackFake::Callback, quit_closure())); 2695 base::Bind(&CompletionCallbackFake::Callback, quit_closure()));
2696 2696
2697 RunThreads(); 2697 RunThreads();
2698 2698
2699 update_client->RemoveObserver(&observer); 2699 update_client->RemoveObserver(&observer);
2700 } 2700 }
2701 2701
2702 } // namespace update_client 2702 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/update_client_internal.h ('k') | components/update_client/update_response.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698