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

Side by Side Diff: chrome/browser/extensions/updater/extension_updater_unittest.cc

Issue 10581012: Move test_url_fetcher_factory.* from content/ to net/url_request (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove export annotations Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
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/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 24 matching lines...) Expand all
35 #include "chrome/common/extensions/extension.h" 35 #include "chrome/common/extensions/extension.h"
36 #include "chrome/common/extensions/extension_manifest_constants.h" 36 #include "chrome/common/extensions/extension_manifest_constants.h"
37 #include "chrome/common/pref_names.h" 37 #include "chrome/common/pref_names.h"
38 #include "chrome/test/base/testing_profile.h" 38 #include "chrome/test/base/testing_profile.h"
39 #include "content/public/browser/notification_details.h" 39 #include "content/public/browser/notification_details.h"
40 #include "content/public/browser/notification_observer.h" 40 #include "content/public/browser/notification_observer.h"
41 #include "content/public/browser/notification_registrar.h" 41 #include "content/public/browser/notification_registrar.h"
42 #include "content/public/browser/notification_service.h" 42 #include "content/public/browser/notification_service.h"
43 #include "content/public/browser/notification_source.h" 43 #include "content/public/browser/notification_source.h"
44 #include "content/public/test/test_browser_thread.h" 44 #include "content/public/test/test_browser_thread.h"
45 #include "content/public/test/test_url_fetcher_factory.h"
46 #include "libxml/globals.h" 45 #include "libxml/globals.h"
47 #include "net/base/escape.h" 46 #include "net/base/escape.h"
48 #include "net/base/load_flags.h" 47 #include "net/base/load_flags.h"
48 #include "net/url_request/test_url_fetcher_factory.h"
49 #include "net/url_request/url_request_status.h" 49 #include "net/url_request/url_request_status.h"
50 #include "testing/gmock/include/gmock/gmock.h" 50 #include "testing/gmock/include/gmock/gmock.h"
51 #include "testing/gtest/include/gtest/gtest.h" 51 #include "testing/gtest/include/gtest/gtest.h"
52 52
53 using base::Time; 53 using base::Time;
54 using base::TimeDelta; 54 using base::TimeDelta;
55 using content::BrowserThread; 55 using content::BrowserThread;
56 using testing::DoAll; 56 using testing::DoAll;
57 using testing::Mock; 57 using testing::Mock;
58 using testing::Return; 58 using testing::Return;
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 if (pending) { 474 if (pending) {
475 SetupPendingExtensionManagerForTest(1, GURL(update_url), 475 SetupPendingExtensionManagerForTest(1, GURL(update_url),
476 pending_extension_manager); 476 pending_extension_manager);
477 } else { 477 } else {
478 service.CreateTestExtensions(1, 1, &extensions, &update_url, 478 service.CreateTestExtensions(1, 1, &extensions, &update_url,
479 Extension::INTERNAL); 479 Extension::INTERNAL);
480 service.set_extensions(extensions); 480 service.set_extensions(extensions);
481 } 481 }
482 482
483 // Set up and start the updater. 483 // Set up and start the updater.
484 TestURLFetcherFactory factory; 484 net::TestURLFetcherFactory factory;
485 ExtensionUpdater updater( 485 ExtensionUpdater updater(
486 &service, service.extension_prefs(), service.pref_service(), 486 &service, service.extension_prefs(), service.pref_service(),
487 service.profile(), 60*60*24); 487 service.profile(), 60*60*24);
488 updater.Start(); 488 updater.Start();
489 // Disable blacklist checks (tested elsewhere) so that we only see the 489 // Disable blacklist checks (tested elsewhere) so that we only see the
490 // update HTTP request. 490 // update HTTP request.
491 updater.set_blacklist_checks_enabled(false); 491 updater.set_blacklist_checks_enabled(false);
492 492
493 // Tell the update that it's time to do update checks. 493 // Tell the update that it's time to do update checks.
494 SimulateTimerFired(&updater); 494 SimulateTimerFired(&updater);
495 495
496 // Get the url our mock fetcher was asked to fetch. 496 // Get the url our mock fetcher was asked to fetch.
497 TestURLFetcher* fetcher = 497 net::TestURLFetcher* fetcher =
498 factory.GetFetcherByID(ExtensionDownloader::kManifestFetcherId); 498 factory.GetFetcherByID(ExtensionDownloader::kManifestFetcherId);
499 const GURL& url = fetcher->GetOriginalURL(); 499 const GURL& url = fetcher->GetOriginalURL();
500 EXPECT_FALSE(url.is_empty()); 500 EXPECT_FALSE(url.is_empty());
501 EXPECT_TRUE(url.is_valid()); 501 EXPECT_TRUE(url.is_valid());
502 EXPECT_TRUE(url.SchemeIs("http")); 502 EXPECT_TRUE(url.SchemeIs("http"));
503 EXPECT_EQ("foo.com", url.host()); 503 EXPECT_EQ("foo.com", url.host());
504 EXPECT_EQ("/bar", url.path()); 504 EXPECT_EQ("/bar", url.path());
505 505
506 // Validate the extension request parameters in the query. It should 506 // Validate the extension request parameters in the query. It should
507 // look something like "?x=id%3D<id>%26v%3D<version>%26uc". 507 // look something like "?x=id%3D<id>%26v%3D<version>%26uc".
(...skipping 13 matching lines...) Expand all
521 EXPECT_EQ(extensions[0]->id(), params["id"]); 521 EXPECT_EQ(extensions[0]->id(), params["id"]);
522 EXPECT_EQ(extensions[0]->VersionString(), params["v"]); 522 EXPECT_EQ(extensions[0]->VersionString(), params["v"]);
523 } 523 }
524 EXPECT_EQ("", params["uc"]); 524 EXPECT_EQ("", params["uc"]);
525 } 525 }
526 526
527 void TestBlacklistUpdateCheckRequests() { 527 void TestBlacklistUpdateCheckRequests() {
528 // Setup and start the updater. 528 // Setup and start the updater.
529 ServiceForManifestTests service; 529 ServiceForManifestTests service;
530 530
531 TestURLFetcherFactory factory; 531 net::TestURLFetcherFactory factory;
532 ExtensionUpdater updater( 532 ExtensionUpdater updater(
533 &service, service.extension_prefs(), service.pref_service(), 533 &service, service.extension_prefs(), service.pref_service(),
534 service.profile(), 60*60*24); 534 service.profile(), 60*60*24);
535 updater.Start(); 535 updater.Start();
536 536
537 // Tell the updater that it's time to do update checks. 537 // Tell the updater that it's time to do update checks.
538 SimulateTimerFired(&updater); 538 SimulateTimerFired(&updater);
539 539
540 // Get the url our mock fetcher was asked to fetch. 540 // Get the url our mock fetcher was asked to fetch.
541 TestURLFetcher* fetcher = 541 net::TestURLFetcher* fetcher =
542 factory.GetFetcherByID(ExtensionDownloader::kManifestFetcherId); 542 factory.GetFetcherByID(ExtensionDownloader::kManifestFetcherId);
543 ASSERT_FALSE(fetcher == NULL); 543 ASSERT_FALSE(fetcher == NULL);
544 const GURL& url = fetcher->GetOriginalURL(); 544 const GURL& url = fetcher->GetOriginalURL();
545 545
546 EXPECT_FALSE(url.is_empty()); 546 EXPECT_FALSE(url.is_empty());
547 EXPECT_TRUE(url.is_valid()); 547 EXPECT_TRUE(url.is_valid());
548 EXPECT_TRUE(url.SchemeIs("https")); 548 EXPECT_TRUE(url.SchemeIs("https"));
549 EXPECT_EQ("clients2.google.com", url.host()); 549 EXPECT_EQ("clients2.google.com", url.host());
550 EXPECT_EQ("/service/update2/crx", url.path()); 550 EXPECT_EQ("/service/update2/crx", url.path());
551 551
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 // Make sure that an update URL data string causes an appropriate ap= 599 // Make sure that an update URL data string causes an appropriate ap=
600 // option to appear in the x= parameter. 600 // option to appear in the x= parameter.
601 ManifestFetchData fetch_data(GURL("http://localhost/foo")); 601 ManifestFetchData fetch_data(GURL("http://localhost/foo"));
602 fetch_data.AddExtension(id, version, &kNeverPingedData, "a=1&b=2&c", ""); 602 fetch_data.AddExtension(id, version, &kNeverPingedData, "a=1&b=2&c", "");
603 EXPECT_EQ("http://localhost/foo\?x=id%3Daaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 603 EXPECT_EQ("http://localhost/foo\?x=id%3Daaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
604 "%26v%3D1.0%26uc%26ap%3Da%253D1%2526b%253D2%2526c", 604 "%26v%3D1.0%26uc%26ap%3Da%253D1%2526b%253D2%2526c",
605 fetch_data.full_url().spec()); 605 fetch_data.full_url().spec());
606 } 606 }
607 607
608 void TestUpdateUrlDataFromGallery(const std::string& gallery_url) { 608 void TestUpdateUrlDataFromGallery(const std::string& gallery_url) {
609 TestURLFetcherFactory factory; 609 net::TestURLFetcherFactory factory;
610 610
611 MockService service; 611 MockService service;
612 MockExtensionDownloaderDelegate delegate; 612 MockExtensionDownloaderDelegate delegate;
613 ExtensionDownloader downloader(&delegate, service.request_context()); 613 ExtensionDownloader downloader(&delegate, service.request_context());
614 ExtensionList extensions; 614 ExtensionList extensions;
615 std::string url(gallery_url); 615 std::string url(gallery_url);
616 616
617 service.CreateTestExtensions(1, 1, &extensions, &url, Extension::INTERNAL); 617 service.CreateTestExtensions(1, 1, &extensions, &url, Extension::INTERNAL);
618 618
619 const std::string& id = extensions[0]->id(); 619 const std::string& id = extensions[0]->id();
620 EXPECT_CALL(delegate, GetPingDataForExtension(id, _)); 620 EXPECT_CALL(delegate, GetPingDataForExtension(id, _));
621 621
622 downloader.AddExtension(*extensions[0]); 622 downloader.AddExtension(*extensions[0]);
623 downloader.StartAllPending(); 623 downloader.StartAllPending();
624 TestURLFetcher* fetcher = 624 net::TestURLFetcher* fetcher =
625 factory.GetFetcherByID(ExtensionDownloader::kManifestFetcherId); 625 factory.GetFetcherByID(ExtensionDownloader::kManifestFetcherId);
626 ASSERT_TRUE(fetcher); 626 ASSERT_TRUE(fetcher);
627 // Make sure that extensions that update from the gallery ignore any 627 // Make sure that extensions that update from the gallery ignore any
628 // update URL data. 628 // update URL data.
629 const std::string& update_url = fetcher->GetOriginalURL().spec(); 629 const std::string& update_url = fetcher->GetOriginalURL().spec();
630 std::string::size_type x = update_url.find("x="); 630 std::string::size_type x = update_url.find("x=");
631 EXPECT_NE(std::string::npos, x); 631 EXPECT_NE(std::string::npos, x);
632 std::string::size_type ap = update_url.find("ap%3D", x); 632 std::string::size_type ap = update_url.find("ap%3D", x);
633 EXPECT_EQ(std::string::npos, ap); 633 EXPECT_EQ(std::string::npos, ap);
634 } 634 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 std::vector<int> updateable; 721 std::vector<int> updateable;
722 downloader.DetermineUpdates(fetch_data, updates, &updateable); 722 downloader.DetermineUpdates(fetch_data, updates, &updateable);
723 // All the apps should be updateable. 723 // All the apps should be updateable.
724 EXPECT_EQ(3u, updateable.size()); 724 EXPECT_EQ(3u, updateable.size());
725 for (std::vector<int>::size_type i = 0; i < updateable.size(); ++i) { 725 for (std::vector<int>::size_type i = 0; i < updateable.size(); ++i) {
726 EXPECT_EQ(static_cast<int>(i), updateable[i]); 726 EXPECT_EQ(static_cast<int>(i), updateable[i]);
727 } 727 }
728 } 728 }
729 729
730 void TestMultipleManifestDownloading() { 730 void TestMultipleManifestDownloading() {
731 TestURLFetcherFactory factory; 731 net::TestURLFetcherFactory factory;
732 TestURLFetcher* fetcher = NULL; 732 net::TestURLFetcher* fetcher = NULL;
733 NotificationsObserver observer; 733 NotificationsObserver observer;
734 MockService service; 734 MockService service;
735 MockExtensionDownloaderDelegate delegate; 735 MockExtensionDownloaderDelegate delegate;
736 ExtensionDownloader downloader(&delegate, service.request_context()); 736 ExtensionDownloader downloader(&delegate, service.request_context());
737 737
738 GURL kUpdateUrl("http://localhost/manifest1"); 738 GURL kUpdateUrl("http://localhost/manifest1");
739 739
740 ManifestFetchData* fetch1 = new ManifestFetchData(kUpdateUrl); 740 ManifestFetchData* fetch1 = new ManifestFetchData(kUpdateUrl);
741 ManifestFetchData* fetch2 = new ManifestFetchData(kUpdateUrl); 741 ManifestFetchData* fetch2 = new ManifestFetchData(kUpdateUrl);
742 ManifestFetchData* fetch3 = new ManifestFetchData(kUpdateUrl); 742 ManifestFetchData* fetch3 = new ManifestFetchData(kUpdateUrl);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 fetcher->delegate()->OnURLFetchComplete(fetcher); 834 fetcher->delegate()->OnURLFetchComplete(fetcher);
835 RunAllPending(); 835 RunAllPending();
836 Mock::VerifyAndClearExpectations(&delegate); 836 Mock::VerifyAndClearExpectations(&delegate);
837 837
838 // Verify that the downloader decided to update this extension. 838 // Verify that the downloader decided to update this extension.
839 EXPECT_EQ(1u, observer.UpdatedCount()); 839 EXPECT_EQ(1u, observer.UpdatedCount());
840 EXPECT_TRUE(observer.Updated("4444")); 840 EXPECT_TRUE(observer.Updated("4444"));
841 } 841 }
842 842
843 void TestSingleExtensionDownloading(bool pending) { 843 void TestSingleExtensionDownloading(bool pending) {
844 TestURLFetcherFactory factory; 844 net::TestURLFetcherFactory factory;
845 TestURLFetcher* fetcher = NULL; 845 net::TestURLFetcher* fetcher = NULL;
846 scoped_ptr<ServiceForDownloadTests> service(new ServiceForDownloadTests); 846 scoped_ptr<ServiceForDownloadTests> service(new ServiceForDownloadTests);
847 ExtensionUpdater updater(service.get(), service->extension_prefs(), 847 ExtensionUpdater updater(service.get(), service->extension_prefs(),
848 service->pref_service(), 848 service->pref_service(),
849 service->profile(), 849 service->profile(),
850 kUpdateFrequencySecs); 850 kUpdateFrequencySecs);
851 updater.Start(); 851 updater.Start();
852 ResetDownloader( 852 ResetDownloader(
853 &updater, 853 &updater,
854 new ExtensionDownloader(&updater, service->request_context())); 854 new ExtensionDownloader(&updater, service->request_context()));
855 855
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 // Expect that ExtensionUpdater asked the mock extensions service to install 891 // Expect that ExtensionUpdater asked the mock extensions service to install
892 // a file with the test data for the right id. 892 // a file with the test data for the right id.
893 EXPECT_EQ(id, service->extension_id()); 893 EXPECT_EQ(id, service->extension_id());
894 FilePath tmpfile_path = service->install_path(); 894 FilePath tmpfile_path = service->install_path();
895 EXPECT_FALSE(tmpfile_path.empty()); 895 EXPECT_FALSE(tmpfile_path.empty());
896 EXPECT_EQ(test_url, service->download_url()); 896 EXPECT_EQ(test_url, service->download_url());
897 EXPECT_EQ(extension_file_path, tmpfile_path); 897 EXPECT_EQ(extension_file_path, tmpfile_path);
898 } 898 }
899 899
900 void TestBlacklistDownloading() { 900 void TestBlacklistDownloading() {
901 TestURLFetcherFactory factory; 901 net::TestURLFetcherFactory factory;
902 TestURLFetcher* fetcher = NULL; 902 net::TestURLFetcher* fetcher = NULL;
903 ServiceForBlacklistTests service; 903 ServiceForBlacklistTests service;
904 ExtensionUpdater updater( 904 ExtensionUpdater updater(
905 &service, service.extension_prefs(), service.pref_service(), 905 &service, service.extension_prefs(), service.pref_service(),
906 service.profile(), kUpdateFrequencySecs); 906 service.profile(), kUpdateFrequencySecs);
907 updater.Start(); 907 updater.Start();
908 ResetDownloader( 908 ResetDownloader(
909 &updater, 909 &updater,
910 new ExtensionDownloader(&updater, service.request_context())); 910 new ExtensionDownloader(&updater, service.request_context()));
911 GURL test_url("http://localhost/extension.crx"); 911 GURL test_url("http://localhost/extension.crx");
912 912
(...skipping 26 matching lines...) Expand all
939 939
940 EXPECT_EQ(version, service.pref_service()-> 940 EXPECT_EQ(version, service.pref_service()->
941 GetString(prefs::kExtensionBlacklistUpdateVersion)); 941 GetString(prefs::kExtensionBlacklistUpdateVersion));
942 } 942 }
943 943
944 // Two extensions are updated. If |updates_start_running| is true, the 944 // Two extensions are updated. If |updates_start_running| is true, the
945 // mock extensions service has UpdateExtension(...) return true, and 945 // mock extensions service has UpdateExtension(...) return true, and
946 // the test is responsible for creating fake CrxInstallers. Otherwise, 946 // the test is responsible for creating fake CrxInstallers. Otherwise,
947 // UpdateExtension() returns false, signaling install failures. 947 // UpdateExtension() returns false, signaling install failures.
948 void TestMultipleExtensionDownloading(bool updates_start_running) { 948 void TestMultipleExtensionDownloading(bool updates_start_running) {
949 TestURLFetcherFactory factory; 949 net::TestURLFetcherFactory factory;
950 TestURLFetcher* fetcher = NULL; 950 net::TestURLFetcher* fetcher = NULL;
951 ServiceForDownloadTests service; 951 ServiceForDownloadTests service;
952 ExtensionUpdater updater( 952 ExtensionUpdater updater(
953 &service, service.extension_prefs(), service.pref_service(), 953 &service, service.extension_prefs(), service.pref_service(),
954 service.profile(), kUpdateFrequencySecs); 954 service.profile(), kUpdateFrequencySecs);
955 updater.Start(); 955 updater.Start();
956 ResetDownloader( 956 ResetDownloader(
957 &updater, 957 &updater,
958 new ExtensionDownloader(&updater, service.request_context())); 958 new ExtensionDownloader(&updater, service.request_context()));
959 959
960 EXPECT_FALSE(updater.crx_install_is_running_); 960 EXPECT_FALSE(updater.crx_install_is_running_);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 // Test requests to both a Google server and a non-google server. This allows 1106 // Test requests to both a Google server and a non-google server. This allows
1107 // us to test various combinations of installed (ie roll call) and active 1107 // us to test various combinations of installed (ie roll call) and active
1108 // (ie app launch) ping scenarios. The invariant is that each type of ping 1108 // (ie app launch) ping scenarios. The invariant is that each type of ping
1109 // value should be present at most once per day, and can be calculated based 1109 // value should be present at most once per day, and can be calculated based
1110 // on the delta between now and the last ping time (or in the case of active 1110 // on the delta between now and the last ping time (or in the case of active
1111 // pings, that delta plus whether the app has been active). 1111 // pings, that delta plus whether the app has been active).
1112 void TestGalleryRequests(int rollcall_ping_days, 1112 void TestGalleryRequests(int rollcall_ping_days,
1113 int active_ping_days, 1113 int active_ping_days,
1114 bool active_bit, 1114 bool active_bit,
1115 bool expect_brand_code) { 1115 bool expect_brand_code) {
1116 TestURLFetcherFactory factory; 1116 net::TestURLFetcherFactory factory;
1117 1117
1118 // Set up 2 mock extensions, one with a google.com update url and one 1118 // Set up 2 mock extensions, one with a google.com update url and one
1119 // without. 1119 // without.
1120 ServiceForManifestTests service; 1120 ServiceForManifestTests service;
1121 ExtensionList tmp; 1121 ExtensionList tmp;
1122 GURL url1("http://clients2.google.com/service/update2/crx"); 1122 GURL url1("http://clients2.google.com/service/update2/crx");
1123 GURL url2("http://www.somewebsite.com"); 1123 GURL url2("http://www.somewebsite.com");
1124 service.CreateTestExtensions(1, 1, &tmp, &url1.possibly_invalid_spec(), 1124 service.CreateTestExtensions(1, 1, &tmp, &url1.possibly_invalid_spec(),
1125 Extension::INTERNAL); 1125 Extension::INTERNAL);
1126 service.CreateTestExtensions(2, 1, &tmp, &url2.possibly_invalid_spec(), 1126 service.CreateTestExtensions(2, 1, &tmp, &url2.possibly_invalid_spec(),
(...skipping 28 matching lines...) Expand all
1155 ExtensionUpdater updater( 1155 ExtensionUpdater updater(
1156 &service, service.extension_prefs(), service.pref_service(), 1156 &service, service.extension_prefs(), service.pref_service(),
1157 service.profile(), kUpdateFrequencySecs); 1157 service.profile(), kUpdateFrequencySecs);
1158 updater.set_blacklist_checks_enabled(false); 1158 updater.set_blacklist_checks_enabled(false);
1159 updater.Start(); 1159 updater.Start();
1160 updater.CheckNow(); 1160 updater.CheckNow();
1161 1161
1162 // Make the updater do manifest fetching, and note the urls it tries to 1162 // Make the updater do manifest fetching, and note the urls it tries to
1163 // fetch. 1163 // fetch.
1164 std::vector<GURL> fetched_urls; 1164 std::vector<GURL> fetched_urls;
1165 TestURLFetcher* fetcher = 1165 net::TestURLFetcher* fetcher =
1166 factory.GetFetcherByID(ExtensionDownloader::kManifestFetcherId); 1166 factory.GetFetcherByID(ExtensionDownloader::kManifestFetcherId);
1167 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); 1167 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL);
1168 fetched_urls.push_back(fetcher->GetOriginalURL()); 1168 fetched_urls.push_back(fetcher->GetOriginalURL());
1169 1169
1170 fetcher->set_url(fetched_urls[0]); 1170 fetcher->set_url(fetched_urls[0]);
1171 fetcher->set_status(net::URLRequestStatus()); 1171 fetcher->set_status(net::URLRequestStatus());
1172 fetcher->set_response_code(500); 1172 fetcher->set_response_code(500);
1173 fetcher->SetResponseString(""); 1173 fetcher->SetResponseString("");
1174 fetcher->delegate()->OnURLFetchComplete(fetcher); 1174 fetcher->delegate()->OnURLFetchComplete(fetcher);
1175 1175
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 1340
1341 TEST_F(ExtensionUpdaterTest, TestGalleryRequestsWithNonOrganicBrand) { 1341 TEST_F(ExtensionUpdaterTest, TestGalleryRequestsWithNonOrganicBrand) {
1342 TestGalleryRequestsWithBrand(false); 1342 TestGalleryRequestsWithBrand(false);
1343 } 1343 }
1344 1344
1345 TEST_F(ExtensionUpdaterTest, TestHandleManifestResults) { 1345 TEST_F(ExtensionUpdaterTest, TestHandleManifestResults) {
1346 TestHandleManifestResults(); 1346 TestHandleManifestResults();
1347 } 1347 }
1348 1348
1349 TEST_F(ExtensionUpdaterTest, TestNonAutoUpdateableLocations) { 1349 TEST_F(ExtensionUpdaterTest, TestNonAutoUpdateableLocations) {
1350 TestURLFetcherFactory factory; 1350 net::TestURLFetcherFactory factory;
1351 ServiceForManifestTests service; 1351 ServiceForManifestTests service;
1352 ExtensionUpdater updater(&service, service.extension_prefs(), 1352 ExtensionUpdater updater(&service, service.extension_prefs(),
1353 service.pref_service(), service.profile(), 1353 service.pref_service(), service.profile(),
1354 kUpdateFrequencySecs); 1354 kUpdateFrequencySecs);
1355 MockExtensionDownloaderDelegate delegate; 1355 MockExtensionDownloaderDelegate delegate;
1356 // Set the downloader directly, so that all its events end up in the mock 1356 // Set the downloader directly, so that all its events end up in the mock
1357 // |delegate|. 1357 // |delegate|.
1358 ExtensionDownloader* downloader = 1358 ExtensionDownloader* downloader =
1359 new ExtensionDownloader(&delegate, service.request_context()); 1359 new ExtensionDownloader(&delegate, service.request_context());
1360 ResetDownloader(&updater, downloader); 1360 ResetDownloader(&updater, downloader);
(...skipping 10 matching lines...) Expand all
1371 EXPECT_CALL(delegate, GetUpdateUrlData(updateable_id)).WillOnce(Return("")); 1371 EXPECT_CALL(delegate, GetUpdateUrlData(updateable_id)).WillOnce(Return(""));
1372 EXPECT_CALL(delegate, GetPingDataForExtension(updateable_id, _)); 1372 EXPECT_CALL(delegate, GetPingDataForExtension(updateable_id, _));
1373 1373
1374 service.set_extensions(extensions); 1374 service.set_extensions(extensions);
1375 updater.set_blacklist_checks_enabled(false); 1375 updater.set_blacklist_checks_enabled(false);
1376 updater.Start(); 1376 updater.Start();
1377 updater.CheckNow(); 1377 updater.CheckNow();
1378 } 1378 }
1379 1379
1380 TEST_F(ExtensionUpdaterTest, TestUpdatingDisabledExtensions) { 1380 TEST_F(ExtensionUpdaterTest, TestUpdatingDisabledExtensions) {
1381 TestURLFetcherFactory factory; 1381 net::TestURLFetcherFactory factory;
1382 ServiceForManifestTests service; 1382 ServiceForManifestTests service;
1383 ExtensionUpdater updater(&service, service.extension_prefs(), 1383 ExtensionUpdater updater(&service, service.extension_prefs(),
1384 service.pref_service(), service.profile(), 1384 service.pref_service(), service.profile(),
1385 kUpdateFrequencySecs); 1385 kUpdateFrequencySecs);
1386 MockExtensionDownloaderDelegate delegate; 1386 MockExtensionDownloaderDelegate delegate;
1387 // Set the downloader directly, so that all its events end up in the mock 1387 // Set the downloader directly, so that all its events end up in the mock
1388 // |delegate|. 1388 // |delegate|.
1389 ExtensionDownloader* downloader = 1389 ExtensionDownloader* downloader =
1390 new ExtensionDownloader(&delegate, service.request_context()); 1390 new ExtensionDownloader(&delegate, service.request_context());
1391 ResetDownloader(&updater, downloader); 1391 ResetDownloader(&updater, downloader);
(...skipping 17 matching lines...) Expand all
1409 EXPECT_CALL(delegate, GetPingDataForExtension(disabled_id, _)); 1409 EXPECT_CALL(delegate, GetPingDataForExtension(disabled_id, _));
1410 1410
1411 service.set_extensions(enabled_extensions); 1411 service.set_extensions(enabled_extensions);
1412 service.set_disabled_extensions(disabled_extensions); 1412 service.set_disabled_extensions(disabled_extensions);
1413 updater.set_blacklist_checks_enabled(false); 1413 updater.set_blacklist_checks_enabled(false);
1414 updater.Start(); 1414 updater.Start();
1415 updater.CheckNow(); 1415 updater.CheckNow();
1416 } 1416 }
1417 1417
1418 TEST_F(ExtensionUpdaterTest, TestManifestFetchesBuilderAddExtension) { 1418 TEST_F(ExtensionUpdaterTest, TestManifestFetchesBuilderAddExtension) {
1419 TestURLFetcherFactory factory; 1419 net::TestURLFetcherFactory factory;
1420 MockService service; 1420 MockService service;
1421 MockExtensionDownloaderDelegate delegate; 1421 MockExtensionDownloaderDelegate delegate;
1422 scoped_ptr<ExtensionDownloader> downloader( 1422 scoped_ptr<ExtensionDownloader> downloader(
1423 new ExtensionDownloader(&delegate, service.request_context())); 1423 new ExtensionDownloader(&delegate, service.request_context()));
1424 EXPECT_EQ(0u, ManifestFetchersCount(downloader.get())); 1424 EXPECT_EQ(0u, ManifestFetchersCount(downloader.get()));
1425 1425
1426 // First, verify that adding valid extensions does invoke the callbacks on 1426 // First, verify that adding valid extensions does invoke the callbacks on
1427 // the delegate. 1427 // the delegate.
1428 std::string id = GenerateId("foo"); 1428 std::string id = GenerateId("foo");
1429 EXPECT_CALL(delegate, GetPingDataForExtension(id, _)).WillOnce(Return(false)); 1429 EXPECT_CALL(delegate, GetPingDataForExtension(id, _)).WillOnce(Return(false));
(...skipping 24 matching lines...) Expand all
1454 EXPECT_EQ(0u, ManifestFetchersCount(downloader.get())); 1454 EXPECT_EQ(0u, ManifestFetchersCount(downloader.get()));
1455 1455
1456 // Extensions with empty update URLs should have a default one 1456 // Extensions with empty update URLs should have a default one
1457 // filled in. 1457 // filled in.
1458 id = GenerateId("foo3"); 1458 id = GenerateId("foo3");
1459 EXPECT_CALL(delegate, GetPingDataForExtension(id, _)).WillOnce(Return(false)); 1459 EXPECT_CALL(delegate, GetPingDataForExtension(id, _)).WillOnce(Return(false));
1460 EXPECT_TRUE(downloader->AddPendingExtension(id, GURL())); 1460 EXPECT_TRUE(downloader->AddPendingExtension(id, GURL()));
1461 downloader->StartAllPending(); 1461 downloader->StartAllPending();
1462 EXPECT_EQ(1u, ManifestFetchersCount(downloader.get())); 1462 EXPECT_EQ(1u, ManifestFetchersCount(downloader.get()));
1463 1463
1464 TestURLFetcher* fetcher = 1464 net::TestURLFetcher* fetcher =
1465 factory.GetFetcherByID(ExtensionDownloader::kManifestFetcherId); 1465 factory.GetFetcherByID(ExtensionDownloader::kManifestFetcherId);
1466 ASSERT_TRUE(fetcher); 1466 ASSERT_TRUE(fetcher);
1467 EXPECT_FALSE(fetcher->GetOriginalURL().is_empty()); 1467 EXPECT_FALSE(fetcher->GetOriginalURL().is_empty());
1468 } 1468 }
1469 1469
1470 TEST_F(ExtensionUpdaterTest, TestStartUpdateCheckMemory) { 1470 TEST_F(ExtensionUpdaterTest, TestStartUpdateCheckMemory) {
1471 TestURLFetcherFactory factory; 1471 net::TestURLFetcherFactory factory;
1472 MockService service; 1472 MockService service;
1473 MockExtensionDownloaderDelegate delegate; 1473 MockExtensionDownloaderDelegate delegate;
1474 ExtensionDownloader downloader(&delegate, service.request_context()); 1474 ExtensionDownloader downloader(&delegate, service.request_context());
1475 1475
1476 StartUpdateCheck(&downloader, new ManifestFetchData(GURL())); 1476 StartUpdateCheck(&downloader, new ManifestFetchData(GURL()));
1477 // This should delete the newly-created ManifestFetchData. 1477 // This should delete the newly-created ManifestFetchData.
1478 StartUpdateCheck(&downloader, new ManifestFetchData(GURL())); 1478 StartUpdateCheck(&downloader, new ManifestFetchData(GURL()));
1479 // This should add into |manifests_pending_|. 1479 // This should add into |manifests_pending_|.
1480 StartUpdateCheck(&downloader, new ManifestFetchData(GURL( 1480 StartUpdateCheck(&downloader, new ManifestFetchData(GURL(
1481 GURL("http://www.google.com")))); 1481 GURL("http://www.google.com"))));
1482 // The dtor of |downloader| should delete the pending fetchers. 1482 // The dtor of |downloader| should delete the pending fetchers.
1483 } 1483 }
1484 1484
1485 TEST_F(ExtensionUpdaterTest, TestCheckSoon) { 1485 TEST_F(ExtensionUpdaterTest, TestCheckSoon) {
1486 ServiceForManifestTests service; 1486 ServiceForManifestTests service;
1487 TestURLFetcherFactory factory; 1487 net::TestURLFetcherFactory factory;
1488 ExtensionUpdater updater( 1488 ExtensionUpdater updater(
1489 &service, service.extension_prefs(), service.pref_service(), 1489 &service, service.extension_prefs(), service.pref_service(),
1490 service.profile(), kUpdateFrequencySecs); 1490 service.profile(), kUpdateFrequencySecs);
1491 EXPECT_FALSE(updater.WillCheckSoon()); 1491 EXPECT_FALSE(updater.WillCheckSoon());
1492 updater.Start(); 1492 updater.Start();
1493 EXPECT_FALSE(updater.WillCheckSoon()); 1493 EXPECT_FALSE(updater.WillCheckSoon());
1494 updater.CheckSoon(); 1494 updater.CheckSoon();
1495 EXPECT_TRUE(updater.WillCheckSoon()); 1495 EXPECT_TRUE(updater.WillCheckSoon());
1496 updater.CheckSoon(); 1496 updater.CheckSoon();
1497 EXPECT_TRUE(updater.WillCheckSoon()); 1497 EXPECT_TRUE(updater.WillCheckSoon());
1498 RunAllPending(); 1498 RunAllPending();
1499 EXPECT_FALSE(updater.WillCheckSoon()); 1499 EXPECT_FALSE(updater.WillCheckSoon());
1500 updater.CheckSoon(); 1500 updater.CheckSoon();
1501 EXPECT_TRUE(updater.WillCheckSoon()); 1501 EXPECT_TRUE(updater.WillCheckSoon());
1502 updater.Stop(); 1502 updater.Stop();
1503 EXPECT_FALSE(updater.WillCheckSoon()); 1503 EXPECT_FALSE(updater.WillCheckSoon());
1504 } 1504 }
1505 1505
1506 // TODO(asargent) - (http://crbug.com/12780) add tests for: 1506 // TODO(asargent) - (http://crbug.com/12780) add tests for:
1507 // -prodversionmin (shouldn't update if browser version too old) 1507 // -prodversionmin (shouldn't update if browser version too old)
1508 // -manifests & updates arriving out of order / interleaved 1508 // -manifests & updates arriving out of order / interleaved
1509 // -malformed update url (empty, file://, has query, has a # fragment, etc.) 1509 // -malformed update url (empty, file://, has query, has a # fragment, etc.)
1510 // -An extension gets uninstalled while updates are in progress (so it doesn't 1510 // -An extension gets uninstalled while updates are in progress (so it doesn't
1511 // "come back from the dead") 1511 // "come back from the dead")
1512 // -An extension gets manually updated to v3 while we're downloading v2 (ie 1512 // -An extension gets manually updated to v3 while we're downloading v2 (ie
1513 // you don't get downgraded accidentally) 1513 // you don't get downgraded accidentally)
1514 // -An update manifest mentions multiple updates 1514 // -An update manifest mentions multiple updates
1515 1515
1516 } // namespace extensions 1516 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_notify_channel_setup_unittest.cc ('k') | chrome/browser/google/google_url_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698