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

Side by Side Diff: chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_observer_unittest.cc

Issue 2139143002: Standardize which page loads are tracked (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add tests Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_ob server.h" 5 #include "chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_ob server.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_ test_harness.h" 8 #include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_ test_harness.h"
9 9
10 class AbortsPageLoadMetricsObserverTest 10 class AbortsPageLoadMetricsObserverTest
(...skipping 11 matching lines...) Expand all
22 }; 22 };
23 23
24 TEST_F(AbortsPageLoadMetricsObserverTest, UnknownNavigationBeforeCommit) { 24 TEST_F(AbortsPageLoadMetricsObserverTest, UnknownNavigationBeforeCommit) {
25 StartNavigation(GURL("https://www.google.com")); 25 StartNavigation(GURL("https://www.google.com"));
26 // Simulate the user performing another navigation before commit. 26 // Simulate the user performing another navigation before commit.
27 NavigateAndCommit(GURL("https://www.example.com")); 27 NavigateAndCommit(GURL("https://www.example.com"));
28 histogram_tester().ExpectTotalCount( 28 histogram_tester().ExpectTotalCount(
29 internal::kHistogramAbortUnknownNavigationBeforeCommit, 1); 29 internal::kHistogramAbortUnknownNavigationBeforeCommit, 1);
30 } 30 }
31 31
32 TEST_F(AbortsPageLoadMetricsObserverTest,
33 UnknownProvisionalNavigationBeforeCommit) {
34 StartNavigation(GURL("https://www.google.com"));
35 StartNavigation(GURL("https://www.example.com"));
36 histogram_tester().ExpectTotalCount(
37 internal::kHistogramAbortUnknownNavigationBeforeCommit, 1);
38 }
39
40 TEST_F(AbortsPageLoadMetricsObserverTest,
41 UnknownNavigationBeforeCommitNonTrackedPageLoad) {
42 StartNavigation(GURL("https://www.google.com"));
43 // Simulate the user performing another navigation before commit. Navigate to
44 // an untracked URL, to verify that we still log abort metrics even if the new
45 // navigation isn't tracked.
46 NavigateAndCommit(GURL("about:blank"));
47 histogram_tester().ExpectTotalCount(
48 internal::kHistogramAbortUnknownNavigationBeforeCommit, 1);
49 }
50
32 TEST_F(AbortsPageLoadMetricsObserverTest, NewNavigationBeforePaint) { 51 TEST_F(AbortsPageLoadMetricsObserverTest, NewNavigationBeforePaint) {
33 NavigateAndCommit(GURL("https://www.google.com")); 52 NavigateAndCommit(GURL("https://www.google.com"));
34 SimulateTimingWithoutPaint(); 53 SimulateTimingWithoutPaint();
35 // Simulate the user performing another navigation before paint. 54 // Simulate the user performing another navigation before paint.
36 NavigateAndCommit(GURL("https://www.example.com")); 55 NavigateAndCommit(GURL("https://www.example.com"));
37 histogram_tester().ExpectTotalCount( 56 histogram_tester().ExpectTotalCount(
38 internal::kHistogramAbortNewNavigationBeforePaint, 1); 57 internal::kHistogramAbortNewNavigationBeforePaint, 1);
39 histogram_tester().ExpectTotalCount( 58 histogram_tester().ExpectTotalCount(
40 internal::kHistogramAbortReloadBeforePaint, 0); 59 internal::kHistogramAbortReloadBeforePaint, 0);
41 histogram_tester().ExpectTotalCount( 60 histogram_tester().ExpectTotalCount(
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 211
193 NavigateAndCommit(GURL("https://www.example.com")); 212 NavigateAndCommit(GURL("https://www.example.com"));
194 213
195 base::HistogramTester::CountsMap counts_map = 214 base::HistogramTester::CountsMap counts_map =
196 histogram_tester().GetTotalCountsForPrefix( 215 histogram_tester().GetTotalCountsForPrefix(
197 internal::kHistogramAbortNewNavigationBeforePaint); 216 internal::kHistogramAbortNewNavigationBeforePaint);
198 217
199 EXPECT_TRUE(counts_map.empty() || 218 EXPECT_TRUE(counts_map.empty() ||
200 (counts_map.size() == 1 && counts_map.begin()->second == 1)); 219 (counts_map.size() == 1 && counts_map.begin()->second == 1));
201 } 220 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/observers/https_engagement_metrics/https_engagement_page_load_metrics_observer_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698