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 6bf40fab5c8d4e28298f11ee0cb8af90fb8f8dc7..c880529749327509de5615c8350e8dab12951029 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 |
@@ -7,6 +7,7 @@ |
#include "base/macros.h" |
#include "base/memory/ptr_util.h" |
#include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_test_harness.h" |
+#include "components/page_load_metrics/browser/page_load_metrics_util.h" |
namespace { |
const char kExampleUrl[] = "http://www.example.com/"; |
@@ -347,13 +348,25 @@ TEST_F(FromGWSPageLoadMetricsObserverTest, |
SimulateTimingUpdate(timing); |
web_contents()->WasHidden(); |
+ // If the system clock is low resolution |
Charlie Harrison
2016/05/19 18:20:48
Can fit more words into comment.
shivanisha
2016/05/23 15:06:43
done.
|
+ // PageLoadTracker's background_time_ may be < timing.first_text_paint. |
+ page_load_metrics::PageLoadExtraInfo info = |
+ GetPageLoadExtraInfoCommittedLoad(); |
+ |
// Navigate again to force logging. |
NavigateAndCommit(GURL("https://www.final.com")); |
- histogram_tester().ExpectTotalCount(internal::kHistogramFromGWSFirstTextPaint, |
- 1); |
- histogram_tester().ExpectBucketCount( |
- internal::kHistogramFromGWSFirstTextPaint, |
- timing.first_text_paint.InMilliseconds(), 1); |
+ |
+ if (page_load_metrics::WasStartedInForegroundEventInForeground( |
+ timing.first_text_paint, info)) { |
+ histogram_tester().ExpectTotalCount( |
+ internal::kHistogramFromGWSFirstTextPaint, 1); |
+ histogram_tester().ExpectBucketCount( |
+ internal::kHistogramFromGWSFirstTextPaint, |
+ timing.first_text_paint.InMilliseconds(), 1); |
+ } else { |
+ histogram_tester().ExpectTotalCount( |
+ internal::kHistogramFromGWSFirstTextPaint, 0); |
+ } |
} |
TEST_F(FromGWSPageLoadMetricsObserverTest, UnknownNavigationBeforeCommit) { |
@@ -516,9 +529,22 @@ TEST_F(FromGWSPageLoadMetricsObserverTest, NoAbortNewNavigationAfterPaint) { |
PopulateRequiredTimingFields(&timing); |
NavigateAndCommit(GURL("https://example.test")); |
SimulateTimingUpdate(timing); |
+ |
+ // If the system clock is low resolution |
Charlie Harrison
2016/05/19 18:20:48
Ditto. Also can you update the explanation about t
shivanisha
2016/05/23 15:06:43
done. Also updated in aborts*unit_test
|
+ // PageLoadTracker's abort time may be <= first_paint. |
+ // In that case the histogram will be logged else it will not be logged. This |
+ // is a case where we cannot retrieve the above navigation's abort time |
+ // in the test since it will be computed and destroyed in the following |
+ // NavigateAndCommit call, thus both 0 and 1 counts of histograms is |
+ // considered good. |
+ |
NavigateAndCommit(GURL("https://example.test2")); |
- histogram_tester().ExpectTotalCount( |
- internal::kHistogramFromGWSAbortNewNavigationBeforePaint, 0); |
+ |
+ base::HistogramTester::CountsMap counts_map = |
+ histogram_tester().GetTotalCountsForPrefix( |
+ internal::kHistogramFromGWSAbortNewNavigationBeforePaint); |
+ |
+ EXPECT_TRUE(counts_map.empty() || counts_map.begin()->second == 1); |
} |
TEST_F(FromGWSPageLoadMetricsLoggerTest, IsGoogleSearchHostname) { |