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

Unified Diff: chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer_unittest.cc

Issue 1984173002: Log First User Interaction in Page Load Metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add tests for from_gws PLMO Created 4 years, 7 months 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: 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 3d122db42221064533aab149fd85181c9efcdf19..b5d10e04e72343740312f305f0e171686ad14783 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
@@ -25,6 +25,22 @@ class FromGWSPageLoadMetricsObserverTest
timing.navigation_start = base::Time::FromDoubleT(1);
SimulateTimingUpdate(timing);
}
+ void SimulateTimingWithFirstPaint() {
Bryan McQuade 2016/05/31 20:33:29 nit: please add a newline between each function
+ page_load_metrics::PageLoadTiming timing;
+ timing.navigation_start = base::Time::FromDoubleT(1);
+ timing.first_paint = base::TimeDelta::FromMilliseconds(1);
+ PopulateRequiredTimingFields(&timing);
+ SimulateTimingUpdate(timing);
+ }
+ void SimulateMouseEvent() {
Bryan McQuade 2016/05/31 20:33:29 same
+ blink::WebMouseEvent mouse_event;
+ mouse_event.type = blink::WebInputEvent::MouseDown;
+ mouse_event.button = blink::WebMouseEvent::ButtonLeft;
+ mouse_event.x = 7;
+ mouse_event.y = 7;
+ mouse_event.clickCount = 1;
+ SimulateInputEvent(mouse_event);
+ }
};
class FromGWSPageLoadMetricsLoggerTest : public testing::Test {};
@@ -573,6 +589,61 @@ TEST_F(FromGWSPageLoadMetricsObserverTest, NoAbortNewNavigationAfterPaint) {
internal::kHistogramFromGWSAbortNewNavigationBeforePaint, 0);
}
+TEST_F(FromGWSPageLoadMetricsObserverTest, NewNavigationBeforeInteraction) {
+ NavigateAndCommit(GURL(kGoogleSearchResultsUrl));
+ NavigateAndCommit(GURL("http://example.test"));
+ SimulateTimingWithFirstPaint();
+ // Simulate the user performing another navigation before paint.
+ NavigateAndCommit(GURL("https://www.example.com"));
+ histogram_tester().ExpectTotalCount(
+ internal::kHistogramFromGWSAbortNewNavigationBeforeInteraction, 1);
+}
+
+TEST_F(FromGWSPageLoadMetricsObserverTest, StopBeforeInteraction) {
+ NavigateAndCommit(GURL(kGoogleSearchResultsUrl));
+ NavigateAndCommit(GURL("http://example.test"));
+ SimulateTimingWithFirstPaint();
+ // Simulate the user pressing the stop button.
+ web_contents()->Stop();
+ // Now close the tab. This will trigger logging for the prior navigation which
+ // was stopped above.
+ DeleteContents();
+ histogram_tester().ExpectTotalCount(
+ internal::kHistogramFromGWSAbortStopBeforeInteraction, 1);
+}
+
+TEST_F(FromGWSPageLoadMetricsObserverTest, CloseBeforeInteraction) {
+ NavigateAndCommit(GURL(kGoogleSearchResultsUrl));
+ NavigateAndCommit(GURL("https://example.test"));
+ SimulateTimingWithFirstPaint();
+ // Simulate closing the tab.
+ DeleteContents();
+ histogram_tester().ExpectTotalCount(
+ internal::kHistogramFromGWSAbortCloseBeforeInteraction, 1);
+}
+
+TEST_F(FromGWSPageLoadMetricsObserverTest, CloseBeforePaintAndInteraction) {
+ NavigateAndCommit(GURL(kGoogleSearchResultsUrl));
+ NavigateAndCommit(GURL("https://example.test"));
+ SimulateTimingWithoutPaint();
+ // Simulate closing the tab.
+ DeleteContents();
+ histogram_tester().ExpectTotalCount(
+ internal::kHistogramFromGWSAbortCloseBeforeInteraction, 0);
+}
+
+TEST_F(FromGWSPageLoadMetricsObserverTest, CloseAfterInteraction) {
+ NavigateAndCommit(GURL(kGoogleSearchResultsUrl));
+ NavigateAndCommit(GURL("https://example.test"));
+ SimulateTimingWithFirstPaint();
+ // Simulate user interaction.
+ SimulateMouseEvent();
+ // Simulate closing the tab.
+ DeleteContents();
+ histogram_tester().ExpectTotalCount(
+ internal::kHistogramFromGWSAbortCloseBeforeInteraction, 0);
+}
+
TEST_F(FromGWSPageLoadMetricsLoggerTest, IsGoogleSearchHostname) {
struct {
bool expected_result;

Powered by Google App Engine
This is Rietveld 408576698