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

Unified Diff: components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc

Issue 1433533007: [page_load_metrics] Get navigation_start from NavigationHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@change-names-refactor
Patch Set: Update dependent patchset Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc
diff --git a/components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc b/components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc
index aee25156f79cc6894d28ee8828f3cd5b8ad2b302..6cd0915adec88c2640ea1eb914eb1b7a4fe64b84 100644
--- a/components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc
+++ b/components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc
@@ -282,8 +282,7 @@ TEST_F(MetricsWebContentsObserverTest, BackgroundDifferentHistogram) {
base::TimeDelta first_layout = base::TimeDelta::FromSeconds(2);
PageLoadTiming timing;
- timing.navigation_start = base::Time::FromDoubleT(
- (base::TimeTicks::Now() - base::TimeTicks::UnixEpoch()).InSecondsF());
+ timing.navigation_start = base::Time::FromDoubleT(1);
timing.first_layout = first_layout;
content::WebContentsTester* web_contents_tester =
@@ -319,11 +318,11 @@ TEST_F(MetricsWebContentsObserverTest, BackgroundDifferentHistogram) {
TEST_F(MetricsWebContentsObserverTest, OnlyBackgroundLaterEvents) {
PageLoadTiming timing;
- timing.navigation_start = base::Time::FromDoubleT(
- (base::TimeTicks::Now() - base::TimeTicks::UnixEpoch()).InSecondsF() - 1);
-
- timing.response_start = base::TimeDelta::FromMilliseconds(1);
- timing.dom_content_loaded_event_start = base::TimeDelta::FromMilliseconds(1);
+ timing.navigation_start = base::Time::FromDoubleT(1);
+ // Set these events at 1 microsecond so they are definitely occur before we
+ // background the tab later in the test.
+ timing.response_start = base::TimeDelta::FromMicroseconds(1);
+ timing.dom_content_loaded_event_start = base::TimeDelta::FromMicroseconds(1);
content::WebContentsTester* web_contents_tester =
content::WebContentsTester::For(web_contents());
@@ -365,7 +364,9 @@ TEST_F(MetricsWebContentsObserverTest, OnlyBackgroundLaterEvents) {
}
TEST_F(MetricsWebContentsObserverTest, DontBackgroundQuickerLoad) {
- base::TimeDelta first_layout = base::TimeDelta::FromMilliseconds(1);
+ // Set this event at 1 microsecond so it occurs before we foreground later in
+ // the test.
+ base::TimeDelta first_layout = base::TimeDelta::FromMicroseconds(1);
PageLoadTiming timing;
timing.navigation_start = base::Time::FromDoubleT(1);
@@ -393,7 +394,7 @@ TEST_F(MetricsWebContentsObserverTest, DontBackgroundQuickerLoad) {
main_rfh());
rfh_tester->SimulateNavigationStop();
- // Navigate again to see if the timing updated for a subframe message.
+ // Navigate again to see if the timing updated for the foregrounded load.
web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl));
histogram_tester_.ExpectTotalCount(kHistogramDomContentLoaded, 0);
@@ -541,9 +542,7 @@ TEST_F(MetricsWebContentsObserverTest, SuccessfulFirstLayoutInForegroundEvent) {
TEST_F(MetricsWebContentsObserverTest,
SuccessfulFirstLayoutInBackgroundEvent) {
PageLoadTiming timing;
- timing.navigation_start = base::Time::FromDoubleT(
- (base::TimeTicks::Now() - base::TimeTicks::UnixEpoch()).InSecondsF() - 1);
-
+ timing.navigation_start = base::Time::FromDoubleT(1);
timing.first_layout = base::TimeDelta::FromSeconds(30);
content::WebContentsTester* web_contents_tester =

Powered by Google App Engine
This is Rietveld 408576698