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

Side by Side Diff: chrome/browser/prerender/prerender_nostate_prefetch_browsertest.cc

Issue 2512953002: Prerender: Add FCP histograms to nostate browsertests. (Closed)
Patch Set: rebase Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/strings/string16.h" 6 #include "base/strings/string16.h"
7 #include "base/strings/string_split.h" 7 #include "base/strings/string_split.h"
8 #include "base/task_scheduler/post_task.h" 8 #include "base/task_scheduler/post_task.h"
9 #include "chrome/browser/history/history_service_factory.h" 9 #include "chrome/browser/history/history_service_factory.h"
10 #include "chrome/browser/history/history_test_utils.h" 10 #include "chrome/browser/history/history_test_utils.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 std::unique_ptr<TestPrerender> test_prerender = 148 std::unique_ptr<TestPrerender> test_prerender =
149 PrefetchFromFile(kPrefetchPage, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); 149 PrefetchFromFile(kPrefetchPage, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED);
150 main_counter.WaitForCount(1); 150 main_counter.WaitForCount(1);
151 script_counter.WaitForCount(1); 151 script_counter.WaitForCount(1);
152 152
153 // Verify that the page load did not happen. 153 // Verify that the page load did not happen.
154 test_prerender->WaitForLoads(0); 154 test_prerender->WaitForLoads(0);
155 } 155 }
156 156
157 // Check that a prefetch followed by a load produces the approriate
158 // histograms. Note that other histogram testing is done in
159 // browser/page_load_metrics, in particular, testing the combinations of
160 // Warm/Cold and Cacheable/NoCacheable.
161 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, PrefetchHistograms) {
162 PrefetchFromFile(kPrefetchPage, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED);
163 histogram_tester().ExpectTotalCount(
164 "Prerender.websame_NoStatePrefetchTTFCP.Warm", 0);
165
166 test_utils::FirstContentfulPaintManagerWaiter* fcp_waiter =
167 test_utils::FirstContentfulPaintManagerWaiter::Create(
168 GetPrerenderManager());
169 ui_test_utils::NavigateToURL(
170 current_browser(), src_server()->GetURL(MakeAbsolute(kPrefetchPage)));
171 fcp_waiter->Wait();
172
173 histogram_tester().ExpectTotalCount(
174 "Prerender.websame_PrefetchTTFCP.Warm.Cacheable.Visible", 1);
175 histogram_tester().ExpectTotalCount(
176 "Prerender.websame_NoStatePrefetchResponseTypes", 2);
177 }
178
157 // Checks the prefetch of an img tag. 179 // Checks the prefetch of an img tag.
158 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, PrefetchImage) { 180 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, PrefetchImage) {
159 RequestCounter image_counter; 181 RequestCounter image_counter;
160 CountRequestFor(kPrefetchJpeg, &image_counter); 182 CountRequestFor(kPrefetchJpeg, &image_counter);
161 base::StringPairs replacement_text; 183 base::StringPairs replacement_text;
162 replacement_text.push_back( 184 replacement_text.push_back(
163 std::make_pair("REPLACE_WITH_IMAGE_URL", MakeAbsolute(kPrefetchJpeg))); 185 std::make_pair("REPLACE_WITH_IMAGE_URL", MakeAbsolute(kPrefetchJpeg)));
164 std::string main_page_path; 186 std::string main_page_path;
165 net::test_server::GetFilePathWithReplacements( 187 net::test_server::GetFilePathWithReplacements(
166 kPrefetchImagePage, replacement_text, &main_page_path); 188 kPrefetchImagePage, replacement_text, &main_page_path);
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 #else 530 #else
509 constexpr net::RequestPriority kExpectedPriority = net::IDLE; 531 constexpr net::RequestPriority kExpectedPriority = net::IDLE;
510 #endif 532 #endif
511 EXPECT_EQ(kExpectedPriority, request->priority()); 533 EXPECT_EQ(kExpectedPriority, request->priority());
512 })); 534 }));
513 PrefetchFromFile(kPrefetchPage, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); 535 PrefetchFromFile(kPrefetchPage, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED);
514 script_counter.WaitForCount(1); 536 script_counter.WaitForCount(1);
515 } 537 }
516 538
517 } // namespace prerender 539 } // namespace prerender
OLDNEW
« 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