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

Side by Side Diff: chrome/browser/page_load_metrics/observers/core_page_load_metrics_observer_unittest.cc

Issue 2699933003: Generalize abort tracking to page end state tracking (Closed)
Patch Set: fix comment Created 3 years, 10 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 "chrome/browser/page_load_metrics/observers/core_page_load_metrics_obse rver.h" 5 #include "chrome/browser/page_load_metrics/observers/core_page_load_metrics_obse rver.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_ test_harness.h" 8 #include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_ test_harness.h"
9 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" 9 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h"
10 #include "chrome/test/base/testing_browser_process.h" 10 #include "chrome/test/base/testing_browser_process.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 histogram_tester().ExpectBucketCount( 97 histogram_tester().ExpectBucketCount(
98 internal::kHistogramParseDuration, 98 internal::kHistogramParseDuration,
99 (parse_stop - parse_start).InMilliseconds(), 1); 99 (parse_stop - parse_start).InMilliseconds(), 1);
100 histogram_tester().ExpectBucketCount( 100 histogram_tester().ExpectBucketCount(
101 internal::kHistogramParseBlockedOnScriptLoad, 101 internal::kHistogramParseBlockedOnScriptLoad,
102 parse_script_load_duration.InMilliseconds(), 1); 102 parse_script_load_duration.InMilliseconds(), 1);
103 histogram_tester().ExpectBucketCount( 103 histogram_tester().ExpectBucketCount(
104 internal::kHistogramParseBlockedOnScriptExecution, 104 internal::kHistogramParseBlockedOnScriptExecution,
105 parse_script_exec_duration.InMilliseconds(), 1); 105 parse_script_exec_duration.InMilliseconds(), 1);
106 histogram_tester().ExpectTotalCount(internal::kHistogramFirstTextPaint, 0); 106 histogram_tester().ExpectTotalCount(internal::kHistogramFirstTextPaint, 0);
107
108 histogram_tester().ExpectTotalCount(internal::kHistogramPageTimingPageEnd, 1);
109 histogram_tester().ExpectTotalCount(
110 internal::kHistogramPageTimingFirstBackground, 0);
107 } 111 }
108 112
109 TEST_F(CorePageLoadMetricsObserverTest, MultipleMetricsAfterCommits) { 113 TEST_F(CorePageLoadMetricsObserverTest, MultipleMetricsAfterCommits) {
110 base::TimeDelta response = base::TimeDelta::FromMilliseconds(1); 114 base::TimeDelta response = base::TimeDelta::FromMilliseconds(1);
111 base::TimeDelta first_layout_1 = base::TimeDelta::FromMilliseconds(10); 115 base::TimeDelta first_layout_1 = base::TimeDelta::FromMilliseconds(10);
112 base::TimeDelta first_layout_2 = base::TimeDelta::FromMilliseconds(20); 116 base::TimeDelta first_layout_2 = base::TimeDelta::FromMilliseconds(20);
113 base::TimeDelta first_text_paint = base::TimeDelta::FromMilliseconds(30); 117 base::TimeDelta first_text_paint = base::TimeDelta::FromMilliseconds(30);
114 base::TimeDelta first_contentful_paint = first_text_paint; 118 base::TimeDelta first_contentful_paint = first_text_paint;
115 base::TimeDelta dom_content = base::TimeDelta::FromMilliseconds(40); 119 base::TimeDelta dom_content = base::TimeDelta::FromMilliseconds(40);
116 base::TimeDelta load = base::TimeDelta::FromMilliseconds(100); 120 base::TimeDelta load = base::TimeDelta::FromMilliseconds(100);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 257
254 histogram_tester().ExpectTotalCount(internal::kBackgroundHistogramLoad, 0); 258 histogram_tester().ExpectTotalCount(internal::kBackgroundHistogramLoad, 0);
255 histogram_tester().ExpectTotalCount( 259 histogram_tester().ExpectTotalCount(
256 internal::kBackgroundHistogramFirstTextPaint, 1); 260 internal::kBackgroundHistogramFirstTextPaint, 1);
257 histogram_tester().ExpectBucketCount( 261 histogram_tester().ExpectBucketCount(
258 internal::kBackgroundHistogramFirstTextPaint, 262 internal::kBackgroundHistogramFirstTextPaint,
259 timing.first_text_paint.value().InMilliseconds(), 1); 263 timing.first_text_paint.value().InMilliseconds(), 1);
260 264
261 histogram_tester().ExpectTotalCount(internal::kHistogramLoad, 0); 265 histogram_tester().ExpectTotalCount(internal::kHistogramLoad, 0);
262 histogram_tester().ExpectTotalCount(internal::kHistogramFirstTextPaint, 0); 266 histogram_tester().ExpectTotalCount(internal::kHistogramFirstTextPaint, 0);
267
268 histogram_tester().ExpectTotalCount(internal::kHistogramPageTimingPageEnd, 0);
269 histogram_tester().ExpectTotalCount(
270 internal::kHistogramPageTimingFirstBackground, 1);
263 } 271 }
264 272
265 TEST_F(CorePageLoadMetricsObserverTest, DontBackgroundQuickerLoad) { 273 TEST_F(CorePageLoadMetricsObserverTest, DontBackgroundQuickerLoad) {
266 // Set this event at 1 microsecond so it occurs before we foreground later in 274 // Set this event at 1 microsecond so it occurs before we foreground later in
267 // the test. 275 // the test.
268 base::TimeDelta first_layout = base::TimeDelta::FromMicroseconds(1); 276 base::TimeDelta first_layout = base::TimeDelta::FromMicroseconds(1);
269 277
270 page_load_metrics::PageLoadTiming timing; 278 page_load_metrics::PageLoadTiming timing;
271 timing.navigation_start = base::Time::FromDoubleT(1); 279 timing.navigation_start = base::Time::FromDoubleT(1);
272 timing.first_layout = first_layout; 280 timing.first_layout = first_layout;
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 NavigateAndCommit(GURL(kDefaultTestUrl2)); 546 NavigateAndCommit(GURL(kDefaultTestUrl2));
539 547
540 histogram_tester().ExpectTotalCount( 548 histogram_tester().ExpectTotalCount(
541 internal::kHistogramFirstMeaningfulPaint, 0); 549 internal::kHistogramFirstMeaningfulPaint, 0);
542 histogram_tester().ExpectTotalCount( 550 histogram_tester().ExpectTotalCount(
543 internal::kHistogramParseStartToFirstMeaningfulPaint, 0); 551 internal::kHistogramParseStartToFirstMeaningfulPaint, 0);
544 histogram_tester().ExpectBucketCount( 552 histogram_tester().ExpectBucketCount(
545 internal::kHistogramFirstMeaningfulPaintStatus, 553 internal::kHistogramFirstMeaningfulPaintStatus,
546 internal::FIRST_MEANINGFUL_PAINT_USER_INTERACTION_BEFORE_FMP, 1); 554 internal::FIRST_MEANINGFUL_PAINT_USER_INTERACTION_BEFORE_FMP, 1);
547 } 555 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698