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

Unified Diff: chrome/browser/extensions/updater/extension_updater_unittest.cc

Issue 476073002: Revert of Factor Chrome details out of update manifest fetching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
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 f63cea5c7db906e48eb160e11285ed6a35583b57..874dca1c01751c5a1766b9ced28958ecfb476344 100644
--- a/chrome/browser/extensions/updater/extension_updater_unittest.cc
+++ b/chrome/browser/extensions/updater/extension_updater_unittest.cc
@@ -30,10 +30,10 @@
#include "chrome/browser/extensions/test_extension_prefs.h"
#include "chrome/browser/extensions/test_extension_service.h"
#include "chrome/browser/extensions/test_extension_system.h"
-#include "chrome/browser/extensions/updater/chrome_extension_downloader_factory.h"
#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,7 +50,6 @@
#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"
@@ -76,7 +75,6 @@
using base::Time;
using base::TimeDelta;
using content::BrowserThread;
-using omaha_query_params::OmahaQueryParams;
using testing::DoAll;
using testing::Invoke;
using testing::InvokeWithoutArgs;
@@ -358,10 +356,10 @@
private:
scoped_ptr<ExtensionDownloader> CreateExtensionDownloader(
ExtensionDownloaderDelegate* delegate) {
- return ChromeExtensionDownloaderFactory::CreateForRequestContext(
- request_context(),
+ return make_scoped_ptr(new ExtensionDownloader(
downloader_delegate_override_ ? downloader_delegate_override_
- : delegate);
+ : delegate,
+ request_context()));
}
scoped_ptr<ExtensionDownloader> CreateExtensionDownloaderWithIdentity(
@@ -568,7 +566,8 @@
std::map<std::string, std::string> params;
ExtractParameters(query, &params);
- std::string omaha_params = OmahaQueryParams::Get(OmahaQueryParams::CRX);
+ std::string omaha_params = omaha_query_params::OmahaQueryParams::Get(
+ omaha_query_params::OmahaQueryParams::CRX);
std::map<std::string, std::string> expected;
ExtractParameters(omaha_params, &expected);
@@ -701,13 +700,12 @@
// Make sure that an empty update URL data string does not cause a ap=
// option to appear in the x= parameter.
- scoped_ptr<ManifestFetchData> fetch_data(
- CreateManifestFetchData(GURL("http://localhost/foo")));
- fetch_data->AddExtension(
+ ManifestFetchData fetch_data(GURL("http://localhost/foo"), 0);
+ fetch_data.AddExtension(
id, version, &kNeverPingedData, std::string(), std::string());
std::map<std::string, std::string> params;
- VerifyQueryAndExtractParameters(fetch_data->full_url().query(), &params);
+ VerifyQueryAndExtractParameters(fetch_data.full_url().query(), &params);
EXPECT_EQ(id, params["id"]);
EXPECT_EQ(version, params["v"]);
EXPECT_EQ(0U, params.count("ap"));
@@ -719,12 +717,11 @@
// Make sure that an update URL data string causes an appropriate ap=
// option to appear in the x= parameter.
- scoped_ptr<ManifestFetchData> fetch_data(
- CreateManifestFetchData(GURL("http://localhost/foo")));
- fetch_data->AddExtension(
+ ManifestFetchData fetch_data(GURL("http://localhost/foo"), 0);
+ fetch_data.AddExtension(
id, version, &kNeverPingedData, "bar", std::string());
std::map<std::string, std::string> params;
- VerifyQueryAndExtractParameters(fetch_data->full_url().query(), &params);
+ VerifyQueryAndExtractParameters(fetch_data.full_url().query(), &params);
EXPECT_EQ(id, params["id"]);
EXPECT_EQ(version, params["v"]);
EXPECT_EQ("bar", params["ap"]);
@@ -736,12 +733,11 @@
// Make sure that an update URL data string causes an appropriate ap=
// option to appear in the x= parameter.
- scoped_ptr<ManifestFetchData> fetch_data(
- CreateManifestFetchData(GURL("http://localhost/foo")));
- fetch_data->AddExtension(
+ ManifestFetchData fetch_data(GURL("http://localhost/foo"), 0);
+ 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(), &params);
+ VerifyQueryAndExtractParameters(fetch_data.full_url().query(), &params);
EXPECT_EQ(id, params["id"]);
EXPECT_EQ(version, params["v"]);
EXPECT_EQ("a%3D1%26b%3D2%26c", params["ap"]);
@@ -781,12 +777,11 @@
const std::string install_source = "instally";
// Make sure that an installsource= appears in the x= parameter.
- scoped_ptr<ManifestFetchData> fetch_data(
- CreateManifestFetchData(GURL("http://localhost/foo")));
- fetch_data->AddExtension(
- id, version, &kNeverPingedData, kEmptyUpdateUrlData, install_source);
+ ManifestFetchData fetch_data(GURL("http://localhost/foo"), 0);
+ fetch_data.AddExtension(id, version, &kNeverPingedData,
+ kEmptyUpdateUrlData, install_source);
std::map<std::string, std::string> params;
- VerifyQueryAndExtractParameters(fetch_data->full_url().query(), &params);
+ VerifyQueryAndExtractParameters(fetch_data.full_url().query(), &params);
EXPECT_EQ(id, params["id"]);
EXPECT_EQ(version, params["v"]);
EXPECT_EQ(install_source, params["installsource"]);
@@ -798,11 +793,10 @@
ExtensionDownloader downloader(&delegate, profile.GetRequestContext());
// Check passing an empty list of parse results to DetermineUpdates
- scoped_ptr<ManifestFetchData> fetch_data(
- CreateManifestFetchData(GURL("http://localhost/foo")));
+ ManifestFetchData fetch_data(GURL("http://localhost/foo"), 0);
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
@@ -810,10 +804,10 @@
// 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);
@@ -825,7 +819,7 @@
.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]);
}
@@ -841,8 +835,7 @@
MockExtensionDownloaderDelegate delegate;
ExtensionDownloader downloader(&delegate, profile.GetRequestContext());
- scoped_ptr<ManifestFetchData> fetch_data(
- CreateManifestFetchData(GURL("http://localhost/foo")));
+ ManifestFetchData fetch_data(GURL("http://localhost/foo"), 0);
UpdateManifest::Results updates;
std::list<std::string> ids_for_update_check;
@@ -852,11 +845,11 @@
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);
}
@@ -865,7 +858,7 @@
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) {
@@ -884,10 +877,10 @@
GURL kUpdateUrl("http://localhost/manifest1");
- scoped_ptr<ManifestFetchData> fetch1(CreateManifestFetchData(kUpdateUrl));
- scoped_ptr<ManifestFetchData> fetch2(CreateManifestFetchData(kUpdateUrl));
- scoped_ptr<ManifestFetchData> fetch3(CreateManifestFetchData(kUpdateUrl));
- scoped_ptr<ManifestFetchData> fetch4(CreateManifestFetchData(kUpdateUrl));
+ 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));
ManifestFetchData::PingData zeroDays(0, 0, true);
fetch1->AddExtension(
"1111", "1.0", &zeroDays, kEmptyUpdateUrlData, std::string());
@@ -1024,7 +1017,7 @@
GURL kUpdateUrl("http://localhost/manifest1");
- scoped_ptr<ManifestFetchData> fetch(CreateManifestFetchData(kUpdateUrl));
+ scoped_ptr<ManifestFetchData> fetch(new ManifestFetchData(kUpdateUrl, 0));
ManifestFetchData::PingData zeroDays(0, 0, true);
fetch->AddExtension(
"1111", "1.0", &zeroDays, kEmptyUpdateUrlData, std::string());
@@ -1053,7 +1046,7 @@
// For response codes that are not in the 5xx range ExtensionDownloader
// should not retry.
- fetch.reset(CreateManifestFetchData(kUpdateUrl));
+ fetch.reset(new ManifestFetchData(kUpdateUrl, 0));
fetch->AddExtension(
"1111", "1.0", &zeroDays, kEmptyUpdateUrlData, std::string());
@@ -1707,18 +1700,17 @@
updater.Start();
updater.EnsureDownloaderCreated();
- scoped_ptr<ManifestFetchData> fetch_data(
- CreateManifestFetchData(update_url));
+ ManifestFetchData fetch_data(update_url, 0);
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());
@@ -1728,14 +1720,6 @@
protected:
scoped_ptr<TestExtensionPrefs> prefs_;
-
- ManifestFetchData* CreateManifestFetchData(const GURL& update_url) {
- return new ManifestFetchData(update_url,
- 0,
- "",
- OmahaQueryParams::Get(OmahaQueryParams::CRX),
- ManifestFetchData::PING);
- }
private:
content::TestBrowserThreadBundle thread_bundle_;
@@ -2019,12 +2003,12 @@
MockExtensionDownloaderDelegate delegate;
ExtensionDownloader downloader(&delegate, service.request_context());
- StartUpdateCheck(&downloader, CreateManifestFetchData(GURL()));
+ StartUpdateCheck(&downloader, new ManifestFetchData(GURL(), 0));
// This should delete the newly-created ManifestFetchData.
- StartUpdateCheck(&downloader, CreateManifestFetchData(GURL()));
+ StartUpdateCheck(&downloader, new ManifestFetchData(GURL(), 0));
// This should add into |manifests_pending_|.
- StartUpdateCheck(&downloader,
- CreateManifestFetchData(GURL("http://www.google.com")));
+ StartUpdateCheck(&downloader, new ManifestFetchData(GURL(
+ GURL("http://www.google.com")), 0));
// The dtor of |downloader| should delete the pending fetchers.
}
« no previous file with comments | « chrome/browser/extensions/updater/extension_updater.h ('k') | chrome/browser/extensions/updater/manifest_fetch_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698