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

Side by Side Diff: chrome/browser/page_load_metrics/page_load_metrics_browsertest.cc

Issue 2624283004: Associate a main resource request with its PageLoadTracker. (Closed)
Patch Set: fix comment 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/files/scoped_temp_dir.h" 5 #include "base/files/scoped_temp_dir.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/test/histogram_tester.h" 7 #include "base/test/histogram_tester.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" 9 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h"
10 #include "chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_ob server.h" 10 #include "chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_ob server.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 void NavigateToUntrackedUrl() { 42 void NavigateToUntrackedUrl() {
43 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 43 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
44 } 44 }
45 45
46 bool NoPageLoadMetricsRecorded() { 46 bool NoPageLoadMetricsRecorded() {
47 return histogram_tester_.GetTotalCountsForPrefix("PageLoad.").empty(); 47 return histogram_tester_.GetTotalCountsForPrefix("PageLoad.").empty();
48 } 48 }
49 49
50 base::HistogramTester histogram_tester_; 50 base::HistogramTester histogram_tester_;
51 51
52 private:
52 DISALLOW_COPY_AND_ASSIGN(PageLoadMetricsBrowserTest); 53 DISALLOW_COPY_AND_ASSIGN(PageLoadMetricsBrowserTest);
53 }; 54 };
54 55
55 void FailAllNetworkTransactions(net::URLRequestContextGetter* getter) { 56 void FailAllNetworkTransactions(net::URLRequestContextGetter* getter) {
56 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 57 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
57 net::HttpCache* cache( 58 net::HttpCache* cache(
58 getter->GetURLRequestContext()->http_transaction_factory()->GetCache()); 59 getter->GetURLRequestContext()->http_transaction_factory()->GetCache());
59 DCHECK(cache); 60 DCHECK(cache);
60 std::unique_ptr<net::FailingHttpTransactionFactory> factory( 61 std::unique_ptr<net::FailingHttpTransactionFactory> factory(
61 new net::FailingHttpTransactionFactory(cache->GetSession(), 62 new net::FailingHttpTransactionFactory(cache->GetSession(),
(...skipping 16 matching lines...) Expand all
78 NavigateToUntrackedUrl(); 79 NavigateToUntrackedUrl();
79 80
80 histogram_tester_.ExpectTotalCount(internal::kHistogramDomContentLoaded, 1); 81 histogram_tester_.ExpectTotalCount(internal::kHistogramDomContentLoaded, 1);
81 histogram_tester_.ExpectTotalCount(internal::kHistogramLoad, 1); 82 histogram_tester_.ExpectTotalCount(internal::kHistogramLoad, 1);
82 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 1); 83 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 1);
83 histogram_tester_.ExpectTotalCount(internal::kHistogramParseDuration, 1); 84 histogram_tester_.ExpectTotalCount(internal::kHistogramParseDuration, 1);
84 histogram_tester_.ExpectTotalCount( 85 histogram_tester_.ExpectTotalCount(
85 internal::kHistogramParseBlockedOnScriptLoad, 1); 86 internal::kHistogramParseBlockedOnScriptLoad, 1);
86 histogram_tester_.ExpectTotalCount( 87 histogram_tester_.ExpectTotalCount(
87 internal::kHistogramParseBlockedOnScriptExecution, 1); 88 internal::kHistogramParseBlockedOnScriptExecution, 1);
89 histogram_tester_.ExpectTotalCount(internal::kHistogramTotalBytes, 1);
88 90
89 // Verify that NoPageLoadMetricsRecorded returns false when PageLoad metrics 91 // Verify that NoPageLoadMetricsRecorded returns false when PageLoad metrics
90 // have been recorded. 92 // have been recorded.
91 EXPECT_FALSE(NoPageLoadMetricsRecorded()); 93 EXPECT_FALSE(NoPageLoadMetricsRecorded());
92 } 94 }
93 95
94 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, SamePageNavigation) { 96 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, SamePageNavigation) {
95 ASSERT_TRUE(embedded_test_server()->Start()); 97 ASSERT_TRUE(embedded_test_server()->Start());
96 98
97 ui_test_utils::NavigateToURL(browser(), 99 ui_test_utils::NavigateToURL(browser(),
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 544
543 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstContentfulPaint, 545 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstContentfulPaint,
544 1); 546 1);
545 histogram_tester_.ExpectTotalCount( 547 histogram_tester_.ExpectTotalCount(
546 "PageLoad.CSSTiming.Parse.BeforeFirstContentfulPaint", 1); 548 "PageLoad.CSSTiming.Parse.BeforeFirstContentfulPaint", 1);
547 histogram_tester_.ExpectTotalCount( 549 histogram_tester_.ExpectTotalCount(
548 "PageLoad.CSSTiming.Update.BeforeFirstContentfulPaint", 1); 550 "PageLoad.CSSTiming.Update.BeforeFirstContentfulPaint", 1);
549 histogram_tester_.ExpectTotalCount( 551 histogram_tester_.ExpectTotalCount(
550 "PageLoad.CSSTiming.ParseAndUpdate.BeforeFirstContentfulPaint", 1); 552 "PageLoad.CSSTiming.ParseAndUpdate.BeforeFirstContentfulPaint", 1);
551 } 553 }
554
555 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PayloadSize) {
556 ASSERT_TRUE(embedded_test_server()->Start());
557
558 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL(
559 "/page_load_metrics/large.html"));
560 NavigateToUntrackedUrl();
561
562 histogram_tester_.ExpectTotalCount(internal::kHistogramTotalBytes, 1);
563
564 // Verify that there is a single sample recorded in the 10kB bucket (the size
565 // of the main HTML response).
566 histogram_tester_.ExpectBucketCount(internal::kHistogramTotalBytes, 10, 1);
567 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698