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

Unified Diff: chrome/browser/predictors/resource_prefetch_predictor_browsertest.cc

Issue 2569723002: predictors: Fuzzy comparison of request priority for images. (Closed)
Patch Set: Rebase. Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/predictors/resource_prefetch_predictor_browsertest.cc
diff --git a/chrome/browser/predictors/resource_prefetch_predictor_browsertest.cc b/chrome/browser/predictors/resource_prefetch_predictor_browsertest.cc
index c47ea93cf10e9715299975023f41e6d747d13543..c9ab1bf7d49b80fd04537fa57badfb65b8920df9 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor_browsertest.cc
+++ b/chrome/browser/predictors/resource_prefetch_predictor_browsertest.cc
@@ -112,6 +112,19 @@ void SetValidNavigationID(NavigationID* navigation_id) {
navigation_id->main_frame_url = GURL("http://127.0.0.1");
}
+void ModifySubresourceForComparison(URLRequestSummary* subresource,
+ bool match_navigation_id) {
+ if (!match_navigation_id)
+ SetValidNavigationID(&subresource->navigation_id);
+ if (subresource->resource_type == content::RESOURCE_TYPE_IMAGE &&
+ subresource->priority == net::LOWEST) {
+ // Fuzzy comparison for images because an image priority can be
+ // boosted during layout via
+ // ResourceFetcher::updateAllImageResourcePriorities().
+ subresource->priority = net::MEDIUM;
+ }
+}
+
// Does a custom comparison of subresources of URLRequestSummary
// and fail the test if the expectation is not met.
void CompareSubresources(std::vector<URLRequestSummary> actual_subresources,
@@ -121,12 +134,11 @@ void CompareSubresources(std::vector<URLRequestSummary> actual_subresources,
// ResourcePrefetchPredictor only cares about the first occurrence of each.
RemoveDuplicateSubresources(&actual_subresources);
- if (!match_navigation_id) {
- for (auto& subresource : actual_subresources)
- SetValidNavigationID(&subresource.navigation_id);
- for (auto& subresource : expected_subresources)
- SetValidNavigationID(&subresource.navigation_id);
- }
+ for (auto& subresource : actual_subresources)
+ ModifySubresourceForComparison(&subresource, match_navigation_id);
+ for (auto& subresource : expected_subresources)
+ ModifySubresourceForComparison(&subresource, match_navigation_id);
+
EXPECT_THAT(actual_subresources,
testing::UnorderedElementsAreArray(expected_subresources));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698