| Index: chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer_unittest.cc
|
| diff --git a/chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer_unittest.cc b/chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer_unittest.cc
|
| index 53235048d81068080e1dd8fb902b85225156184f..0137ae6c5e3af6b1f16726e429983d9bef688698 100644
|
| --- a/chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer_unittest.cc
|
| +++ b/chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer_unittest.cc
|
| @@ -3,20 +3,21 @@
|
| // found in the LICENSE file.
|
|
|
| #include "chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer.h"
|
|
|
| #include <memory>
|
| #include <string>
|
|
|
| #include "base/macros.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "base/metrics/field_trial.h"
|
| +#include "base/optional.h"
|
| #include "base/time/time.h"
|
| #include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_test_harness.h"
|
| #include "chrome/browser/renderer_host/chrome_navigation_data.h"
|
| #include "chrome/test/base/testing_browser_process.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.h"
|
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_page_load_timing.h"
|
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
|
| #include "components/page_load_metrics/common/page_load_timing.h"
|
|
|
| @@ -145,43 +146,44 @@ class DataReductionProxyMetricsObserverTest
|
| is_using_lofi_ = is_using_lofi;
|
| NavigateAndCommit(GURL(kDefaultTestUrl));
|
| SimulateTimingUpdate(timing_);
|
| pingback_client_->Reset();
|
|
|
| // Navigate again to force OnComplete, which happens when a new navigation
|
| // occurs.
|
| NavigateAndCommit(GURL(kDefaultTestUrl2));
|
| }
|
|
|
| - // Verify that, if expected is set, its value equals that of
|
| - // actual. Otherwise, if expected is unset, verify that actual is zero.
|
| + // Verify that, if expected and actual are set, their values are equal.
|
| + // Otherwise, verify that both are unset.
|
| void ExpectEqualOrUnset(const base::Optional<base::TimeDelta>& expected,
|
| - base::TimeDelta actual) {
|
| - if (expected) {
|
| - EXPECT_EQ(expected.value(), actual);
|
| + const base::Optional<base::TimeDelta>& actual) {
|
| + if (expected && actual) {
|
| + EXPECT_EQ(expected.value(), actual.value());
|
| } else {
|
| - EXPECT_TRUE(actual.is_zero());
|
| + EXPECT_TRUE(!expected);
|
| + EXPECT_TRUE(!actual);
|
| }
|
| }
|
|
|
| void ValidateTimes() {
|
| EXPECT_TRUE(pingback_client_->send_pingback_called());
|
| EXPECT_EQ(timing_.navigation_start,
|
| pingback_client_->timing()->navigation_start);
|
| ExpectEqualOrUnset(timing_.first_contentful_paint,
|
| - pingback_client_->timing()->first_contentful_paint);
|
| + pingback_client_->timing()->first_contentful_paint);
|
| ExpectEqualOrUnset(timing_.response_start,
|
| - pingback_client_->timing()->response_start);
|
| + pingback_client_->timing()->response_start);
|
| ExpectEqualOrUnset(timing_.load_event_start,
|
| - pingback_client_->timing()->load_event_start);
|
| + pingback_client_->timing()->load_event_start);
|
| ExpectEqualOrUnset(timing_.first_image_paint,
|
| - pingback_client_->timing()->first_image_paint);
|
| + pingback_client_->timing()->first_image_paint);
|
| }
|
|
|
| void ValidateHistograms() {
|
| ValidateHistogramsForSuffix(
|
| internal::kHistogramDOMContentLoadedEventFiredSuffix,
|
| timing_.dom_content_loaded_event_start);
|
| ValidateHistogramsForSuffix(internal::kHistogramFirstLayoutSuffix,
|
| timing_.first_layout);
|
| ValidateHistogramsForSuffix(internal::kHistogramLoadEventFiredSuffix,
|
| timing_.load_event_start);
|
|
|