Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1313 } | 1313 } |
| 1314 | 1314 |
| 1315 TEST_F(ResourcePrefetchPredictorTest, SummarizeResponse) { | 1315 TEST_F(ResourcePrefetchPredictorTest, SummarizeResponse) { |
| 1316 net::HttpResponseInfo response_info; | 1316 net::HttpResponseInfo response_info; |
| 1317 response_info.headers = | 1317 response_info.headers = |
| 1318 MakeResponseHeaders("HTTP/1.1 200 OK\n\nSome: Headers\n"); | 1318 MakeResponseHeaders("HTTP/1.1 200 OK\n\nSome: Headers\n"); |
| 1319 response_info.was_cached = true; | 1319 response_info.was_cached = true; |
| 1320 url_request_job_factory_.set_response_info(response_info); | 1320 url_request_job_factory_.set_response_info(response_info); |
| 1321 | 1321 |
| 1322 GURL url("http://www.google.com/cat.png"); | 1322 GURL url("http://www.google.com/cat.png"); |
| 1323 GURL emptyUrl; | |
|
ahemery
2016/12/06 14:31:11
Just using GURL()
| |
| 1323 std::unique_ptr<net::URLRequest> request = CreateURLRequest( | 1324 std::unique_ptr<net::URLRequest> request = CreateURLRequest( |
| 1324 url, net::MEDIUM, content::RESOURCE_TYPE_IMAGE, 1, 1, true); | 1325 url, net::MEDIUM, content::RESOURCE_TYPE_IMAGE, 1, 1, true); |
| 1325 URLRequestSummary summary; | 1326 URLRequestSummary summary; |
| 1326 EXPECT_TRUE(URLRequestSummary::SummarizeResponse(*request, &summary)); | 1327 EXPECT_TRUE(URLRequestSummary::SummarizeResponse(*request, &summary)); |
| 1327 EXPECT_EQ(1, summary.navigation_id.render_process_id); | |
| 1328 EXPECT_EQ(1, summary.navigation_id.render_frame_id); | |
| 1329 EXPECT_EQ(url, summary.navigation_id.main_frame_url); | |
| 1330 EXPECT_EQ(url, summary.resource_url); | 1328 EXPECT_EQ(url, summary.resource_url); |
| 1331 EXPECT_EQ(content::RESOURCE_TYPE_IMAGE, summary.resource_type); | 1329 EXPECT_EQ(content::RESOURCE_TYPE_IMAGE, summary.resource_type); |
| 1332 EXPECT_TRUE(summary.was_cached); | 1330 EXPECT_TRUE(summary.was_cached); |
| 1333 EXPECT_FALSE(summary.has_validators); | 1331 EXPECT_FALSE(summary.has_validators); |
| 1334 EXPECT_FALSE(summary.always_revalidate); | 1332 EXPECT_FALSE(summary.always_revalidate); |
| 1333 | |
| 1334 // navigation_id elements should be unset by default | |
|
ahemery
2016/12/05 09:38:45
Simply reflecting the changes commented in Summari
alexilin
2016/12/05 13:20:00
nit: add period to the end of the comment.
https:/
| |
| 1335 EXPECT_EQ(-1, summary.navigation_id.render_process_id); | |
| 1336 EXPECT_EQ(-1, summary.navigation_id.render_frame_id); | |
| 1337 EXPECT_EQ(emptyUrl, summary.navigation_id.main_frame_url); | |
| 1335 } | 1338 } |
| 1336 | 1339 |
| 1337 TEST_F(ResourcePrefetchPredictorTest, SummarizeResponseContentType) { | 1340 TEST_F(ResourcePrefetchPredictorTest, SummarizeResponseContentType) { |
| 1338 net::HttpResponseInfo response_info; | 1341 net::HttpResponseInfo response_info; |
| 1339 response_info.headers = MakeResponseHeaders( | 1342 response_info.headers = MakeResponseHeaders( |
| 1340 "HTTP/1.1 200 OK\n\n" | 1343 "HTTP/1.1 200 OK\n\n" |
| 1341 "Some: Headers\n" | 1344 "Some: Headers\n" |
| 1342 "Content-Type: image/whatever\n"); | 1345 "Content-Type: image/whatever\n"); |
| 1343 url_request_job_factory_.set_response_info(response_info); | 1346 url_request_job_factory_.set_response_info(response_info); |
| 1344 url_request_job_factory_.set_mime_type("image/png"); | 1347 url_request_job_factory_.set_mime_type("image/png"); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1549 net::MEDIUM, false, false); | 1552 net::MEDIUM, false, false); |
| 1550 predictor_->url_table_cache_->insert( | 1553 predictor_->url_table_cache_->insert( |
| 1551 std::make_pair(www_google_url.primary_key(), www_google_url)); | 1554 std::make_pair(www_google_url.primary_key(), www_google_url)); |
| 1552 | 1555 |
| 1553 urls.clear(); | 1556 urls.clear(); |
| 1554 EXPECT_TRUE(predictor_->GetPrefetchData(main_frame_url, &urls)); | 1557 EXPECT_TRUE(predictor_->GetPrefetchData(main_frame_url, &urls)); |
| 1555 EXPECT_THAT(urls, UnorderedElementsAre(GURL(font_url))); | 1558 EXPECT_THAT(urls, UnorderedElementsAre(GURL(font_url))); |
| 1556 } | 1559 } |
| 1557 | 1560 |
| 1558 } // namespace predictors | 1561 } // namespace predictors |
| OLD | NEW |