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

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

Issue 1575523002: Comparison and streaming operators for base::Version (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes mistake in previous patch set. Created 4 years, 11 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 <utility> 5 #include <utility>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 }; 414 };
415 415
416 class FakePingManager : public FakePingManagerImpl { 416 class FakePingManager : public FakePingManagerImpl {
417 public: 417 public:
418 explicit FakePingManager(const scoped_refptr<Configurator>& config) 418 explicit FakePingManager(const scoped_refptr<Configurator>& config)
419 : FakePingManagerImpl(config) {} 419 : FakePingManagerImpl(config) {}
420 ~FakePingManager() override { 420 ~FakePingManager() override {
421 const auto& ping_items = items(); 421 const auto& ping_items = items();
422 EXPECT_EQ(1U, ping_items.size()); 422 EXPECT_EQ(1U, ping_items.size());
423 EXPECT_EQ("jebgalgnebhfojomionfpkfelancnnkf", ping_items[0].id); 423 EXPECT_EQ("jebgalgnebhfojomionfpkfelancnnkf", ping_items[0].id);
424 EXPECT_TRUE(base::Version("0.9").Equals(ping_items[0].previous_version)); 424 EXPECT_EQ(base::Version("0.9"), ping_items[0].previous_version);
425 EXPECT_TRUE(base::Version("1.0").Equals(ping_items[0].next_version)); 425 EXPECT_EQ(base::Version("1.0"), ping_items[0].next_version);
426 EXPECT_EQ(0, ping_items[0].error_category); 426 EXPECT_EQ(0, ping_items[0].error_category);
427 EXPECT_EQ(0, ping_items[0].error_code); 427 EXPECT_EQ(0, ping_items[0].error_code);
428 } 428 }
429 }; 429 };
430 430
431 scoped_ptr<PingManager> ping_manager(new FakePingManager(config())); 431 scoped_ptr<PingManager> ping_manager(new FakePingManager(config()));
432 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl( 432 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl(
433 config(), std::move(ping_manager), &FakeUpdateChecker::Create, 433 config(), std::move(ping_manager), &FakeUpdateChecker::Create,
434 &FakeCrxDownloader::Create)); 434 &FakeCrxDownloader::Create));
435 435
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 }; 638 };
639 639
640 class FakePingManager : public FakePingManagerImpl { 640 class FakePingManager : public FakePingManagerImpl {
641 public: 641 public:
642 explicit FakePingManager(const scoped_refptr<Configurator>& config) 642 explicit FakePingManager(const scoped_refptr<Configurator>& config)
643 : FakePingManagerImpl(config) {} 643 : FakePingManagerImpl(config) {}
644 ~FakePingManager() override { 644 ~FakePingManager() override {
645 const auto& ping_items = items(); 645 const auto& ping_items = items();
646 EXPECT_EQ(2U, ping_items.size()); 646 EXPECT_EQ(2U, ping_items.size());
647 EXPECT_EQ("jebgalgnebhfojomionfpkfelancnnkf", ping_items[0].id); 647 EXPECT_EQ("jebgalgnebhfojomionfpkfelancnnkf", ping_items[0].id);
648 EXPECT_TRUE(base::Version("0.9").Equals(ping_items[0].previous_version)); 648 EXPECT_EQ(base::Version("0.9"), ping_items[0].previous_version);
649 EXPECT_TRUE(base::Version("1.0").Equals(ping_items[0].next_version)); 649 EXPECT_EQ(base::Version("1.0"), ping_items[0].next_version);
650 EXPECT_EQ(0, ping_items[0].error_category); 650 EXPECT_EQ(0, ping_items[0].error_category);
651 EXPECT_EQ(0, ping_items[0].error_code); 651 EXPECT_EQ(0, ping_items[0].error_code);
652 EXPECT_EQ("ihfokbkgjpifnbbojhneepfflplebdkc", ping_items[1].id); 652 EXPECT_EQ("ihfokbkgjpifnbbojhneepfflplebdkc", ping_items[1].id);
653 EXPECT_TRUE(base::Version("0.8").Equals(ping_items[1].previous_version)); 653 EXPECT_EQ(base::Version("0.8"), ping_items[1].previous_version);
654 EXPECT_TRUE(base::Version("1.0").Equals(ping_items[1].next_version)); 654 EXPECT_EQ(base::Version("1.0"), ping_items[1].next_version);
655 EXPECT_EQ(0, ping_items[1].error_category); 655 EXPECT_EQ(0, ping_items[1].error_category);
656 EXPECT_EQ(0, ping_items[1].error_code); 656 EXPECT_EQ(0, ping_items[1].error_code);
657 } 657 }
658 }; 658 };
659 659
660 scoped_ptr<FakePingManager> ping_manager(new FakePingManager(config())); 660 scoped_ptr<FakePingManager> ping_manager(new FakePingManager(config()));
661 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl( 661 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl(
662 config(), std::move(ping_manager), &FakeUpdateChecker::Create, 662 config(), std::move(ping_manager), &FakeUpdateChecker::Create,
663 &FakeCrxDownloader::Create)); 663 &FakeCrxDownloader::Create));
664 664
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 }; 877 };
878 878
879 class FakePingManager : public FakePingManagerImpl { 879 class FakePingManager : public FakePingManagerImpl {
880 public: 880 public:
881 explicit FakePingManager(const scoped_refptr<Configurator>& config) 881 explicit FakePingManager(const scoped_refptr<Configurator>& config)
882 : FakePingManagerImpl(config) {} 882 : FakePingManagerImpl(config) {}
883 ~FakePingManager() override { 883 ~FakePingManager() override {
884 const auto& ping_items = items(); 884 const auto& ping_items = items();
885 EXPECT_EQ(2U, ping_items.size()); 885 EXPECT_EQ(2U, ping_items.size());
886 EXPECT_EQ("jebgalgnebhfojomionfpkfelancnnkf", ping_items[0].id); 886 EXPECT_EQ("jebgalgnebhfojomionfpkfelancnnkf", ping_items[0].id);
887 EXPECT_TRUE(base::Version("0.9").Equals(ping_items[0].previous_version)); 887 EXPECT_EQ(base::Version("0.9"), ping_items[0].previous_version);
888 EXPECT_TRUE(base::Version("1.0").Equals(ping_items[0].next_version)); 888 EXPECT_EQ(base::Version("1.0"), ping_items[0].next_version);
889 EXPECT_EQ(1, ping_items[0].error_category); // Network error. 889 EXPECT_EQ(1, ping_items[0].error_category); // Network error.
890 EXPECT_EQ(-118, ping_items[0].error_code); 890 EXPECT_EQ(-118, ping_items[0].error_code);
891 EXPECT_EQ("ihfokbkgjpifnbbojhneepfflplebdkc", ping_items[1].id); 891 EXPECT_EQ("ihfokbkgjpifnbbojhneepfflplebdkc", ping_items[1].id);
892 EXPECT_TRUE(base::Version("0.8").Equals(ping_items[1].previous_version)); 892 EXPECT_EQ(base::Version("0.8"), ping_items[1].previous_version);
893 EXPECT_TRUE(base::Version("1.0").Equals(ping_items[1].next_version)); 893 EXPECT_EQ(base::Version("1.0"), ping_items[1].next_version);
894 EXPECT_EQ(0, ping_items[1].error_category); 894 EXPECT_EQ(0, ping_items[1].error_category);
895 EXPECT_EQ(0, ping_items[1].error_code); 895 EXPECT_EQ(0, ping_items[1].error_code);
896 } 896 }
897 }; 897 };
898 898
899 scoped_ptr<FakePingManager> ping_manager(new FakePingManager(config())); 899 scoped_ptr<FakePingManager> ping_manager(new FakePingManager(config()));
900 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl( 900 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl(
901 config(), std::move(ping_manager), &FakeUpdateChecker::Create, 901 config(), std::move(ping_manager), &FakeUpdateChecker::Create,
902 &FakeCrxDownloader::Create)); 902 &FakeCrxDownloader::Create));
903 903
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 }; 1136 };
1137 1137
1138 class FakePingManager : public FakePingManagerImpl { 1138 class FakePingManager : public FakePingManagerImpl {
1139 public: 1139 public:
1140 explicit FakePingManager(const scoped_refptr<Configurator>& config) 1140 explicit FakePingManager(const scoped_refptr<Configurator>& config)
1141 : FakePingManagerImpl(config) {} 1141 : FakePingManagerImpl(config) {}
1142 ~FakePingManager() override { 1142 ~FakePingManager() override {
1143 const auto& ping_items = items(); 1143 const auto& ping_items = items();
1144 EXPECT_EQ(2U, ping_items.size()); 1144 EXPECT_EQ(2U, ping_items.size());
1145 EXPECT_EQ("ihfokbkgjpifnbbojhneepfflplebdkc", ping_items[0].id); 1145 EXPECT_EQ("ihfokbkgjpifnbbojhneepfflplebdkc", ping_items[0].id);
1146 EXPECT_TRUE(base::Version("0.8").Equals(ping_items[0].previous_version)); 1146 EXPECT_EQ(base::Version("0.8"), ping_items[0].previous_version);
1147 EXPECT_TRUE(base::Version("1.0").Equals(ping_items[0].next_version)); 1147 EXPECT_EQ(base::Version("1.0"), ping_items[0].next_version);
1148 EXPECT_EQ(0, ping_items[0].error_category); 1148 EXPECT_EQ(0, ping_items[0].error_category);
1149 EXPECT_EQ(0, ping_items[0].error_code); 1149 EXPECT_EQ(0, ping_items[0].error_code);
1150 EXPECT_EQ("ihfokbkgjpifnbbojhneepfflplebdkc", ping_items[1].id); 1150 EXPECT_EQ("ihfokbkgjpifnbbojhneepfflplebdkc", ping_items[1].id);
1151 EXPECT_TRUE(base::Version("1.0").Equals(ping_items[1].previous_version)); 1151 EXPECT_EQ(base::Version("1.0"), ping_items[1].previous_version);
1152 EXPECT_TRUE(base::Version("2.0").Equals(ping_items[1].next_version)); 1152 EXPECT_EQ(base::Version("2.0"), ping_items[1].next_version);
1153 EXPECT_EQ(0, ping_items[1].diff_error_category); 1153 EXPECT_EQ(0, ping_items[1].diff_error_category);
1154 EXPECT_EQ(0, ping_items[1].diff_error_code); 1154 EXPECT_EQ(0, ping_items[1].diff_error_code);
1155 } 1155 }
1156 }; 1156 };
1157 1157
1158 scoped_ptr<FakePingManager> ping_manager(new FakePingManager(config())); 1158 scoped_ptr<FakePingManager> ping_manager(new FakePingManager(config()));
1159 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl( 1159 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl(
1160 config(), std::move(ping_manager), &FakeUpdateChecker::Create, 1160 config(), std::move(ping_manager), &FakeUpdateChecker::Create,
1161 &FakeCrxDownloader::Create)); 1161 &FakeCrxDownloader::Create));
1162 1162
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 }; 1354 };
1355 1355
1356 class FakePingManager : public FakePingManagerImpl { 1356 class FakePingManager : public FakePingManagerImpl {
1357 public: 1357 public:
1358 explicit FakePingManager(const scoped_refptr<Configurator>& config) 1358 explicit FakePingManager(const scoped_refptr<Configurator>& config)
1359 : FakePingManagerImpl(config) {} 1359 : FakePingManagerImpl(config) {}
1360 ~FakePingManager() override { 1360 ~FakePingManager() override {
1361 const auto& ping_items = items(); 1361 const auto& ping_items = items();
1362 EXPECT_EQ(1U, ping_items.size()); 1362 EXPECT_EQ(1U, ping_items.size());
1363 EXPECT_EQ("jebgalgnebhfojomionfpkfelancnnkf", ping_items[0].id); 1363 EXPECT_EQ("jebgalgnebhfojomionfpkfelancnnkf", ping_items[0].id);
1364 EXPECT_TRUE(base::Version("0.9").Equals(ping_items[0].previous_version)); 1364 EXPECT_EQ(base::Version("0.9"), ping_items[0].previous_version);
1365 EXPECT_TRUE(base::Version("1.0").Equals(ping_items[0].next_version)); 1365 EXPECT_EQ(base::Version("1.0"), ping_items[0].next_version);
1366 EXPECT_EQ(3, ping_items[0].error_category); // kInstallError. 1366 EXPECT_EQ(3, ping_items[0].error_category); // kInstallError.
1367 EXPECT_EQ(9, ping_items[0].error_code); // kInstallerError. 1367 EXPECT_EQ(9, ping_items[0].error_code); // kInstallerError.
1368 } 1368 }
1369 }; 1369 };
1370 1370
1371 scoped_ptr<PingManager> ping_manager(new FakePingManager(config())); 1371 scoped_ptr<PingManager> ping_manager(new FakePingManager(config()));
1372 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl( 1372 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl(
1373 config(), std::move(ping_manager), &FakeUpdateChecker::Create, 1373 config(), std::move(ping_manager), &FakeUpdateChecker::Create,
1374 &FakeCrxDownloader::Create)); 1374 &FakeCrxDownloader::Create));
1375 1375
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 }; 1609 };
1610 1610
1611 class FakePingManager : public FakePingManagerImpl { 1611 class FakePingManager : public FakePingManagerImpl {
1612 public: 1612 public:
1613 explicit FakePingManager(const scoped_refptr<Configurator>& config) 1613 explicit FakePingManager(const scoped_refptr<Configurator>& config)
1614 : FakePingManagerImpl(config) {} 1614 : FakePingManagerImpl(config) {}
1615 ~FakePingManager() override { 1615 ~FakePingManager() override {
1616 const auto& ping_items = items(); 1616 const auto& ping_items = items();
1617 EXPECT_EQ(2U, ping_items.size()); 1617 EXPECT_EQ(2U, ping_items.size());
1618 EXPECT_EQ("ihfokbkgjpifnbbojhneepfflplebdkc", ping_items[0].id); 1618 EXPECT_EQ("ihfokbkgjpifnbbojhneepfflplebdkc", ping_items[0].id);
1619 EXPECT_TRUE(base::Version("0.8").Equals(ping_items[0].previous_version)); 1619 EXPECT_EQ(base::Version("0.8"), ping_items[0].previous_version);
1620 EXPECT_TRUE(base::Version("1.0").Equals(ping_items[0].next_version)); 1620 EXPECT_EQ(base::Version("1.0"), ping_items[0].next_version);
1621 EXPECT_EQ(0, ping_items[0].error_category); 1621 EXPECT_EQ(0, ping_items[0].error_category);
1622 EXPECT_EQ(0, ping_items[0].error_code); 1622 EXPECT_EQ(0, ping_items[0].error_code);
1623 EXPECT_EQ("ihfokbkgjpifnbbojhneepfflplebdkc", ping_items[1].id); 1623 EXPECT_EQ("ihfokbkgjpifnbbojhneepfflplebdkc", ping_items[1].id);
1624 EXPECT_TRUE(base::Version("1.0").Equals(ping_items[1].previous_version)); 1624 EXPECT_EQ(base::Version("1.0"), ping_items[1].previous_version);
1625 EXPECT_TRUE(base::Version("2.0").Equals(ping_items[1].next_version)); 1625 EXPECT_EQ(base::Version("2.0"), ping_items[1].next_version);
1626 EXPECT_TRUE(ping_items[1].diff_update_failed); 1626 EXPECT_TRUE(ping_items[1].diff_update_failed);
1627 EXPECT_EQ(1, ping_items[1].diff_error_category); // kNetworkError. 1627 EXPECT_EQ(1, ping_items[1].diff_error_category); // kNetworkError.
1628 EXPECT_EQ(-1, ping_items[1].diff_error_code); 1628 EXPECT_EQ(-1, ping_items[1].diff_error_code);
1629 } 1629 }
1630 }; 1630 };
1631 1631
1632 scoped_ptr<FakePingManager> ping_manager(new FakePingManager(config())); 1632 scoped_ptr<FakePingManager> ping_manager(new FakePingManager(config()));
1633 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl( 1633 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl(
1634 config(), std::move(ping_manager), &FakeUpdateChecker::Create, 1634 config(), std::move(ping_manager), &FakeUpdateChecker::Create,
1635 &FakeCrxDownloader::Create)); 1635 &FakeCrxDownloader::Create));
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1913 }; 1913 };
1914 1914
1915 class FakePingManager : public FakePingManagerImpl { 1915 class FakePingManager : public FakePingManagerImpl {
1916 public: 1916 public:
1917 explicit FakePingManager(const scoped_refptr<Configurator>& config) 1917 explicit FakePingManager(const scoped_refptr<Configurator>& config)
1918 : FakePingManagerImpl(config) {} 1918 : FakePingManagerImpl(config) {}
1919 ~FakePingManager() override { 1919 ~FakePingManager() override {
1920 const auto& ping_items = items(); 1920 const auto& ping_items = items();
1921 EXPECT_EQ(1U, ping_items.size()); 1921 EXPECT_EQ(1U, ping_items.size());
1922 EXPECT_EQ("jebgalgnebhfojomionfpkfelancnnkf", ping_items[0].id); 1922 EXPECT_EQ("jebgalgnebhfojomionfpkfelancnnkf", ping_items[0].id);
1923 EXPECT_TRUE(base::Version("0.0").Equals(ping_items[0].previous_version)); 1923 EXPECT_EQ(base::Version("0.0"), ping_items[0].previous_version);
1924 EXPECT_TRUE(base::Version("1.0").Equals(ping_items[0].next_version)); 1924 EXPECT_EQ(base::Version("1.0"), ping_items[0].next_version);
1925 EXPECT_EQ(0, ping_items[0].error_category); 1925 EXPECT_EQ(0, ping_items[0].error_category);
1926 EXPECT_EQ(0, ping_items[0].error_code); 1926 EXPECT_EQ(0, ping_items[0].error_code);
1927 } 1927 }
1928 }; 1928 };
1929 1929
1930 scoped_ptr<FakePingManager> ping_manager(new FakePingManager(config())); 1930 scoped_ptr<FakePingManager> ping_manager(new FakePingManager(config()));
1931 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl( 1931 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl(
1932 config(), std::move(ping_manager), &FakeUpdateChecker::Create, 1932 config(), std::move(ping_manager), &FakeUpdateChecker::Create,
1933 &FakeCrxDownloader::Create)); 1933 &FakeCrxDownloader::Create));
1934 1934
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 }; 2169 };
2170 2170
2171 class FakePingManager : public FakePingManagerImpl { 2171 class FakePingManager : public FakePingManagerImpl {
2172 public: 2172 public:
2173 explicit FakePingManager(const scoped_refptr<Configurator>& config) 2173 explicit FakePingManager(const scoped_refptr<Configurator>& config)
2174 : FakePingManagerImpl(config) {} 2174 : FakePingManagerImpl(config) {}
2175 ~FakePingManager() override { 2175 ~FakePingManager() override {
2176 const auto& ping_items = items(); 2176 const auto& ping_items = items();
2177 EXPECT_EQ(1U, ping_items.size()); 2177 EXPECT_EQ(1U, ping_items.size());
2178 EXPECT_EQ("jebgalgnebhfojomionfpkfelancnnkf", ping_items[0].id); 2178 EXPECT_EQ("jebgalgnebhfojomionfpkfelancnnkf", ping_items[0].id);
2179 EXPECT_TRUE(base::Version("1.0").Equals(ping_items[0].previous_version)); 2179 EXPECT_EQ(base::Version("1.0"), ping_items[0].previous_version);
2180 EXPECT_TRUE(base::Version("0.0").Equals(ping_items[0].next_version)); 2180 EXPECT_EQ(base::Version("0.0"), ping_items[0].next_version);
2181 EXPECT_EQ(10, ping_items[0].extra_code1); 2181 EXPECT_EQ(10, ping_items[0].extra_code1);
2182 } 2182 }
2183 }; 2183 };
2184 2184
2185 scoped_ptr<PingManager> ping_manager(new FakePingManager(config())); 2185 scoped_ptr<PingManager> ping_manager(new FakePingManager(config()));
2186 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl( 2186 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl(
2187 config(), std::move(ping_manager), &FakeUpdateChecker::Create, 2187 config(), std::move(ping_manager), &FakeUpdateChecker::Create,
2188 &FakeCrxDownloader::Create)); 2188 &FakeCrxDownloader::Create));
2189 2189
2190 update_client->SendUninstallPing("jebgalgnebhfojomionfpkfelancnnkf", 2190 update_client->SendUninstallPing("jebgalgnebhfojomionfpkfelancnnkf",
2191 base::Version("1.0"), 10); 2191 base::Version("1.0"), 10);
2192 } 2192 }
2193 2193
2194 } // namespace update_client 2194 } // namespace update_client
OLDNEW
« no previous file with comments | « components/component_updater/default_component_installer.cc ('k') | components/variations/service/variations_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698