| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <list> | 5 #include <list> |
| 6 #include <map> | 6 #include <map> |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 ManifestFetchData::kNeverPinged, | 138 ManifestFetchData::kNeverPinged, |
| 139 true, | 139 true, |
| 140 0); | 140 0); |
| 141 | 141 |
| 142 class MockExtensionDownloaderDelegate : public ExtensionDownloaderDelegate { | 142 class MockExtensionDownloaderDelegate : public ExtensionDownloaderDelegate { |
| 143 public: | 143 public: |
| 144 MOCK_METHOD4(OnExtensionDownloadFailed, void(const std::string&, | 144 MOCK_METHOD4(OnExtensionDownloadFailed, void(const std::string&, |
| 145 Error, | 145 Error, |
| 146 const PingResult&, | 146 const PingResult&, |
| 147 const std::set<int>&)); | 147 const std::set<int>&)); |
| 148 MOCK_METHOD7(OnExtensionDownloadFinished, void(const std::string&, | 148 MOCK_METHOD8(OnExtensionDownloadFinished, |
| 149 const base::FilePath&, | 149 void(const std::string&, |
| 150 bool, | 150 const base::FilePath&, |
| 151 const GURL&, | 151 const std::string&, |
| 152 const std::string&, | 152 bool, |
| 153 const PingResult&, | 153 const GURL&, |
| 154 const std::set<int>&)); | 154 const std::string&, |
| 155 const PingResult&, |
| 156 const std::set<int>&)); |
| 155 MOCK_METHOD2(GetPingDataForExtension, | 157 MOCK_METHOD2(GetPingDataForExtension, |
| 156 bool(const std::string&, ManifestFetchData::PingData*)); | 158 bool(const std::string&, ManifestFetchData::PingData*)); |
| 157 MOCK_METHOD1(GetUpdateUrlData, std::string(const std::string&)); | 159 MOCK_METHOD1(GetUpdateUrlData, std::string(const std::string&)); |
| 158 MOCK_METHOD1(IsExtensionPending, bool(const std::string&)); | 160 MOCK_METHOD1(IsExtensionPending, bool(const std::string&)); |
| 159 MOCK_METHOD2(GetExtensionExistingVersion, | 161 MOCK_METHOD2(GetExtensionExistingVersion, |
| 160 bool(const std::string&, std::string*)); | 162 bool(const std::string&, std::string*)); |
| 161 | 163 |
| 162 void Wait() { | 164 void Wait() { |
| 163 scoped_refptr<content::MessageLoopRunner> runner = | 165 scoped_refptr<content::MessageLoopRunner> runner = |
| 164 new content::MessageLoopRunner; | 166 new content::MessageLoopRunner; |
| 165 quit_closure_ = runner->QuitClosure(); | 167 quit_closure_ = runner->QuitClosure(); |
| 166 runner->Run(); | 168 runner->Run(); |
| 167 quit_closure_.Reset(); | 169 quit_closure_.Reset(); |
| 168 } | 170 } |
| 169 | 171 |
| 170 void Quit() { | 172 void Quit() { |
| 171 quit_closure_.Run(); | 173 quit_closure_.Run(); |
| 172 } | 174 } |
| 173 | 175 |
| 174 void DelegateTo(ExtensionDownloaderDelegate* delegate) { | 176 void DelegateTo(ExtensionDownloaderDelegate* delegate) { |
| 175 ON_CALL(*this, OnExtensionDownloadFailed(_, _, _, _)) | 177 ON_CALL(*this, OnExtensionDownloadFailed(_, _, _, _)) |
| 176 .WillByDefault(Invoke(delegate, | 178 .WillByDefault(Invoke(delegate, |
| 177 &ExtensionDownloaderDelegate::OnExtensionDownloadFailed)); | 179 &ExtensionDownloaderDelegate::OnExtensionDownloadFailed)); |
| 178 ON_CALL(*this, OnExtensionDownloadFinished(_, _, _, _, _, _, _)) | 180 ON_CALL(*this, OnExtensionDownloadFinished(_, _, _, _, _, _, _, _)) |
| 179 .WillByDefault(Invoke(delegate, | 181 .WillByDefault( |
| 180 &ExtensionDownloaderDelegate::OnExtensionDownloadFinished)); | 182 Invoke(delegate, |
| 183 &ExtensionDownloaderDelegate::OnExtensionDownloadFinished)); |
| 181 ON_CALL(*this, GetPingDataForExtension(_, _)) | 184 ON_CALL(*this, GetPingDataForExtension(_, _)) |
| 182 .WillByDefault(Invoke(delegate, | 185 .WillByDefault(Invoke(delegate, |
| 183 &ExtensionDownloaderDelegate::GetPingDataForExtension)); | 186 &ExtensionDownloaderDelegate::GetPingDataForExtension)); |
| 184 ON_CALL(*this, GetUpdateUrlData(_)) | 187 ON_CALL(*this, GetUpdateUrlData(_)) |
| 185 .WillByDefault(Invoke(delegate, | 188 .WillByDefault(Invoke(delegate, |
| 186 &ExtensionDownloaderDelegate::GetUpdateUrlData)); | 189 &ExtensionDownloaderDelegate::GetUpdateUrlData)); |
| 187 ON_CALL(*this, IsExtensionPending(_)) | 190 ON_CALL(*this, IsExtensionPending(_)) |
| 188 .WillByDefault(Invoke(delegate, | 191 .WillByDefault(Invoke(delegate, |
| 189 &ExtensionDownloaderDelegate::IsExtensionPending)); | 192 &ExtensionDownloaderDelegate::IsExtensionPending)); |
| 190 ON_CALL(*this, GetExtensionExistingVersion(_, _)) | 193 ON_CALL(*this, GetExtensionExistingVersion(_, _)) |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 install_path_ = extension_path; | 510 install_path_ = extension_path; |
| 508 | 511 |
| 509 if (ContainsKey(fake_crx_installers_, id)) { | 512 if (ContainsKey(fake_crx_installers_, id)) { |
| 510 *out_crx_installer = fake_crx_installers_[id]; | 513 *out_crx_installer = fake_crx_installers_[id]; |
| 511 return true; | 514 return true; |
| 512 } | 515 } |
| 513 | 516 |
| 514 return false; | 517 return false; |
| 515 } | 518 } |
| 516 | 519 |
| 520 bool CheckAndUpdateExtension(const std::string& id, |
| 521 const base::FilePath& extension_path, |
| 522 const std::string& hash, |
| 523 bool file_ownership_passed, |
| 524 CrxInstaller** out_crx_installer) override { |
| 525 return UpdateExtension( |
| 526 id, extension_path, file_ownership_passed, out_crx_installer); |
| 527 } |
| 528 |
| 517 PendingExtensionManager* pending_extension_manager() override { | 529 PendingExtensionManager* pending_extension_manager() override { |
| 518 return &pending_extension_manager_; | 530 return &pending_extension_manager_; |
| 519 } | 531 } |
| 520 | 532 |
| 521 const Extension* GetExtensionById(const std::string& id, | 533 const Extension* GetExtensionById(const std::string& id, |
| 522 bool) const override { | 534 bool) const override { |
| 523 last_inquired_extension_id_ = id; | 535 last_inquired_extension_id_ = id; |
| 524 return NULL; | 536 return NULL; |
| 525 } | 537 } |
| 526 | 538 |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 } | 1225 } |
| 1214 | 1226 |
| 1215 fetcher->set_url(test_url); | 1227 fetcher->set_url(test_url); |
| 1216 fetcher->set_status(net::URLRequestStatus()); | 1228 fetcher->set_status(net::URLRequestStatus()); |
| 1217 if (fail) { | 1229 if (fail) { |
| 1218 fetcher->set_response_code(404); | 1230 fetcher->set_response_code(404); |
| 1219 EXPECT_CALL(delegate, OnExtensionDownloadFailed(id, _, _, requests)); | 1231 EXPECT_CALL(delegate, OnExtensionDownloadFailed(id, _, _, requests)); |
| 1220 } else { | 1232 } else { |
| 1221 fetcher->set_response_code(200); | 1233 fetcher->set_response_code(200); |
| 1222 fetcher->SetResponseFilePath(extension_file_path); | 1234 fetcher->SetResponseFilePath(extension_file_path); |
| 1223 EXPECT_CALL(delegate, OnExtensionDownloadFinished( | 1235 EXPECT_CALL(delegate, |
| 1224 id, _, _, _, version.GetString(), _, requests)); | 1236 OnExtensionDownloadFinished( |
| 1237 id, _, _, _, _, version.GetString(), _, requests)); |
| 1225 } | 1238 } |
| 1226 fetcher->delegate()->OnURLFetchComplete(fetcher); | 1239 fetcher->delegate()->OnURLFetchComplete(fetcher); |
| 1227 | 1240 |
| 1228 RunUntilIdle(); | 1241 RunUntilIdle(); |
| 1229 | 1242 |
| 1230 if (fail) { | 1243 if (fail) { |
| 1231 // Don't expect any extension to have been installed. | 1244 // Don't expect any extension to have been installed. |
| 1232 EXPECT_TRUE(service->extension_id().empty()); | 1245 EXPECT_TRUE(service->extension_id().empty()); |
| 1233 } else { | 1246 } else { |
| 1234 // Expect that ExtensionUpdater asked the mock extensions service to | 1247 // Expect that ExtensionUpdater asked the mock extensions service to |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2244 // -prodversionmin (shouldn't update if browser version too old) | 2257 // -prodversionmin (shouldn't update if browser version too old) |
| 2245 // -manifests & updates arriving out of order / interleaved | 2258 // -manifests & updates arriving out of order / interleaved |
| 2246 // -malformed update url (empty, file://, has query, has a # fragment, etc.) | 2259 // -malformed update url (empty, file://, has query, has a # fragment, etc.) |
| 2247 // -An extension gets uninstalled while updates are in progress (so it doesn't | 2260 // -An extension gets uninstalled while updates are in progress (so it doesn't |
| 2248 // "come back from the dead") | 2261 // "come back from the dead") |
| 2249 // -An extension gets manually updated to v3 while we're downloading v2 (ie | 2262 // -An extension gets manually updated to v3 while we're downloading v2 (ie |
| 2250 // you don't get downgraded accidentally) | 2263 // you don't get downgraded accidentally) |
| 2251 // -An update manifest mentions multiple updates | 2264 // -An update manifest mentions multiple updates |
| 2252 | 2265 |
| 2253 } // namespace extensions | 2266 } // namespace extensions |
| OLD | NEW |