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

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

Issue 2856573003: Fix the broken XML parser due to version mismatch. (Closed)
Patch Set: Created 3 years, 7 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 bool CheckForUpdates( 353 bool CheckForUpdates(
354 const std::vector<std::string>& ids_to_check, 354 const std::vector<std::string>& ids_to_check,
355 const IdToComponentPtrMap& components, 355 const IdToComponentPtrMap& components,
356 const std::string& additional_attributes, 356 const std::string& additional_attributes,
357 bool enabled_component_updates, 357 bool enabled_component_updates,
358 const UpdateCheckCallback& update_check_callback) override { 358 const UpdateCheckCallback& update_check_callback) override {
359 /* 359 /*
360 Fake the following response: 360 Fake the following response:
361 361
362 <?xml version='1.0' encoding='UTF-8'?> 362 <?xml version='1.0' encoding='UTF-8'?>
363 <response protocol='3.0'> 363 <response protocol='3.1'>
364 <app appid='jebgalgnebhfojomionfpkfelancnnkf'> 364 <app appid='jebgalgnebhfojomionfpkfelancnnkf'>
365 <updatecheck status='ok'> 365 <updatecheck status='ok'>
366 <urls> 366 <urls>
367 <url codebase='http://localhost/download/'/> 367 <url codebase='http://localhost/download/'/>
368 </urls> 368 </urls>
369 <manifest version='1.0' prodversionmin='11.0.1.0'> 369 <manifest version='1.0' prodversionmin='11.0.1.0'>
370 <packages> 370 <packages>
371 <package name='jebgalgnebhfojomionfpkfelancnnkf.crx' 371 <package name='jebgalgnebhfojomionfpkfelancnnkf.crx'
372 hash_sha256='6fc4b93fd11134de1300c2c0bb88c12b644a4ec0fd 372 hash_sha256='6fc4b93fd11134de1300c2c0bb88c12b644a4ec0fd
373 7c9b12cb7cc067667bde87'/> 373 7c9b12cb7cc067667bde87'/>
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 bool CheckForUpdates( 567 bool CheckForUpdates(
568 const std::vector<std::string>& ids_to_check, 568 const std::vector<std::string>& ids_to_check,
569 const IdToComponentPtrMap& components, 569 const IdToComponentPtrMap& components,
570 const std::string& additional_attributes, 570 const std::string& additional_attributes,
571 bool enabled_component_updates, 571 bool enabled_component_updates,
572 const UpdateCheckCallback& update_check_callback) override { 572 const UpdateCheckCallback& update_check_callback) override {
573 /* 573 /*
574 Fake the following response: 574 Fake the following response:
575 575
576 <?xml version='1.0' encoding='UTF-8'?> 576 <?xml version='1.0' encoding='UTF-8'?>
577 <response protocol='3.0'> 577 <response protocol='3.1'>
578 <app appid='jebgalgnebhfojomionfpkfelancnnkf'> 578 <app appid='jebgalgnebhfojomionfpkfelancnnkf'>
579 <updatecheck status='ok'> 579 <updatecheck status='ok'>
580 <urls> 580 <urls>
581 <url codebase='http://localhost/download/'/> 581 <url codebase='http://localhost/download/'/>
582 </urls> 582 </urls>
583 <manifest version='1.0' prodversionmin='11.0.1.0'> 583 <manifest version='1.0' prodversionmin='11.0.1.0'>
584 <packages> 584 <packages>
585 <package name='jebgalgnebhfojomionfpkfelancnnkf.crx' 585 <package name='jebgalgnebhfojomionfpkfelancnnkf.crx'
586 hash_sha256='6fc4b93fd11134de1300c2c0bb88c12b644a4ec0fd 586 hash_sha256='6fc4b93fd11134de1300c2c0bb88c12b644a4ec0fd
587 7c9b12cb7cc067667bde87'/> 587 7c9b12cb7cc067667bde87'/>
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 bool CheckForUpdates( 839 bool CheckForUpdates(
840 const std::vector<std::string>& ids_to_check, 840 const std::vector<std::string>& ids_to_check,
841 const IdToComponentPtrMap& components, 841 const IdToComponentPtrMap& components,
842 const std::string& additional_attributes, 842 const std::string& additional_attributes,
843 bool enabled_component_updates, 843 bool enabled_component_updates,
844 const UpdateCheckCallback& update_check_callback) override { 844 const UpdateCheckCallback& update_check_callback) override {
845 /* 845 /*
846 Fake the following response: 846 Fake the following response:
847 847
848 <?xml version='1.0' encoding='UTF-8'?> 848 <?xml version='1.0' encoding='UTF-8'?>
849 <response protocol='3.0'> 849 <response protocol='3.1'>
850 <app appid='jebgalgnebhfojomionfpkfelancnnkf'> 850 <app appid='jebgalgnebhfojomionfpkfelancnnkf'>
851 <updatecheck status='ok'> 851 <updatecheck status='ok'>
852 <urls> 852 <urls>
853 <url codebase='http://localhost/download/'/> 853 <url codebase='http://localhost/download/'/>
854 </urls> 854 </urls>
855 <manifest version='1.0' prodversionmin='11.0.1.0'> 855 <manifest version='1.0' prodversionmin='11.0.1.0'>
856 <packages> 856 <packages>
857 <package name='jebgalgnebhfojomionfpkfelancnnkf.crx' 857 <package name='jebgalgnebhfojomionfpkfelancnnkf.crx'
858 hash_sha256='6fc4b93fd11134de1300c2c0bb88c12b644a4ec0fd 858 hash_sha256='6fc4b93fd11134de1300c2c0bb88c12b644a4ec0fd
859 7c9b12cb7cc067667bde87'/> 859 7c9b12cb7cc067667bde87'/>
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 const UpdateCheckCallback& update_check_callback) override { 1117 const UpdateCheckCallback& update_check_callback) override {
1118 static int num_call = 0; 1118 static int num_call = 0;
1119 ++num_call; 1119 ++num_call;
1120 1120
1121 UpdateResponse::Results results; 1121 UpdateResponse::Results results;
1122 1122
1123 if (num_call == 1) { 1123 if (num_call == 1) {
1124 /* 1124 /*
1125 Fake the following response: 1125 Fake the following response:
1126 <?xml version='1.0' encoding='UTF-8'?> 1126 <?xml version='1.0' encoding='UTF-8'?>
1127 <response protocol='3.0'> 1127 <response protocol='3.1'>
1128 <app appid='ihfokbkgjpifnbbojhneepfflplebdkc'> 1128 <app appid='ihfokbkgjpifnbbojhneepfflplebdkc'>
1129 <updatecheck status='ok'> 1129 <updatecheck status='ok'>
1130 <urls> 1130 <urls>
1131 <url codebase='http://localhost/download/'/> 1131 <url codebase='http://localhost/download/'/>
1132 </urls> 1132 </urls>
1133 <manifest version='1.0' prodversionmin='11.0.1.0'> 1133 <manifest version='1.0' prodversionmin='11.0.1.0'>
1134 <packages> 1134 <packages>
1135 <package name='ihfokbkgjpifnbbojhneepfflplebdkc_1.crx' 1135 <package name='ihfokbkgjpifnbbojhneepfflplebdkc_1.crx'
1136 hash_sha256='813c59747e139a608b3b5fc49633affc6db57437 1136 hash_sha256='813c59747e139a608b3b5fc49633affc6db57437
1137 3f309f156ea6d27229c0b3f9'/> 1137 3f309f156ea6d27229c0b3f9'/>
(...skipping 19 matching lines...) Expand all
1157 result.manifest.version = "1.0"; 1157 result.manifest.version = "1.0";
1158 result.manifest.browser_min_version = "11.0.1.0"; 1158 result.manifest.browser_min_version = "11.0.1.0";
1159 result.manifest.packages.push_back(package); 1159 result.manifest.packages.push_back(package);
1160 1160
1161 auto& component = components.at(id); 1161 auto& component = components.at(id);
1162 component->SetParseResult(result); 1162 component->SetParseResult(result);
1163 } else if (num_call == 2) { 1163 } else if (num_call == 2) {
1164 /* 1164 /*
1165 Fake the following response: 1165 Fake the following response:
1166 <?xml version='1.0' encoding='UTF-8'?> 1166 <?xml version='1.0' encoding='UTF-8'?>
1167 <response protocol='3.0'> 1167 <response protocol='3.1'>
1168 <app appid='ihfokbkgjpifnbbojhneepfflplebdkc'> 1168 <app appid='ihfokbkgjpifnbbojhneepfflplebdkc'>
1169 <updatecheck status='ok'> 1169 <updatecheck status='ok'>
1170 <urls> 1170 <urls>
1171 <url codebase='http://localhost/download/'/> 1171 <url codebase='http://localhost/download/'/>
1172 <url codebasediff='http://localhost/download/'/> 1172 <url codebasediff='http://localhost/download/'/>
1173 </urls> 1173 </urls>
1174 <manifest version='2.0' prodversionmin='11.0.1.0'> 1174 <manifest version='2.0' prodversionmin='11.0.1.0'>
1175 <packages> 1175 <packages>
1176 <package name='ihfokbkgjpifnbbojhneepfflplebdkc_2.crx' 1176 <package name='ihfokbkgjpifnbbojhneepfflplebdkc_2.crx'
1177 namediff='ihfokbkgjpifnbbojhneepfflplebdkc_1to2.crx' 1177 namediff='ihfokbkgjpifnbbojhneepfflplebdkc_1to2.crx'
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 bool CheckForUpdates( 1425 bool CheckForUpdates(
1426 const std::vector<std::string>& ids_to_check, 1426 const std::vector<std::string>& ids_to_check,
1427 const IdToComponentPtrMap& components, 1427 const IdToComponentPtrMap& components,
1428 const std::string& additional_attributes, 1428 const std::string& additional_attributes,
1429 bool enabled_component_updates, 1429 bool enabled_component_updates,
1430 const UpdateCheckCallback& update_check_callback) override { 1430 const UpdateCheckCallback& update_check_callback) override {
1431 /* 1431 /*
1432 Fake the following response: 1432 Fake the following response:
1433 1433
1434 <?xml version='1.0' encoding='UTF-8'?> 1434 <?xml version='1.0' encoding='UTF-8'?>
1435 <response protocol='3.0'> 1435 <response protocol='3.1'>
1436 <app appid='jebgalgnebhfojomionfpkfelancnnkf'> 1436 <app appid='jebgalgnebhfojomionfpkfelancnnkf'>
1437 <updatecheck status='ok'> 1437 <updatecheck status='ok'>
1438 <urls> 1438 <urls>
1439 <url codebase='http://localhost/download/'/> 1439 <url codebase='http://localhost/download/'/>
1440 </urls> 1440 </urls>
1441 <manifest version='1.0' prodversionmin='11.0.1.0'> 1441 <manifest version='1.0' prodversionmin='11.0.1.0'>
1442 <packages> 1442 <packages>
1443 <package name='jebgalgnebhfojomionfpkfelancnnkf.crx' 1443 <package name='jebgalgnebhfojomionfpkfelancnnkf.crx'
1444 hash_sha256='6fc4b93fd11134de1300c2c0bb88c12b644a4ec0fd 1444 hash_sha256='6fc4b93fd11134de1300c2c0bb88c12b644a4ec0fd
1445 7c9b12cb7cc067667bde87'/> 1445 7c9b12cb7cc067667bde87'/>
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 const UpdateCheckCallback& update_check_callback) override { 1620 const UpdateCheckCallback& update_check_callback) override {
1621 static int num_call = 0; 1621 static int num_call = 0;
1622 ++num_call; 1622 ++num_call;
1623 1623
1624 UpdateResponse::Results results; 1624 UpdateResponse::Results results;
1625 1625
1626 if (num_call == 1) { 1626 if (num_call == 1) {
1627 /* 1627 /*
1628 Fake the following response: 1628 Fake the following response:
1629 <?xml version='1.0' encoding='UTF-8'?> 1629 <?xml version='1.0' encoding='UTF-8'?>
1630 <response protocol='3.0'> 1630 <response protocol='3.1'>
1631 <app appid='ihfokbkgjpifnbbojhneepfflplebdkc'> 1631 <app appid='ihfokbkgjpifnbbojhneepfflplebdkc'>
1632 <updatecheck status='ok'> 1632 <updatecheck status='ok'>
1633 <urls> 1633 <urls>
1634 <url codebase='http://localhost/download/'/> 1634 <url codebase='http://localhost/download/'/>
1635 </urls> 1635 </urls>
1636 <manifest version='1.0' prodversionmin='11.0.1.0'> 1636 <manifest version='1.0' prodversionmin='11.0.1.0'>
1637 <packages> 1637 <packages>
1638 <package name='ihfokbkgjpifnbbojhneepfflplebdkc_1.crx' 1638 <package name='ihfokbkgjpifnbbojhneepfflplebdkc_1.crx'
1639 hash_sha256='813c59747e139a608b3b5fc49633affc6db57437 1639 hash_sha256='813c59747e139a608b3b5fc49633affc6db57437
1640 3f309f156ea6d27229c0b3f9' 1640 3f309f156ea6d27229c0b3f9'
(...skipping 21 matching lines...) Expand all
1662 result.manifest.version = "1.0"; 1662 result.manifest.version = "1.0";
1663 result.manifest.browser_min_version = "11.0.1.0"; 1663 result.manifest.browser_min_version = "11.0.1.0";
1664 result.manifest.packages.push_back(package); 1664 result.manifest.packages.push_back(package);
1665 1665
1666 auto& component = components.at(id); 1666 auto& component = components.at(id);
1667 component->SetParseResult(result); 1667 component->SetParseResult(result);
1668 } else if (num_call == 2) { 1668 } else if (num_call == 2) {
1669 /* 1669 /*
1670 Fake the following response: 1670 Fake the following response:
1671 <?xml version='1.0' encoding='UTF-8'?> 1671 <?xml version='1.0' encoding='UTF-8'?>
1672 <response protocol='3.0'> 1672 <response protocol='3.1'>
1673 <app appid='ihfokbkgjpifnbbojhneepfflplebdkc'> 1673 <app appid='ihfokbkgjpifnbbojhneepfflplebdkc'>
1674 <updatecheck status='ok'> 1674 <updatecheck status='ok'>
1675 <urls> 1675 <urls>
1676 <url codebase='http://localhost/download/'/> 1676 <url codebase='http://localhost/download/'/>
1677 <url codebasediff='http://localhost/download/'/> 1677 <url codebasediff='http://localhost/download/'/>
1678 </urls> 1678 </urls>
1679 <manifest version='2.0' prodversionmin='11.0.1.0'> 1679 <manifest version='2.0' prodversionmin='11.0.1.0'>
1680 <packages> 1680 <packages>
1681 <package name='ihfokbkgjpifnbbojhneepfflplebdkc_2.crx' 1681 <package name='ihfokbkgjpifnbbojhneepfflplebdkc_2.crx'
1682 namediff='ihfokbkgjpifnbbojhneepfflplebdkc_1to2.crx' 1682 namediff='ihfokbkgjpifnbbojhneepfflplebdkc_1to2.crx'
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
2038 bool CheckForUpdates( 2038 bool CheckForUpdates(
2039 const std::vector<std::string>& ids_to_check, 2039 const std::vector<std::string>& ids_to_check,
2040 const IdToComponentPtrMap& components, 2040 const IdToComponentPtrMap& components,
2041 const std::string& additional_attributes, 2041 const std::string& additional_attributes,
2042 bool enabled_component_updates, 2042 bool enabled_component_updates,
2043 const UpdateCheckCallback& update_check_callback) override { 2043 const UpdateCheckCallback& update_check_callback) override {
2044 /* 2044 /*
2045 Fake the following response: 2045 Fake the following response:
2046 2046
2047 <?xml version='1.0' encoding='UTF-8'?> 2047 <?xml version='1.0' encoding='UTF-8'?>
2048 <response protocol='3.0'> 2048 <response protocol='3.1'>
2049 <app appid='jebgalgnebhfojomionfpkfelancnnkf'> 2049 <app appid='jebgalgnebhfojomionfpkfelancnnkf'>
2050 <updatecheck status='ok'> 2050 <updatecheck status='ok'>
2051 <urls> 2051 <urls>
2052 <url codebase='http://localhost/download/'/> 2052 <url codebase='http://localhost/download/'/>
2053 </urls> 2053 </urls>
2054 <manifest version='1.0' prodversionmin='11.0.1.0'> 2054 <manifest version='1.0' prodversionmin='11.0.1.0'>
2055 <packages> 2055 <packages>
2056 <package name='jebgalgnebhfojomionfpkfelancnnkf.crx' 2056 <package name='jebgalgnebhfojomionfpkfelancnnkf.crx'
2057 hash_sha256='6fc4b93fd11134de1300c2c0bb88c12b644a4ec0fd 2057 hash_sha256='6fc4b93fd11134de1300c2c0bb88c12b644a4ec0fd
2058 7c9b12cb7cc067667bde87'/> 2058 7c9b12cb7cc067667bde87'/>
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
2674 bool CheckForUpdates( 2674 bool CheckForUpdates(
2675 const std::vector<std::string>& ids_to_check, 2675 const std::vector<std::string>& ids_to_check,
2676 const IdToComponentPtrMap& components, 2676 const IdToComponentPtrMap& components,
2677 const std::string& additional_attributes, 2677 const std::string& additional_attributes,
2678 bool enabled_component_updates, 2678 bool enabled_component_updates,
2679 const UpdateCheckCallback& update_check_callback) override { 2679 const UpdateCheckCallback& update_check_callback) override {
2680 /* 2680 /*
2681 Fake the following response: 2681 Fake the following response:
2682 2682
2683 <?xml version='1.0' encoding='UTF-8'?> 2683 <?xml version='1.0' encoding='UTF-8'?>
2684 <response protocol='3.0'> 2684 <response protocol='3.1'>
2685 <app appid='jebgalgnebhfojomionfpkfelancnnkf'> 2685 <app appid='jebgalgnebhfojomionfpkfelancnnkf'>
2686 <updatecheck status='ok'> 2686 <updatecheck status='ok'>
2687 <urls> 2687 <urls>
2688 <url codebase='http://localhost/download/'/> 2688 <url codebase='http://localhost/download/'/>
2689 </urls> 2689 </urls>
2690 <manifest version='1.0' prodversionmin='11.0.1.0'> 2690 <manifest version='1.0' prodversionmin='11.0.1.0'>
2691 <packages> 2691 <packages>
2692 <package name='jebgalgnebhfojomionfpkfelancnnkf.crx' 2692 <package name='jebgalgnebhfojomionfpkfelancnnkf.crx'
2693 hash_sha256='6fc4b93fd11134de1300c2c0bb88c12b644a4ec0fd 2693 hash_sha256='6fc4b93fd11134de1300c2c0bb88c12b644a4ec0fd
2694 7c9b12cb7cc067667bde87'/> 2694 7c9b12cb7cc067667bde87'/>
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
2884 update_client->Update( 2884 update_client->Update(
2885 ids, base::Bind(&DataCallbackFake::Callback), 2885 ids, base::Bind(&DataCallbackFake::Callback),
2886 base::Bind(&CompletionCallbackFake::Callback, quit_closure())); 2886 base::Bind(&CompletionCallbackFake::Callback, quit_closure()));
2887 2887
2888 RunThreads(); 2888 RunThreads();
2889 2889
2890 update_client->RemoveObserver(&observer); 2890 update_client->RemoveObserver(&observer);
2891 } 2891 }
2892 2892
2893 } // namespace update_client 2893 } // namespace update_client
OLDNEW
« no previous file with comments | « components/test/data/update_client/updatecheck_reply_noupdate.xml ('k') | components/update_client/update_response.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698