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

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

Issue 2761353002: Fixing reporting of AMP page load information (Closed)
Patch Set: changed re-verrsioning to AMPCache2 Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/amp_page_load_metrics_obser ver.h" 5 #include "chrome/browser/page_load_metrics/observers/amp_page_load_metrics_obser ver.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/optional.h" 10 #include "base/optional.h"
(...skipping 23 matching lines...) Expand all
34 NavigateAndCommit(url); 34 NavigateAndCommit(url);
35 SimulateTimingUpdate(timing_); 35 SimulateTimingUpdate(timing_);
36 36
37 // Navigate again to force OnComplete, which happens when a new navigation 37 // Navigate again to force OnComplete, which happens when a new navigation
38 // occurs. 38 // occurs.
39 NavigateAndCommit(GURL("http://otherurl.com")); 39 NavigateAndCommit(GURL("http://otherurl.com"));
40 } 40 }
41 41
42 void ValidateHistograms(bool expect_histograms) { 42 void ValidateHistograms(bool expect_histograms) {
43 ValidateHistogramsFor( 43 ValidateHistogramsFor(
44 "PageLoad.Clients.AMPCache.DocumentTiming." 44 "PageLoad.Clients.AMPCache2.DocumentTiming."
45 "NavigationToDOMContentLoadedEventFired", 45 "NavigationToDOMContentLoadedEventFired",
46 timing_.dom_content_loaded_event_start, expect_histograms); 46 timing_.dom_content_loaded_event_start, expect_histograms);
47 ValidateHistogramsFor( 47 ValidateHistogramsFor(
48 "PageLoad.Clients.AMPCache.DocumentTiming.NavigationToFirstLayout", 48 "PageLoad.Clients.AMPCache2.DocumentTiming.NavigationToFirstLayout",
49 timing_.first_layout, expect_histograms); 49 timing_.first_layout, expect_histograms);
50 ValidateHistogramsFor( 50 ValidateHistogramsFor(
51 "PageLoad.Clients.AMPCache.DocumentTiming.NavigationToLoadEventFired", 51 "PageLoad.Clients.AMPCache2.DocumentTiming."
52 "NavigationToLoadEventFired",
52 timing_.load_event_start, expect_histograms); 53 timing_.load_event_start, expect_histograms);
53 ValidateHistogramsFor( 54 ValidateHistogramsFor(
54 "PageLoad.Clients.AMPCache.PaintTiming." 55 "PageLoad.Clients.AMPCache2.PaintTiming."
55 "NavigationToFirstContentfulPaint", 56 "NavigationToFirstContentfulPaint",
56 timing_.first_contentful_paint, expect_histograms); 57 timing_.first_contentful_paint, expect_histograms);
57 ValidateHistogramsFor( 58 ValidateHistogramsFor(
58 "PageLoad.Clients.AMPCache.ParseTiming.NavigationToParseStart", 59 "PageLoad.Clients.AMPCache2.ParseTiming.NavigationToParseStart",
59 timing_.parse_start, expect_histograms); 60 timing_.parse_start, expect_histograms);
60 } 61 }
61 62
62 void ValidateHistogramsFor(const std::string& histogram_, 63 void ValidateHistogramsFor(const std::string& histogram_,
63 const base::Optional<base::TimeDelta>& event, 64 const base::Optional<base::TimeDelta>& event,
64 bool expect_histograms) { 65 bool expect_histograms) {
65 histogram_tester().ExpectTotalCount(histogram_, expect_histograms ? 1 : 0); 66 histogram_tester().ExpectTotalCount(histogram_, expect_histograms ? 1 : 0);
66 if (!expect_histograms) 67 if (!expect_histograms)
67 return; 68 return;
68 histogram_tester().ExpectUniqueSample( 69 histogram_tester().ExpectUniqueSample(
(...skipping 23 matching lines...) Expand all
92 ResetTest(); 93 ResetTest();
93 RunTest(GURL("https://www.google.com/amp/page")); 94 RunTest(GURL("https://www.google.com/amp/page"));
94 ValidateHistograms(true); 95 ValidateHistograms(true);
95 } 96 }
96 97
97 TEST_F(AMPPageLoadMetricsObserverTest, NonAMPPage) { 98 TEST_F(AMPPageLoadMetricsObserverTest, NonAMPPage) {
98 ResetTest(); 99 ResetTest();
99 RunTest(GURL("https://www.google.com/not-amp/page")); 100 RunTest(GURL("https://www.google.com/not-amp/page"));
100 ValidateHistograms(false); 101 ValidateHistograms(false);
101 } 102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698