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

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

Issue 2820943002: Add detailed tracking for causes of invalid PageLoadTimings. (Closed)
Patch Set: add tests Created 3 years, 8 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 // documents with non-well-formed XML on the blink side. See crbug.com/627607 492 // documents with non-well-formed XML on the blink side. See crbug.com/627607
493 // for more. 493 // for more.
494 ui_test_utils::NavigateToURL( 494 ui_test_utils::NavigateToURL(
495 browser(), 495 browser(),
496 embedded_test_server()->GetURL("/page_load_metrics/badxml.xhtml")); 496 embedded_test_server()->GetURL("/page_load_metrics/badxml.xhtml"));
497 497
498 timing_observer->WaitForMatchingIPC(); 498 timing_observer->WaitForMatchingIPC();
499 499
500 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 0); 500 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 0);
501 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstPaint, 0); 501 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstPaint, 0);
502 histogram_tester_.ExpectTotalCount(page_load_metrics::internal::kErrorEvents,
503 1);
502 histogram_tester_.ExpectBucketCount( 504 histogram_tester_.ExpectBucketCount(
503 page_load_metrics::internal::kErrorEvents, 505 page_load_metrics::internal::kErrorEvents,
504 page_load_metrics::ERR_BAD_TIMING_IPC_INVALID_TIMING, 1); 506 page_load_metrics::ERR_BAD_TIMING_IPC_INVALID_TIMING, 1);
507
508 histogram_tester_.ExpectTotalCount(
509 page_load_metrics::internal::kPageLoadTimingStatus, 1);
510 histogram_tester_.ExpectBucketCount(
511 page_load_metrics::internal::kPageLoadTimingStatus,
512 page_load_metrics::internal::INVALID_ORDER_FIRST_LAYOUT_FIRST_PAINT, 1);
505 } 513 }
506 514
507 // Test code that aborts provisional navigations. 515 // Test code that aborts provisional navigations.
508 // TODO(csharrison): Move these to unit tests once the navigation API in content 516 // TODO(csharrison): Move these to unit tests once the navigation API in content
509 // properly calls NavigationHandle/NavigationThrottle methods. 517 // properly calls NavigationHandle/NavigationThrottle methods.
510 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, AbortNewNavigation) { 518 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, AbortNewNavigation) {
511 ASSERT_TRUE(embedded_test_server()->Start()); 519 ASSERT_TRUE(embedded_test_server()->Start());
512 520
513 GURL url(embedded_test_server()->GetURL("/title1.html")); 521 GURL url(embedded_test_server()->GetURL("/title1.html"));
514 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_LINK); 522 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_LINK);
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL( 777 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL(
770 "/page_load_metrics/large.html")); 778 "/page_load_metrics/large.html"));
771 NavigateToUntrackedUrl(); 779 NavigateToUntrackedUrl();
772 780
773 histogram_tester_.ExpectTotalCount(internal::kHistogramTotalBytes, 1); 781 histogram_tester_.ExpectTotalCount(internal::kHistogramTotalBytes, 1);
774 782
775 // Verify that there is a single sample recorded in the 10kB bucket (the size 783 // Verify that there is a single sample recorded in the 10kB bucket (the size
776 // of the main HTML response). 784 // of the main HTML response).
777 histogram_tester_.ExpectBucketCount(internal::kHistogramTotalBytes, 10, 1); 785 histogram_tester_.ExpectBucketCount(internal::kHistogramTotalBytes, 10, 1);
778 } 786 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698