| Index: chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer_unittest.cc
|
| diff --git a/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer_unittest.cc b/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer_unittest.cc
|
| index d8cb11170edc491882e9ea597d9e601e4f775e66..752bab5ad5fd096ac139572fdce313a47429eddf 100644
|
| --- a/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer_unittest.cc
|
| +++ b/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer_unittest.cc
|
| @@ -20,7 +20,6 @@ class FromGWSPageLoadMetricsObserverTest
|
| void RegisterObservers(page_load_metrics::PageLoadTracker* tracker) override {
|
| FromGWSPageLoadMetricsObserver* observer =
|
| new FromGWSPageLoadMetricsObserver();
|
| - logger_ = observer->GetLogger();
|
| tracker->AddObserver(base::WrapUnique(observer));
|
| }
|
|
|
| @@ -33,15 +32,9 @@ class FromGWSPageLoadMetricsObserverTest
|
| void SimulateTimingWithFirstPaint() {
|
| page_load_metrics::PageLoadTiming timing;
|
| timing.navigation_start = base::Time::FromDoubleT(1);
|
| - // Use 0 and invoke OnFirstPaint here as a hack for current time_to_abort
|
| - // in cases in release env are always 0
|
| - // TODO(bmcquade): replace it by 1
|
| timing.first_paint = base::TimeDelta::FromMilliseconds(0);
|
| PopulateRequiredTimingFields(&timing);
|
| SimulateTimingUpdate(timing);
|
| - // TODO(bmcquade): remove SetFirstPaintTriggered as part of fixing
|
| - // crbug.com/616901
|
| - logger_->SetFirstPaintTriggered(true);
|
| }
|
|
|
| void SimulateMouseEvent() {
|
| @@ -53,10 +46,6 @@ class FromGWSPageLoadMetricsObserverTest
|
| mouse_event.clickCount = 1;
|
| SimulateInputEvent(mouse_event);
|
| }
|
| -
|
| - protected:
|
| - // TODO(bmcquade): remove once crbug.com/616901 is addressed
|
| - FromGWSPageLoadMetricsLogger* logger_;
|
| };
|
|
|
| class FromGWSPageLoadMetricsLoggerTest : public testing::Test {};
|
| @@ -155,53 +144,58 @@ TEST_F(FromGWSPageLoadMetricsObserverTest, SearchPreviousCommittedUrl1) {
|
| NavigateAndCommit(GURL("http://www.final.com"));
|
|
|
| histogram_tester().ExpectTotalCount(internal::kHistogramFromGWSParseStart, 1);
|
| - histogram_tester().ExpectBucketCount(internal::kHistogramFromGWSParseStart,
|
| - timing.parse_start.InMilliseconds(), 1);
|
| + histogram_tester().ExpectBucketCount(
|
| + internal::kHistogramFromGWSParseStart,
|
| + timing.parse_start.value().InMilliseconds(), 1);
|
|
|
| histogram_tester().ExpectTotalCount(internal::kHistogramFromGWSFirstPaint, 1);
|
| - histogram_tester().ExpectBucketCount(internal::kHistogramFromGWSFirstPaint,
|
| - timing.first_paint.InMilliseconds(), 1);
|
| + histogram_tester().ExpectBucketCount(
|
| + internal::kHistogramFromGWSFirstPaint,
|
| + timing.first_paint.value().InMilliseconds(), 1);
|
|
|
| histogram_tester().ExpectTotalCount(
|
| internal::kHistogramFromGWSFirstContentfulPaint, 1);
|
| histogram_tester().ExpectBucketCount(
|
| internal::kHistogramFromGWSFirstContentfulPaint,
|
| - timing.first_contentful_paint.InMilliseconds(), 1);
|
| + timing.first_contentful_paint.value().InMilliseconds(), 1);
|
|
|
| histogram_tester().ExpectTotalCount(
|
| internal::kHistogramFromGWSParseStartToFirstContentfulPaint, 1);
|
| histogram_tester().ExpectBucketCount(
|
| internal::kHistogramFromGWSParseStartToFirstContentfulPaint,
|
| - (timing.first_contentful_paint - timing.parse_start).InMilliseconds(), 1);
|
| + (timing.first_contentful_paint.value() - timing.parse_start.value())
|
| + .InMilliseconds(),
|
| + 1);
|
|
|
| histogram_tester().ExpectTotalCount(internal::kHistogramFromGWSFirstTextPaint,
|
| 1);
|
| histogram_tester().ExpectBucketCount(
|
| internal::kHistogramFromGWSFirstTextPaint,
|
| - timing.first_text_paint.InMilliseconds(), 1);
|
| + timing.first_text_paint.value().InMilliseconds(), 1);
|
|
|
| histogram_tester().ExpectTotalCount(
|
| internal::kHistogramFromGWSFirstImagePaint, 1);
|
| histogram_tester().ExpectBucketCount(
|
| internal::kHistogramFromGWSFirstImagePaint,
|
| - timing.first_image_paint.InMilliseconds(), 1);
|
| + timing.first_image_paint.value().InMilliseconds(), 1);
|
|
|
| histogram_tester().ExpectTotalCount(internal::kHistogramFromGWSParseDuration,
|
| 1);
|
| histogram_tester().ExpectBucketCount(
|
| internal::kHistogramFromGWSParseDuration,
|
| - (timing.parse_stop - timing.parse_start).InMilliseconds(), 1);
|
| + (timing.parse_stop.value() - timing.parse_start.value()).InMilliseconds(),
|
| + 1);
|
|
|
| histogram_tester().ExpectTotalCount(
|
| internal::kHistogramFromGWSDomContentLoaded, 1);
|
| histogram_tester().ExpectBucketCount(
|
| internal::kHistogramFromGWSDomContentLoaded,
|
| - timing.dom_content_loaded_event_start.InMilliseconds(), 1);
|
| + timing.dom_content_loaded_event_start.value().InMilliseconds(), 1);
|
|
|
| histogram_tester().ExpectTotalCount(internal::kHistogramFromGWSLoad, 1);
|
| - histogram_tester().ExpectBucketCount(internal::kHistogramFromGWSLoad,
|
| - timing.load_event_start.InMilliseconds(),
|
| - 1);
|
| + histogram_tester().ExpectBucketCount(
|
| + internal::kHistogramFromGWSLoad,
|
| + timing.load_event_start.value().InMilliseconds(), 1);
|
| }
|
|
|
| TEST_F(FromGWSPageLoadMetricsObserverTest, SearchPreviousCommittedUrl2) {
|
| @@ -220,7 +214,7 @@ TEST_F(FromGWSPageLoadMetricsObserverTest, SearchPreviousCommittedUrl2) {
|
| 1);
|
| histogram_tester().ExpectBucketCount(
|
| internal::kHistogramFromGWSFirstTextPaint,
|
| - timing.first_text_paint.InMilliseconds(), 1);
|
| + timing.first_text_paint.value().InMilliseconds(), 1);
|
| }
|
|
|
| TEST_F(FromGWSPageLoadMetricsObserverTest, SearchPreviousCommittedUrl3) {
|
| @@ -239,7 +233,7 @@ TEST_F(FromGWSPageLoadMetricsObserverTest, SearchPreviousCommittedUrl3) {
|
| 1);
|
| histogram_tester().ExpectBucketCount(
|
| internal::kHistogramFromGWSFirstTextPaint,
|
| - timing.first_text_paint.InMilliseconds(), 1);
|
| + timing.first_text_paint.value().InMilliseconds(), 1);
|
| }
|
|
|
| TEST_F(FromGWSPageLoadMetricsObserverTest, SearchPreviousCommittedUrl4) {
|
| @@ -258,7 +252,7 @@ TEST_F(FromGWSPageLoadMetricsObserverTest, SearchPreviousCommittedUrl4) {
|
| 1);
|
| histogram_tester().ExpectBucketCount(
|
| internal::kHistogramFromGWSFirstTextPaint,
|
| - timing.first_text_paint.InMilliseconds(), 1);
|
| + timing.first_text_paint.value().InMilliseconds(), 1);
|
| }
|
|
|
| TEST_F(FromGWSPageLoadMetricsObserverTest, SearchToNonSearchToOtherPage) {
|
| @@ -283,7 +277,7 @@ TEST_F(FromGWSPageLoadMetricsObserverTest, SearchToNonSearchToOtherPage) {
|
| 1);
|
| histogram_tester().ExpectBucketCount(
|
| internal::kHistogramFromGWSFirstTextPaint,
|
| - timing.first_text_paint.InMilliseconds(), 1);
|
| + timing.first_text_paint.value().InMilliseconds(), 1);
|
| }
|
|
|
| TEST_F(FromGWSPageLoadMetricsObserverTest, SearchToNonSearchToSearch) {
|
| @@ -308,7 +302,7 @@ TEST_F(FromGWSPageLoadMetricsObserverTest, SearchToNonSearchToSearch) {
|
| 1);
|
| histogram_tester().ExpectBucketCount(
|
| internal::kHistogramFromGWSFirstTextPaint,
|
| - timing.first_text_paint.InMilliseconds(), 1);
|
| + timing.first_text_paint.value().InMilliseconds(), 1);
|
| }
|
|
|
| TEST_F(FromGWSPageLoadMetricsObserverTest,
|
| @@ -340,10 +334,10 @@ TEST_F(FromGWSPageLoadMetricsObserverTest,
|
| 2);
|
| histogram_tester().ExpectBucketCount(
|
| internal::kHistogramFromGWSFirstTextPaint,
|
| - timing.first_text_paint.InMilliseconds(), 1);
|
| + timing.first_text_paint.value().InMilliseconds(), 1);
|
| histogram_tester().ExpectBucketCount(
|
| internal::kHistogramFromGWSFirstTextPaint,
|
| - timing3.first_text_paint.InMilliseconds(), 1);
|
| + timing3.first_text_paint.value().InMilliseconds(), 1);
|
| }
|
|
|
| TEST_F(FromGWSPageLoadMetricsObserverTest,
|
| @@ -376,7 +370,7 @@ TEST_F(FromGWSPageLoadMetricsObserverTest,
|
| 1);
|
| histogram_tester().ExpectBucketCount(
|
| internal::kHistogramFromGWSFirstTextPaint,
|
| - timing.first_text_paint.InMilliseconds(), 1);
|
| + timing.first_text_paint.value().InMilliseconds(), 1);
|
| }
|
|
|
| TEST_F(FromGWSPageLoadMetricsObserverTest,
|
| @@ -397,7 +391,7 @@ TEST_F(FromGWSPageLoadMetricsObserverTest,
|
| 1);
|
| histogram_tester().ExpectBucketCount(
|
| internal::kHistogramFromGWSFirstTextPaint,
|
| - timing.first_text_paint.InMilliseconds(), 1);
|
| + timing.first_text_paint.value().InMilliseconds(), 1);
|
| }
|
|
|
| TEST_F(FromGWSPageLoadMetricsObserverTest,
|
| @@ -436,13 +430,13 @@ TEST_F(FromGWSPageLoadMetricsObserverTest,
|
|
|
| // If the system clock is low resolution PageLoadTracker's background_time_
|
| // may be < timing.first_text_paint.
|
| - if (page_load_metrics::WasStartedInForegroundEventInForeground(
|
| + if (page_load_metrics::WasStartedInForegroundOptionalEventInForeground(
|
| timing.first_text_paint, info)) {
|
| histogram_tester().ExpectTotalCount(
|
| internal::kHistogramFromGWSFirstTextPaint, 1);
|
| histogram_tester().ExpectBucketCount(
|
| internal::kHistogramFromGWSFirstTextPaint,
|
| - timing.first_text_paint.InMilliseconds(), 1);
|
| + timing.first_text_paint.value().InMilliseconds(), 1);
|
| } else {
|
| histogram_tester().ExpectTotalCount(
|
| internal::kHistogramFromGWSFirstTextPaint, 0);
|
|
|