OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/delay_navigation_page_load_
metrics_observer.h" | 5 #include "chrome/browser/page_load_metrics/observers/delay_navigation_page_load_
metrics_observer.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 scoped_refptr<base::TestMockTimeTaskRunner> mock_time_task_runner_; | 130 scoped_refptr<base::TestMockTimeTaskRunner> mock_time_task_runner_; |
131 }; | 131 }; |
132 | 132 |
133 TEST_F(DelayNavigationPageLoadMetricsObserverTest, NoMetricsWithoutNavigation) { | 133 TEST_F(DelayNavigationPageLoadMetricsObserverTest, NoMetricsWithoutNavigation) { |
134 ASSERT_FALSE(AnyMetricsRecorded()); | 134 ASSERT_FALSE(AnyMetricsRecorded()); |
135 } | 135 } |
136 | 136 |
137 TEST_F(DelayNavigationPageLoadMetricsObserverTest, CommitWithPaint) { | 137 TEST_F(DelayNavigationPageLoadMetricsObserverTest, CommitWithPaint) { |
138 NavigateToDefaultUrlAndCommit(); | 138 NavigateToDefaultUrlAndCommit(); |
139 | 139 |
140 page_load_metrics::PageLoadTiming timing; | 140 page_load_metrics::mojom::PageLoadTiming timing; |
| 141 page_load_metrics::InitPageLoadTimingForTest(&timing); |
141 timing.navigation_start = base::Time::FromDoubleT(1); | 142 timing.navigation_start = base::Time::FromDoubleT(1); |
142 timing.paint_timing.first_paint = base::TimeDelta::FromMilliseconds(1); | 143 timing.paint_timing->first_paint = base::TimeDelta::FromMilliseconds(1); |
143 PopulateRequiredTimingFields(&timing); | 144 PopulateRequiredTimingFields(&timing); |
144 SimulateTimingUpdate(timing); | 145 SimulateTimingUpdate(timing); |
145 | 146 |
146 ASSERT_TRUE(AnyMetricsRecorded()); | 147 ASSERT_TRUE(AnyMetricsRecorded()); |
147 histogram_tester().ExpectTotalCount( | 148 histogram_tester().ExpectTotalCount( |
148 internal::kHistogramNavigationDelaySpecified, 1); | 149 internal::kHistogramNavigationDelaySpecified, 1); |
149 histogram_tester().ExpectBucketCount( | 150 histogram_tester().ExpectBucketCount( |
150 internal::kHistogramNavigationDelaySpecified, kDelayMillis, 1); | 151 internal::kHistogramNavigationDelaySpecified, kDelayMillis, 1); |
151 | 152 |
152 histogram_tester().ExpectTotalCount(internal::kHistogramNavigationDelayActual, | 153 histogram_tester().ExpectTotalCount(internal::kHistogramNavigationDelayActual, |
153 1); | 154 1); |
154 histogram_tester().ExpectTotalCount(internal::kHistogramNavigationDelayDelta, | 155 histogram_tester().ExpectTotalCount(internal::kHistogramNavigationDelayDelta, |
155 1); | 156 1); |
156 } | 157 } |
OLD | NEW |