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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor_unittest.cc

Issue 2539263004: predictors: Take RESOURCE_TYPE_XHR into account. (Closed)
Patch Set: Add test. 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/predictors/resource_prefetch_predictor.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/predictors/resource_prefetch_predictor.h" 5 #include "chrome/browser/predictors/resource_prefetch_predictor.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 EXPECT_TRUE(ResourcePrefetchPredictor::IsHandledResourceType( 1156 EXPECT_TRUE(ResourcePrefetchPredictor::IsHandledResourceType(
1157 content::RESOURCE_TYPE_PREFETCH, "text/css")); 1157 content::RESOURCE_TYPE_PREFETCH, "text/css"));
1158 EXPECT_FALSE(ResourcePrefetchPredictor::IsHandledResourceType( 1158 EXPECT_FALSE(ResourcePrefetchPredictor::IsHandledResourceType(
1159 content::RESOURCE_TYPE_PREFETCH, "bogus/mime-type")); 1159 content::RESOURCE_TYPE_PREFETCH, "bogus/mime-type"));
1160 EXPECT_FALSE(ResourcePrefetchPredictor::IsHandledResourceType( 1160 EXPECT_FALSE(ResourcePrefetchPredictor::IsHandledResourceType(
1161 content::RESOURCE_TYPE_PREFETCH, "")); 1161 content::RESOURCE_TYPE_PREFETCH, ""));
1162 EXPECT_TRUE(ResourcePrefetchPredictor::IsHandledResourceType( 1162 EXPECT_TRUE(ResourcePrefetchPredictor::IsHandledResourceType(
1163 content::RESOURCE_TYPE_PREFETCH, "application/font-woff")); 1163 content::RESOURCE_TYPE_PREFETCH, "application/font-woff"));
1164 EXPECT_TRUE(ResourcePrefetchPredictor::IsHandledResourceType( 1164 EXPECT_TRUE(ResourcePrefetchPredictor::IsHandledResourceType(
1165 content::RESOURCE_TYPE_PREFETCH, "font/woff2")); 1165 content::RESOURCE_TYPE_PREFETCH, "font/woff2"));
1166 EXPECT_FALSE(ResourcePrefetchPredictor::IsHandledResourceType(
1167 content::RESOURCE_TYPE_XHR, ""));
1168 EXPECT_FALSE(ResourcePrefetchPredictor::IsHandledResourceType(
1169 content::RESOURCE_TYPE_XHR, "bogus/mime-type"));
1170 EXPECT_TRUE(ResourcePrefetchPredictor::IsHandledResourceType(
1171 content::RESOURCE_TYPE_XHR, "application/javascript"));
1166 } 1172 }
1167 1173
1168 TEST_F(ResourcePrefetchPredictorTest, ShouldRecordRequestMainFrame) { 1174 TEST_F(ResourcePrefetchPredictorTest, ShouldRecordRequestMainFrame) {
1169 std::unique_ptr<net::URLRequest> http_request = 1175 std::unique_ptr<net::URLRequest> http_request =
1170 CreateURLRequest(GURL("http://www.google.com"), net::MEDIUM, 1176 CreateURLRequest(GURL("http://www.google.com"), net::MEDIUM,
1171 content::RESOURCE_TYPE_IMAGE, 1, 1, true); 1177 content::RESOURCE_TYPE_IMAGE, 1, 1, true);
1172 EXPECT_TRUE(ResourcePrefetchPredictor::ShouldRecordRequest( 1178 EXPECT_TRUE(ResourcePrefetchPredictor::ShouldRecordRequest(
1173 http_request.get(), content::RESOURCE_TYPE_MAIN_FRAME)); 1179 http_request.get(), content::RESOURCE_TYPE_MAIN_FRAME));
1174 1180
1175 std::unique_ptr<net::URLRequest> https_request = 1181 std::unique_ptr<net::URLRequest> https_request =
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 net::MEDIUM, false, false); 1549 net::MEDIUM, false, false);
1544 predictor_->url_table_cache_->insert( 1550 predictor_->url_table_cache_->insert(
1545 std::make_pair(www_google_url.primary_key(), www_google_url)); 1551 std::make_pair(www_google_url.primary_key(), www_google_url));
1546 1552
1547 urls.clear(); 1553 urls.clear();
1548 EXPECT_TRUE(predictor_->GetPrefetchData(main_frame_url, &urls)); 1554 EXPECT_TRUE(predictor_->GetPrefetchData(main_frame_url, &urls));
1549 EXPECT_THAT(urls, UnorderedElementsAre(GURL(font_url))); 1555 EXPECT_THAT(urls, UnorderedElementsAre(GURL(font_url)));
1550 } 1556 }
1551 1557
1552 } // namespace predictors 1558 } // namespace predictors
OLDNEW
« no previous file with comments | « chrome/browser/predictors/resource_prefetch_predictor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698