Chromium Code Reviews| Index: chrome/browser/extensions/updater/extension_updater_unittest.cc |
| diff --git a/chrome/browser/extensions/updater/extension_updater_unittest.cc b/chrome/browser/extensions/updater/extension_updater_unittest.cc |
| index 874dca1c01751c5a1766b9ced28958ecfb476344..0b96a9b3b1f71f489c54a02d55b36da74b0b0d55 100644 |
| --- a/chrome/browser/extensions/updater/extension_updater_unittest.cc |
| +++ b/chrome/browser/extensions/updater/extension_updater_unittest.cc |
| @@ -33,7 +33,6 @@ |
| #include "chrome/browser/extensions/updater/extension_downloader.h" |
| #include "chrome/browser/extensions/updater/extension_downloader_delegate.h" |
| #include "chrome/browser/extensions/updater/extension_updater.h" |
| -#include "chrome/browser/extensions/updater/manifest_fetch_data.h" |
| #include "chrome/browser/extensions/updater/request_queue_impl.h" |
| #include "chrome/browser/google/google_brand.h" |
| #include "chrome/browser/prefs/pref_service_syncable.h" |
| @@ -50,6 +49,7 @@ |
| #include "extensions/browser/extension_prefs.h" |
| #include "extensions/browser/extension_registry.h" |
| #include "extensions/browser/extension_system.h" |
| +#include "extensions/browser/updater/manifest_fetch_data.h" |
| #include "extensions/common/extension.h" |
| #include "extensions/common/id_util.h" |
| #include "extensions/common/manifest_constants.h" |
| @@ -356,10 +356,15 @@ class MockService : public TestExtensionService { |
| private: |
| scoped_ptr<ExtensionDownloader> CreateExtensionDownloader( |
| ExtensionDownloaderDelegate* delegate) { |
| - return make_scoped_ptr(new ExtensionDownloader( |
| + scoped_ptr<ExtensionDownloader> downloader(new ExtensionDownloader( |
| downloader_delegate_override_ ? downloader_delegate_override_ |
| - : delegate, |
| + : delegate, |
| request_context())); |
| + downloader->EnablePingDataForDomain("google.com"); |
| + downloader->SetManifestQueryParams( |
| + omaha_query_params::OmahaQueryParams::Get( |
| + omaha_query_params::OmahaQueryParams::CRX)); |
| + return downloader.Pass(); |
| } |
| scoped_ptr<ExtensionDownloader> CreateExtensionDownloaderWithIdentity( |
| @@ -700,12 +705,13 @@ class ExtensionUpdaterTest : public testing::Test { |
| // Make sure that an empty update URL data string does not cause a ap= |
| // option to appear in the x= parameter. |
| - ManifestFetchData fetch_data(GURL("http://localhost/foo"), 0); |
| - fetch_data.AddExtension( |
| + scoped_ptr<ManifestFetchData> fetch_data( |
| + CreateManifestFetchData(GURL("http://localhost/foo"))); |
| + fetch_data->AddExtension( |
| id, version, &kNeverPingedData, std::string(), std::string()); |
| std::map<std::string, std::string> params; |
| - VerifyQueryAndExtractParameters(fetch_data.full_url().query(), ¶ms); |
| + VerifyQueryAndExtractParameters(fetch_data->full_url().query(), ¶ms); |
| EXPECT_EQ(id, params["id"]); |
| EXPECT_EQ(version, params["v"]); |
| EXPECT_EQ(0U, params.count("ap")); |
| @@ -717,11 +723,12 @@ class ExtensionUpdaterTest : public testing::Test { |
| // Make sure that an update URL data string causes an appropriate ap= |
| // option to appear in the x= parameter. |
| - ManifestFetchData fetch_data(GURL("http://localhost/foo"), 0); |
| - fetch_data.AddExtension( |
| + scoped_ptr<ManifestFetchData> fetch_data( |
| + CreateManifestFetchData(GURL("http://localhost/foo"))); |
| + fetch_data->AddExtension( |
| id, version, &kNeverPingedData, "bar", std::string()); |
| std::map<std::string, std::string> params; |
| - VerifyQueryAndExtractParameters(fetch_data.full_url().query(), ¶ms); |
| + VerifyQueryAndExtractParameters(fetch_data->full_url().query(), ¶ms); |
| EXPECT_EQ(id, params["id"]); |
| EXPECT_EQ(version, params["v"]); |
| EXPECT_EQ("bar", params["ap"]); |
| @@ -733,11 +740,12 @@ class ExtensionUpdaterTest : public testing::Test { |
| // Make sure that an update URL data string causes an appropriate ap= |
| // option to appear in the x= parameter. |
| - ManifestFetchData fetch_data(GURL("http://localhost/foo"), 0); |
| - fetch_data.AddExtension( |
| + scoped_ptr<ManifestFetchData> fetch_data( |
| + CreateManifestFetchData(GURL("http://localhost/foo"))); |
| + fetch_data->AddExtension( |
| id, version, &kNeverPingedData, "a=1&b=2&c", std::string()); |
| std::map<std::string, std::string> params; |
| - VerifyQueryAndExtractParameters(fetch_data.full_url().query(), ¶ms); |
| + VerifyQueryAndExtractParameters(fetch_data->full_url().query(), ¶ms); |
| EXPECT_EQ(id, params["id"]); |
| EXPECT_EQ(version, params["v"]); |
| EXPECT_EQ("a%3D1%26b%3D2%26c", params["ap"]); |
| @@ -777,11 +785,12 @@ class ExtensionUpdaterTest : public testing::Test { |
| const std::string install_source = "instally"; |
| // Make sure that an installsource= appears in the x= parameter. |
| - ManifestFetchData fetch_data(GURL("http://localhost/foo"), 0); |
| - fetch_data.AddExtension(id, version, &kNeverPingedData, |
| - kEmptyUpdateUrlData, install_source); |
| + scoped_ptr<ManifestFetchData> fetch_data( |
| + CreateManifestFetchData(GURL("http://localhost/foo"))); |
| + fetch_data->AddExtension( |
| + id, version, &kNeverPingedData, kEmptyUpdateUrlData, install_source); |
| std::map<std::string, std::string> params; |
| - VerifyQueryAndExtractParameters(fetch_data.full_url().query(), ¶ms); |
| + VerifyQueryAndExtractParameters(fetch_data->full_url().query(), ¶ms); |
| EXPECT_EQ(id, params["id"]); |
| EXPECT_EQ(version, params["v"]); |
| EXPECT_EQ(install_source, params["installsource"]); |
| @@ -793,10 +802,11 @@ class ExtensionUpdaterTest : public testing::Test { |
| ExtensionDownloader downloader(&delegate, profile.GetRequestContext()); |
| // Check passing an empty list of parse results to DetermineUpdates |
| - ManifestFetchData fetch_data(GURL("http://localhost/foo"), 0); |
| + scoped_ptr<ManifestFetchData> fetch_data( |
| + CreateManifestFetchData(GURL("http://localhost/foo"))); |
| UpdateManifest::Results updates; |
| std::vector<int> updateable; |
| - downloader.DetermineUpdates(fetch_data, updates, &updateable); |
| + downloader.DetermineUpdates(*fetch_data, updates, &updateable); |
| EXPECT_TRUE(updateable.empty()); |
| // Create two updates - expect that DetermineUpdates will return the first |
| @@ -804,10 +814,10 @@ class ExtensionUpdaterTest : public testing::Test { |
| // installed and available at v2.0). |
| const std::string id1 = id_util::GenerateId("1"); |
| const std::string id2 = id_util::GenerateId("2"); |
| - fetch_data.AddExtension( |
| + fetch_data->AddExtension( |
| id1, "1.0.0.0", &kNeverPingedData, kEmptyUpdateUrlData, std::string()); |
| AddParseResult(id1, "1.1", "http://localhost/e1_1.1.crx", &updates); |
| - fetch_data.AddExtension( |
| + fetch_data->AddExtension( |
| id2, "2.0.0.0", &kNeverPingedData, kEmptyUpdateUrlData, std::string()); |
| AddParseResult(id2, "2.0.0.0", "http://localhost/e2_2.0.crx", &updates); |
| @@ -819,7 +829,7 @@ class ExtensionUpdaterTest : public testing::Test { |
| .WillOnce(DoAll(SetArgPointee<1>("2.0.0.0"), |
| Return(true))); |
| - downloader.DetermineUpdates(fetch_data, updates, &updateable); |
| + downloader.DetermineUpdates(*fetch_data, updates, &updateable); |
| EXPECT_EQ(1u, updateable.size()); |
| EXPECT_EQ(0, updateable[0]); |
| } |
| @@ -835,7 +845,8 @@ class ExtensionUpdaterTest : public testing::Test { |
| MockExtensionDownloaderDelegate delegate; |
| ExtensionDownloader downloader(&delegate, profile.GetRequestContext()); |
| - ManifestFetchData fetch_data(GURL("http://localhost/foo"), 0); |
| + scoped_ptr<ManifestFetchData> fetch_data( |
| + CreateManifestFetchData(GURL("http://localhost/foo"))); |
| UpdateManifest::Results updates; |
| std::list<std::string> ids_for_update_check; |
| @@ -845,11 +856,11 @@ class ExtensionUpdaterTest : public testing::Test { |
| std::list<std::string>::const_iterator it; |
| for (it = ids_for_update_check.begin(); |
| it != ids_for_update_check.end(); ++it) { |
| - fetch_data.AddExtension(*it, |
| - "1.0.0.0", |
| - &kNeverPingedData, |
| - kEmptyUpdateUrlData, |
| - std::string()); |
| + fetch_data->AddExtension(*it, |
| + "1.0.0.0", |
| + &kNeverPingedData, |
| + kEmptyUpdateUrlData, |
| + std::string()); |
| AddParseResult(*it, "1.1", "http://localhost/e1_1.1.crx", &updates); |
| } |
| @@ -858,7 +869,7 @@ class ExtensionUpdaterTest : public testing::Test { |
| EXPECT_CALL(delegate, IsExtensionPending(_)).WillRepeatedly(Return(true)); |
| std::vector<int> updateable; |
| - downloader.DetermineUpdates(fetch_data, updates, &updateable); |
| + downloader.DetermineUpdates(*fetch_data, updates, &updateable); |
| // All the apps should be updateable. |
| EXPECT_EQ(3u, updateable.size()); |
| for (std::vector<int>::size_type i = 0; i < updateable.size(); ++i) { |
| @@ -877,10 +888,10 @@ class ExtensionUpdaterTest : public testing::Test { |
| GURL kUpdateUrl("http://localhost/manifest1"); |
| - scoped_ptr<ManifestFetchData> fetch1(new ManifestFetchData(kUpdateUrl, 0)); |
| - scoped_ptr<ManifestFetchData> fetch2(new ManifestFetchData(kUpdateUrl, 0)); |
| - scoped_ptr<ManifestFetchData> fetch3(new ManifestFetchData(kUpdateUrl, 0)); |
| - scoped_ptr<ManifestFetchData> fetch4(new ManifestFetchData(kUpdateUrl, 0)); |
| + scoped_ptr<ManifestFetchData> fetch1(CreateManifestFetchData(kUpdateUrl)); |
| + scoped_ptr<ManifestFetchData> fetch2(CreateManifestFetchData(kUpdateUrl)); |
| + scoped_ptr<ManifestFetchData> fetch3(CreateManifestFetchData(kUpdateUrl)); |
| + scoped_ptr<ManifestFetchData> fetch4(CreateManifestFetchData(kUpdateUrl)); |
| ManifestFetchData::PingData zeroDays(0, 0, true); |
| fetch1->AddExtension( |
| "1111", "1.0", &zeroDays, kEmptyUpdateUrlData, std::string()); |
| @@ -1017,7 +1028,7 @@ class ExtensionUpdaterTest : public testing::Test { |
| GURL kUpdateUrl("http://localhost/manifest1"); |
| - scoped_ptr<ManifestFetchData> fetch(new ManifestFetchData(kUpdateUrl, 0)); |
| + scoped_ptr<ManifestFetchData> fetch(CreateManifestFetchData(kUpdateUrl)); |
| ManifestFetchData::PingData zeroDays(0, 0, true); |
| fetch->AddExtension( |
| "1111", "1.0", &zeroDays, kEmptyUpdateUrlData, std::string()); |
| @@ -1046,7 +1057,7 @@ class ExtensionUpdaterTest : public testing::Test { |
| // For response codes that are not in the 5xx range ExtensionDownloader |
| // should not retry. |
| - fetch.reset(new ManifestFetchData(kUpdateUrl, 0)); |
| + fetch.reset(CreateManifestFetchData(kUpdateUrl)); |
| fetch->AddExtension( |
| "1111", "1.0", &zeroDays, kEmptyUpdateUrlData, std::string()); |
| @@ -1700,17 +1711,18 @@ class ExtensionUpdaterTest : public testing::Test { |
| updater.Start(); |
| updater.EnsureDownloaderCreated(); |
| - ManifestFetchData fetch_data(update_url, 0); |
| + scoped_ptr<ManifestFetchData> fetch_data( |
| + CreateManifestFetchData(update_url)); |
| const Extension* extension = tmp[0].get(); |
| - fetch_data.AddExtension(extension->id(), |
| - extension->VersionString(), |
| - &kNeverPingedData, |
| - kEmptyUpdateUrlData, |
| - std::string()); |
| + fetch_data->AddExtension(extension->id(), |
| + extension->VersionString(), |
| + &kNeverPingedData, |
| + kEmptyUpdateUrlData, |
| + std::string()); |
| UpdateManifest::Results results; |
| results.daystart_elapsed_seconds = 750; |
| - updater.downloader_->HandleManifestResults(fetch_data, &results); |
| + updater.downloader_->HandleManifestResults(*fetch_data, &results); |
| Time last_ping_day = |
| service.extension_prefs()->LastPingDay(extension->id()); |
| EXPECT_FALSE(last_ping_day.is_null()); |
| @@ -1721,6 +1733,16 @@ class ExtensionUpdaterTest : public testing::Test { |
| protected: |
| scoped_ptr<TestExtensionPrefs> prefs_; |
| + ManifestFetchData* CreateManifestFetchData(const GURL& update_url) { |
| + return new ManifestFetchData( |
| + update_url, |
| + 0, |
| + "", |
| + omaha_query_params::OmahaQueryParams::Get( |
|
not at google - send to devlin
2014/08/13 01:30:02
Ok, "omaha_query_params::OmahaQueryParams" looks v
|
| + omaha_query_params::OmahaQueryParams::CRX), |
| + ManifestFetchData::PING); |
| + } |
| + |
| private: |
| content::TestBrowserThreadBundle thread_bundle_; |
| content::InProcessUtilityThreadHelper in_process_utility_thread_helper_; |
| @@ -2003,12 +2025,12 @@ TEST_F(ExtensionUpdaterTest, TestStartUpdateCheckMemory) { |
| MockExtensionDownloaderDelegate delegate; |
| ExtensionDownloader downloader(&delegate, service.request_context()); |
| - StartUpdateCheck(&downloader, new ManifestFetchData(GURL(), 0)); |
| + StartUpdateCheck(&downloader, CreateManifestFetchData(GURL())); |
| // This should delete the newly-created ManifestFetchData. |
| - StartUpdateCheck(&downloader, new ManifestFetchData(GURL(), 0)); |
| + StartUpdateCheck(&downloader, CreateManifestFetchData(GURL())); |
| // This should add into |manifests_pending_|. |
| - StartUpdateCheck(&downloader, new ManifestFetchData(GURL( |
| - GURL("http://www.google.com")), 0)); |
| + StartUpdateCheck(&downloader, |
| + CreateManifestFetchData(GURL("http://www.google.com"))); |
| // The dtor of |downloader| should delete the pending fetchers. |
| } |