| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "base/scoped_ptr.h" |
| 9 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| 10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 11 #include "base/thread.h" | 12 #include "base/thread.h" |
| 13 #include "base/version.h" |
| 12 #include "chrome/browser/chrome_thread.h" | 14 #include "chrome/browser/chrome_thread.h" |
| 13 #include "chrome/browser/extensions/extension_updater.h" | 15 #include "chrome/browser/extensions/extension_updater.h" |
| 14 #include "chrome/browser/extensions/extensions_service.h" | 16 #include "chrome/browser/extensions/extensions_service.h" |
| 15 #include "chrome/browser/net/test_url_fetcher_factory.h" | 17 #include "chrome/browser/net/test_url_fetcher_factory.h" |
| 16 #include "chrome/browser/pref_service.h" | 18 #include "chrome/browser/pref_service.h" |
| 17 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
| 18 #include "chrome/common/extensions/extension_constants.h" | 20 #include "chrome/common/extensions/extension_constants.h" |
| 19 #include "chrome/common/extensions/extension_error_reporter.h" | 21 #include "chrome/common/extensions/extension_error_reporter.h" |
| 20 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 21 #include "net/base/escape.h" | 23 #include "net/base/escape.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 43 class MockService : public ExtensionUpdateService { | 45 class MockService : public ExtensionUpdateService { |
| 44 public: | 46 public: |
| 45 MockService() {} | 47 MockService() {} |
| 46 virtual ~MockService() {} | 48 virtual ~MockService() {} |
| 47 | 49 |
| 48 virtual const ExtensionList* extensions() const { | 50 virtual const ExtensionList* extensions() const { |
| 49 EXPECT_TRUE(false); | 51 EXPECT_TRUE(false); |
| 50 return NULL; | 52 return NULL; |
| 51 } | 53 } |
| 52 | 54 |
| 55 virtual const PendingExtensionMap& pending_extensions() const { |
| 56 EXPECT_TRUE(false); |
| 57 return pending_extensions_; |
| 58 } |
| 59 |
| 53 virtual void UpdateExtension(const std::string& id, | 60 virtual void UpdateExtension(const std::string& id, |
| 54 const FilePath& extension_path, | 61 const FilePath& extension_path, |
| 55 const GURL& download_url) { | 62 const GURL& download_url) { |
| 56 EXPECT_TRUE(false); | 63 EXPECT_TRUE(false); |
| 57 } | 64 } |
| 58 | 65 |
| 59 virtual Extension* GetExtensionById(const std::string& id, bool) { | 66 virtual Extension* GetExtensionById(const std::string& id, bool) { |
| 60 EXPECT_TRUE(false); | 67 EXPECT_TRUE(false); |
| 61 return NULL; | 68 return NULL; |
| 62 } | 69 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 78 | 85 |
| 79 virtual Time LastPingDay(const std::string& extension_id) { | 86 virtual Time LastPingDay(const std::string& extension_id) { |
| 80 std::map<std::string, Time>::iterator i = | 87 std::map<std::string, Time>::iterator i = |
| 81 last_ping_days_.find(extension_id); | 88 last_ping_days_.find(extension_id); |
| 82 if (i != last_ping_days_.end()) | 89 if (i != last_ping_days_.end()) |
| 83 return i->second; | 90 return i->second; |
| 84 | 91 |
| 85 return Time(); | 92 return Time(); |
| 86 } | 93 } |
| 87 | 94 |
| 95 protected: |
| 96 PendingExtensionMap pending_extensions_; |
| 97 |
| 88 private: | 98 private: |
| 89 std::map<std::string, Time> last_ping_days_; | 99 std::map<std::string, Time> last_ping_days_; |
| 90 DISALLOW_COPY_AND_ASSIGN(MockService); | 100 DISALLOW_COPY_AND_ASSIGN(MockService); |
| 91 }; | 101 }; |
| 92 | 102 |
| 93 // Class that contains a PrefService and handles cleanup of a temporary file | 103 // Class that contains a PrefService and handles cleanup of a temporary file |
| 94 // backing it. | 104 // backing it. |
| 95 class ScopedTempPrefService { | 105 class ScopedTempPrefService { |
| 96 public: | 106 public: |
| 97 ScopedTempPrefService() { | 107 ScopedTempPrefService() { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 input.SetString(extension_manifest_keys::kName, | 143 input.SetString(extension_manifest_keys::kName, |
| 134 StringPrintf("Extension %d", i)); | 144 StringPrintf("Extension %d", i)); |
| 135 if (update_url) | 145 if (update_url) |
| 136 input.SetString(extension_manifest_keys::kUpdateURL, *update_url); | 146 input.SetString(extension_manifest_keys::kUpdateURL, *update_url); |
| 137 std::string error; | 147 std::string error; |
| 138 EXPECT_TRUE(e->InitFromValue(input, false, &error)); | 148 EXPECT_TRUE(e->InitFromValue(input, false, &error)); |
| 139 list->push_back(e); | 149 list->push_back(e); |
| 140 } | 150 } |
| 141 } | 151 } |
| 142 | 152 |
| 153 // Creates test pending extensions and inserts them into list. The |
| 154 // name and version are all based on their index. |
| 155 void CreateTestPendingExtensions(int count, const GURL& update_url, |
| 156 PendingExtensionMap* pending_extensions) { |
| 157 for (int i = 1; i <= count; i++) { |
| 158 bool is_theme = (i % 2) == 0; |
| 159 const bool kInstallSilently = true; |
| 160 scoped_ptr<Version> version( |
| 161 Version::GetVersionFromString(StringPrintf("%d.0.0.0", i))); |
| 162 ASSERT_TRUE(version.get()); |
| 163 (*pending_extensions)[StringPrintf("extension%i", i)] = |
| 164 PendingExtensionInfo(update_url, *version, |
| 165 is_theme, kInstallSilently); |
| 166 } |
| 167 } |
| 168 |
| 143 class ServiceForManifestTests : public MockService { | 169 class ServiceForManifestTests : public MockService { |
| 144 public: | 170 public: |
| 145 ServiceForManifestTests() : has_installed_extensions_(false) {} | 171 ServiceForManifestTests() : has_installed_extensions_(false) {} |
| 146 | 172 |
| 147 virtual ~ServiceForManifestTests() {} | 173 virtual ~ServiceForManifestTests() {} |
| 148 | 174 |
| 149 virtual Extension* GetExtensionById(const std::string& id, bool) { | 175 virtual Extension* GetExtensionById(const std::string& id, bool) { |
| 150 for (ExtensionList::iterator iter = extensions_.begin(); | 176 for (ExtensionList::iterator iter = extensions_.begin(); |
| 151 iter != extensions_.end(); ++iter) { | 177 iter != extensions_.end(); ++iter) { |
| 152 if ((*iter)->id() == id) { | 178 if ((*iter)->id() == id) { |
| 153 return *iter; | 179 return *iter; |
| 154 } | 180 } |
| 155 } | 181 } |
| 156 return NULL; | 182 return NULL; |
| 157 } | 183 } |
| 158 | 184 |
| 159 virtual const ExtensionList* extensions() const { return &extensions_; } | 185 virtual const ExtensionList* extensions() const { return &extensions_; } |
| 160 | 186 |
| 187 virtual const PendingExtensionMap& pending_extensions() const { |
| 188 return pending_extensions_; |
| 189 } |
| 190 |
| 161 void set_extensions(ExtensionList extensions) { | 191 void set_extensions(ExtensionList extensions) { |
| 162 extensions_ = extensions; | 192 extensions_ = extensions; |
| 163 } | 193 } |
| 164 | 194 |
| 195 void set_pending_extensions( |
| 196 const PendingExtensionMap& pending_extensions) { |
| 197 pending_extensions_ = pending_extensions; |
| 198 } |
| 199 |
| 165 virtual bool HasInstalledExtensions() { | 200 virtual bool HasInstalledExtensions() { |
| 166 return has_installed_extensions_; | 201 return has_installed_extensions_; |
| 167 } | 202 } |
| 168 | 203 |
| 169 void set_has_installed_extensions(bool value) { | 204 void set_has_installed_extensions(bool value) { |
| 170 has_installed_extensions_ = value; | 205 has_installed_extensions_ = value; |
| 171 } | 206 } |
| 172 | 207 |
| 173 private: | 208 private: |
| 174 ExtensionList extensions_; | 209 ExtensionList extensions_; |
| 175 bool has_installed_extensions_; | 210 bool has_installed_extensions_; |
| 176 }; | 211 }; |
| 177 | 212 |
| 178 class ServiceForDownloadTests : public MockService { | 213 class ServiceForDownloadTests : public MockService { |
| 179 public: | 214 public: |
| 180 virtual void UpdateExtension(const std::string& id, | 215 virtual void UpdateExtension(const std::string& id, |
| 181 const FilePath& extension_path, | 216 const FilePath& extension_path, |
| 182 const GURL& download_url) { | 217 const GURL& download_url) { |
| 183 extension_id_ = id; | 218 extension_id_ = id; |
| 184 install_path_ = extension_path; | 219 install_path_ = extension_path; |
| 185 download_url_ = download_url; | 220 download_url_ = download_url; |
| 186 } | 221 } |
| 187 | 222 |
| 223 virtual const PendingExtensionMap& pending_extensions() const { |
| 224 return pending_extensions_; |
| 225 } |
| 226 |
| 188 virtual Extension* GetExtensionById(const std::string& id, bool) { | 227 virtual Extension* GetExtensionById(const std::string& id, bool) { |
| 189 last_inquired_extension_id_ = id; | 228 last_inquired_extension_id_ = id; |
| 190 return NULL; | 229 return NULL; |
| 191 } | 230 } |
| 192 | 231 |
| 232 void set_pending_extensions( |
| 233 const PendingExtensionMap& pending_extensions) { |
| 234 pending_extensions_ = pending_extensions; |
| 235 } |
| 236 |
| 193 const std::string& extension_id() { return extension_id_; } | 237 const std::string& extension_id() { return extension_id_; } |
| 194 const FilePath& install_path() { return install_path_; } | 238 const FilePath& install_path() { return install_path_; } |
| 195 const GURL& download_url() { return download_url_; } | 239 const GURL& download_url() { return download_url_; } |
| 196 const std::string& last_inquired_extension_id() { | 240 const std::string& last_inquired_extension_id() { |
| 197 return last_inquired_extension_id_; | 241 return last_inquired_extension_id_; |
| 198 } | 242 } |
| 199 | 243 |
| 200 private: | 244 private: |
| 201 std::string extension_id_; | 245 std::string extension_id_; |
| 202 FilePath install_path_; | 246 FilePath install_path_; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 const std::string& version, | 309 const std::string& version, |
| 266 const std::string& url, | 310 const std::string& url, |
| 267 UpdateManifest::Results* results) { | 311 UpdateManifest::Results* results) { |
| 268 UpdateManifest::Result result; | 312 UpdateManifest::Result result; |
| 269 result.extension_id = id; | 313 result.extension_id = id; |
| 270 result.version = version; | 314 result.version = version; |
| 271 result.crx_url = GURL(url); | 315 result.crx_url = GURL(url); |
| 272 results->list.push_back(result); | 316 results->list.push_back(result); |
| 273 } | 317 } |
| 274 | 318 |
| 275 static void TestExtensionUpdateCheckRequests() { | 319 static void TestExtensionUpdateCheckRequests(bool pending) { |
| 276 // Create an extension with an update_url. | 320 // Create an extension with an update_url. |
| 277 ServiceForManifestTests service; | 321 ServiceForManifestTests service; |
| 278 ExtensionList tmp; | |
| 279 std::string update_url("http://foo.com/bar"); | 322 std::string update_url("http://foo.com/bar"); |
| 280 CreateTestExtensions(1, &tmp, &update_url); | 323 ExtensionList extensions; |
| 281 service.set_extensions(tmp); | 324 PendingExtensionMap pending_extensions; |
| 325 if (pending) { |
| 326 CreateTestPendingExtensions(1, GURL(update_url), &pending_extensions); |
| 327 service.set_pending_extensions(pending_extensions); |
| 328 } else { |
| 329 CreateTestExtensions(1, &extensions, &update_url); |
| 330 service.set_extensions(extensions); |
| 331 } |
| 282 | 332 |
| 283 // Setup and start the updater. | 333 // Setup and start the updater. |
| 284 MessageLoop message_loop; | 334 MessageLoop message_loop; |
| 285 ChromeThread io_thread(ChromeThread::IO); | 335 ChromeThread io_thread(ChromeThread::IO); |
| 286 io_thread.Start(); | 336 io_thread.Start(); |
| 287 | 337 |
| 288 TestURLFetcherFactory factory; | 338 TestURLFetcherFactory factory; |
| 289 URLFetcher::set_factory(&factory); | 339 URLFetcher::set_factory(&factory); |
| 290 ScopedTempPrefService prefs; | 340 ScopedTempPrefService prefs; |
| 291 scoped_refptr<ExtensionUpdater> updater = | 341 scoped_refptr<ExtensionUpdater> updater = |
| (...skipping 17 matching lines...) Expand all Loading... |
| 309 // look something like "?x=id%3D<id>%26v%3D<version>%26uc". | 359 // look something like "?x=id%3D<id>%26v%3D<version>%26uc". |
| 310 EXPECT_TRUE(url.has_query()); | 360 EXPECT_TRUE(url.has_query()); |
| 311 std::vector<std::string> parts; | 361 std::vector<std::string> parts; |
| 312 SplitString(url.query(), '=', &parts); | 362 SplitString(url.query(), '=', &parts); |
| 313 EXPECT_EQ(2u, parts.size()); | 363 EXPECT_EQ(2u, parts.size()); |
| 314 EXPECT_EQ("x", parts[0]); | 364 EXPECT_EQ("x", parts[0]); |
| 315 std::string decoded = UnescapeURLComponent(parts[1], | 365 std::string decoded = UnescapeURLComponent(parts[1], |
| 316 UnescapeRule::URL_SPECIAL_CHARS); | 366 UnescapeRule::URL_SPECIAL_CHARS); |
| 317 std::map<std::string, std::string> params; | 367 std::map<std::string, std::string> params; |
| 318 ExtractParameters(decoded, ¶ms); | 368 ExtractParameters(decoded, ¶ms); |
| 319 EXPECT_EQ(tmp[0]->id(), params["id"]); | 369 if (pending) { |
| 320 EXPECT_EQ(tmp[0]->VersionString(), params["v"]); | 370 EXPECT_EQ(pending_extensions.begin()->first, params["id"]); |
| 371 EXPECT_EQ("1.0.0.0", params["v"]); |
| 372 } else { |
| 373 EXPECT_EQ(extensions[0]->id(), params["id"]); |
| 374 EXPECT_EQ(extensions[0]->VersionString(), params["v"]); |
| 375 } |
| 321 EXPECT_EQ("", params["uc"]); | 376 EXPECT_EQ("", params["uc"]); |
| 322 | 377 |
| 323 STLDeleteElements(&tmp); | 378 if (!pending) { |
| 379 STLDeleteElements(&extensions); |
| 380 } |
| 324 } | 381 } |
| 325 | 382 |
| 326 static void TestBlacklistUpdateCheckRequests() { | 383 static void TestBlacklistUpdateCheckRequests() { |
| 327 ServiceForManifestTests service; | 384 ServiceForManifestTests service; |
| 328 | 385 |
| 329 // Setup and start the updater. | 386 // Setup and start the updater. |
| 330 MessageLoop message_loop; | 387 MessageLoop message_loop; |
| 331 ChromeThread io_thread(ChromeThread::IO); | 388 ChromeThread io_thread(ChromeThread::IO); |
| 332 io_thread.Start(); | 389 io_thread.Start(); |
| 333 | 390 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 fetch_data.AddExtension(tmp[1]->id(), tmp[1]->VersionString(), | 465 fetch_data.AddExtension(tmp[1]->id(), tmp[1]->VersionString(), |
| 409 ManifestFetchData::kNeverPinged); | 466 ManifestFetchData::kNeverPinged); |
| 410 AddParseResult(tmp[1]->id(), | 467 AddParseResult(tmp[1]->id(), |
| 411 tmp[1]->VersionString(), "http://localhost/e2_2.0.crx", &updates); | 468 tmp[1]->VersionString(), "http://localhost/e2_2.0.crx", &updates); |
| 412 updateable = updater->DetermineUpdates(fetch_data, updates); | 469 updateable = updater->DetermineUpdates(fetch_data, updates); |
| 413 EXPECT_EQ(1u, updateable.size()); | 470 EXPECT_EQ(1u, updateable.size()); |
| 414 EXPECT_EQ(0, updateable[0]); | 471 EXPECT_EQ(0, updateable[0]); |
| 415 STLDeleteElements(&tmp); | 472 STLDeleteElements(&tmp); |
| 416 } | 473 } |
| 417 | 474 |
| 475 static void TestDetermineUpdatesPending() { |
| 476 // Create a set of test extensions |
| 477 ServiceForManifestTests service; |
| 478 PendingExtensionMap pending_extensions; |
| 479 CreateTestPendingExtensions(3, GURL(), &pending_extensions); |
| 480 service.set_pending_extensions(pending_extensions); |
| 481 |
| 482 MessageLoop message_loop; |
| 483 ScopedTempPrefService prefs; |
| 484 scoped_refptr<ExtensionUpdater> updater = |
| 485 new ExtensionUpdater(&service, prefs.get(), kUpdateFrequencySecs); |
| 486 |
| 487 ManifestFetchData fetch_data(GURL("http://localhost/foo")); |
| 488 UpdateManifest::Results updates; |
| 489 for (PendingExtensionMap::const_iterator it = pending_extensions.begin(); |
| 490 it != pending_extensions.end(); ++it) { |
| 491 fetch_data.AddExtension(it->first, |
| 492 it->second.version.GetString(), |
| 493 ManifestFetchData::kNeverPinged); |
| 494 AddParseResult(it->first, |
| 495 "1.1", "http://localhost/e1_1.1.crx", &updates); |
| 496 } |
| 497 std::vector<int> updateable = |
| 498 updater->DetermineUpdates(fetch_data, updates); |
| 499 // Only the first one is updateable. |
| 500 EXPECT_EQ(1u, updateable.size()); |
| 501 for (std::vector<int>::size_type i = 0; i < updateable.size(); ++i) { |
| 502 EXPECT_EQ(static_cast<int>(i), updateable[i]); |
| 503 } |
| 504 } |
| 505 |
| 418 static void TestMultipleManifestDownloading() { | 506 static void TestMultipleManifestDownloading() { |
| 419 MessageLoop ui_loop; | 507 MessageLoop ui_loop; |
| 420 ChromeThread ui_thread(ChromeThread::UI, &ui_loop); | 508 ChromeThread ui_thread(ChromeThread::UI, &ui_loop); |
| 421 ChromeThread file_thread(ChromeThread::FILE); | 509 ChromeThread file_thread(ChromeThread::FILE); |
| 422 file_thread.Start(); | 510 file_thread.Start(); |
| 423 ChromeThread io_thread(ChromeThread::IO); | 511 ChromeThread io_thread(ChromeThread::IO); |
| 424 io_thread.Start(); | 512 io_thread.Start(); |
| 425 | 513 |
| 426 TestURLFetcherFactory factory; | 514 TestURLFetcherFactory factory; |
| 427 TestURLFetcher* fetcher = NULL; | 515 TestURLFetcher* fetcher = NULL; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 // This should run the manifest parsing, then we want to make sure that our | 560 // This should run the manifest parsing, then we want to make sure that our |
| 473 // service was called with GetExtensionById with the matching id from | 561 // service was called with GetExtensionById with the matching id from |
| 474 // kValidXml. | 562 // kValidXml. |
| 475 file_thread.Stop(); | 563 file_thread.Stop(); |
| 476 io_thread.Stop(); | 564 io_thread.Stop(); |
| 477 ui_loop.RunAllPending(); | 565 ui_loop.RunAllPending(); |
| 478 EXPECT_EQ("12345", service.last_inquired_extension_id()); | 566 EXPECT_EQ("12345", service.last_inquired_extension_id()); |
| 479 xmlCleanupGlobals(); | 567 xmlCleanupGlobals(); |
| 480 } | 568 } |
| 481 | 569 |
| 482 static void TestSingleExtensionDownloading() { | 570 static void TestSingleExtensionDownloading(bool pending) { |
| 483 MessageLoop ui_loop; | 571 MessageLoop ui_loop; |
| 484 ChromeThread ui_thread(ChromeThread::UI, &ui_loop); | 572 ChromeThread ui_thread(ChromeThread::UI, &ui_loop); |
| 485 ChromeThread file_thread(ChromeThread::FILE); | 573 ChromeThread file_thread(ChromeThread::FILE); |
| 486 file_thread.Start(); | 574 file_thread.Start(); |
| 487 ChromeThread io_thread(ChromeThread::IO); | 575 ChromeThread io_thread(ChromeThread::IO); |
| 488 io_thread.Start(); | 576 io_thread.Start(); |
| 489 | 577 |
| 490 TestURLFetcherFactory factory; | 578 TestURLFetcherFactory factory; |
| 491 TestURLFetcher* fetcher = NULL; | 579 TestURLFetcher* fetcher = NULL; |
| 492 URLFetcher::set_factory(&factory); | 580 URLFetcher::set_factory(&factory); |
| 493 ServiceForDownloadTests service; | 581 ServiceForDownloadTests service; |
| 494 ScopedTempPrefService prefs; | 582 ScopedTempPrefService prefs; |
| 495 scoped_refptr<ExtensionUpdater> updater = | 583 scoped_refptr<ExtensionUpdater> updater = |
| 496 new ExtensionUpdater(&service, prefs.get(), kUpdateFrequencySecs); | 584 new ExtensionUpdater(&service, prefs.get(), kUpdateFrequencySecs); |
| 497 | 585 |
| 498 GURL test_url("http://localhost/extension.crx"); | 586 GURL test_url("http://localhost/extension.crx"); |
| 499 | 587 |
| 500 std::string id = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; | 588 std::string id = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; |
| 501 std::string hash = ""; | 589 std::string hash = ""; |
| 502 std::string version = "0.0.1"; | 590 scoped_ptr<Version> version(Version::GetVersionFromString("0.0.1")); |
| 591 ASSERT_TRUE(version.get()); |
| 592 updater->FetchUpdatedExtension(id, test_url, hash, version->GetString()); |
| 503 | 593 |
| 504 updater->FetchUpdatedExtension(id, test_url, hash, version); | 594 if (pending) { |
| 595 const bool kIsTheme = false; |
| 596 const bool kInstallSilently = true; |
| 597 PendingExtensionMap pending_extensions; |
| 598 pending_extensions[id] = |
| 599 PendingExtensionInfo(test_url, *version, |
| 600 kIsTheme, kInstallSilently); |
| 601 service.set_pending_extensions(pending_extensions); |
| 602 } |
| 505 | 603 |
| 506 // Call back the ExtensionUpdater with a 200 response and some test data | 604 // Call back the ExtensionUpdater with a 200 response and some test data |
| 507 std::string extension_data("whatever"); | 605 std::string extension_data("whatever"); |
| 508 fetcher = factory.GetFetcherByID(ExtensionUpdater::kExtensionFetcherId); | 606 fetcher = factory.GetFetcherByID(ExtensionUpdater::kExtensionFetcherId); |
| 509 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); | 607 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); |
| 510 EXPECT_TRUE(fetcher->load_flags() == expected_load_flags); | 608 EXPECT_TRUE(fetcher->load_flags() == expected_load_flags); |
| 511 fetcher->delegate()->OnURLFetchComplete( | 609 fetcher->delegate()->OnURLFetchComplete( |
| 512 fetcher, test_url, URLRequestStatus(), 200, ResponseCookies(), | 610 fetcher, test_url, URLRequestStatus(), 200, ResponseCookies(), |
| 513 extension_data); | 611 extension_data); |
| 514 | 612 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 | 847 |
| 750 STLDeleteElements(&tmp); | 848 STLDeleteElements(&tmp); |
| 751 } | 849 } |
| 752 }; | 850 }; |
| 753 | 851 |
| 754 // Because we test some private methods of ExtensionUpdater, it's easer for the | 852 // Because we test some private methods of ExtensionUpdater, it's easer for the |
| 755 // actual test code to live in ExtenionUpdaterTest methods instead of TEST_F | 853 // actual test code to live in ExtenionUpdaterTest methods instead of TEST_F |
| 756 // subclasses where friendship with ExtenionUpdater is not inherited. | 854 // subclasses where friendship with ExtenionUpdater is not inherited. |
| 757 | 855 |
| 758 TEST(ExtensionUpdaterTest, TestExtensionUpdateCheckRequests) { | 856 TEST(ExtensionUpdaterTest, TestExtensionUpdateCheckRequests) { |
| 759 ExtensionUpdaterTest::TestExtensionUpdateCheckRequests(); | 857 ExtensionUpdaterTest::TestExtensionUpdateCheckRequests(false); |
| 858 } |
| 859 |
| 860 TEST(ExtensionUpdaterTest, TestExtensionUpdateCheckRequestsPending) { |
| 861 ExtensionUpdaterTest::TestExtensionUpdateCheckRequests(true); |
| 760 } | 862 } |
| 761 | 863 |
| 762 // This test is disabled on Mac, see http://crbug.com/26035. | 864 // This test is disabled on Mac, see http://crbug.com/26035. |
| 763 TEST(ExtensionUpdaterTest, MAYBE_TestBlacklistUpdateCheckRequests) { | 865 TEST(ExtensionUpdaterTest, MAYBE_TestBlacklistUpdateCheckRequests) { |
| 764 ExtensionUpdaterTest::TestBlacklistUpdateCheckRequests(); | 866 ExtensionUpdaterTest::TestBlacklistUpdateCheckRequests(); |
| 765 } | 867 } |
| 766 | 868 |
| 767 TEST(ExtensionUpdaterTest, TestDetermineUpdates) { | 869 TEST(ExtensionUpdaterTest, TestDetermineUpdates) { |
| 768 ExtensionUpdaterTest::TestDetermineUpdates(); | 870 ExtensionUpdaterTest::TestDetermineUpdates(); |
| 769 } | 871 } |
| 770 | 872 |
| 873 TEST(ExtensionUpdaterTest, TestDetermineUpdatesPending) { |
| 874 ExtensionUpdaterTest::TestDetermineUpdatesPending(); |
| 875 } |
| 876 |
| 771 TEST(ExtensionUpdaterTest, TestMultipleManifestDownloading) { | 877 TEST(ExtensionUpdaterTest, TestMultipleManifestDownloading) { |
| 772 ExtensionUpdaterTest::TestMultipleManifestDownloading(); | 878 ExtensionUpdaterTest::TestMultipleManifestDownloading(); |
| 773 } | 879 } |
| 774 | 880 |
| 775 TEST(ExtensionUpdaterTest, TestSingleExtensionDownloading) { | 881 TEST(ExtensionUpdaterTest, TestSingleExtensionDownloading) { |
| 776 ExtensionUpdaterTest::TestSingleExtensionDownloading(); | 882 ExtensionUpdaterTest::TestSingleExtensionDownloading(false); |
| 883 } |
| 884 |
| 885 TEST(ExtensionUpdaterTest, TestSingleExtensionDownloadingPending) { |
| 886 ExtensionUpdaterTest::TestSingleExtensionDownloading(true); |
| 777 } | 887 } |
| 778 | 888 |
| 779 // This test is disabled on Mac, see http://crbug.com/26035. | 889 // This test is disabled on Mac, see http://crbug.com/26035. |
| 780 TEST(ExtensionUpdaterTest, MAYBE_TestBlacklistDownloading) { | 890 TEST(ExtensionUpdaterTest, MAYBE_TestBlacklistDownloading) { |
| 781 ExtensionUpdaterTest::TestBlacklistDownloading(); | 891 ExtensionUpdaterTest::TestBlacklistDownloading(); |
| 782 } | 892 } |
| 783 | 893 |
| 784 TEST(ExtensionUpdaterTest, TestMultipleExtensionDownloading) { | 894 TEST(ExtensionUpdaterTest, TestMultipleExtensionDownloading) { |
| 785 ExtensionUpdaterTest::TestMultipleExtensionDownloading(); | 895 ExtensionUpdaterTest::TestMultipleExtensionDownloading(); |
| 786 } | 896 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 800 // -prodversionmin (shouldn't update if browser version too old) | 910 // -prodversionmin (shouldn't update if browser version too old) |
| 801 // -manifests & updates arriving out of order / interleaved | 911 // -manifests & updates arriving out of order / interleaved |
| 802 // -Profile::GetDefaultRequestContext() returning null | 912 // -Profile::GetDefaultRequestContext() returning null |
| 803 // (should not crash, but just do check later) | 913 // (should not crash, but just do check later) |
| 804 // -malformed update url (empty, file://, has query, has a # fragment, etc.) | 914 // -malformed update url (empty, file://, has query, has a # fragment, etc.) |
| 805 // -An extension gets uninstalled while updates are in progress (so it doesn't | 915 // -An extension gets uninstalled while updates are in progress (so it doesn't |
| 806 // "come back from the dead") | 916 // "come back from the dead") |
| 807 // -An extension gets manually updated to v3 while we're downloading v2 (ie | 917 // -An extension gets manually updated to v3 while we're downloading v2 (ie |
| 808 // you don't get downgraded accidentally) | 918 // you don't get downgraded accidentally) |
| 809 // -An update manifest mentions multiple updates | 919 // -An update manifest mentions multiple updates |
| OLD | NEW |