OLD | NEW |
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/from_gws_page_load_metrics_
observer.h" | 5 #include "chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_
observer.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_
test_harness.h" | 9 #include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_
test_harness.h" |
10 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" | 10 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 internal::kHistogramFromGWSFirstTextPaint, 1); | 436 internal::kHistogramFromGWSFirstTextPaint, 1); |
437 histogram_tester().ExpectBucketCount( | 437 histogram_tester().ExpectBucketCount( |
438 internal::kHistogramFromGWSFirstTextPaint, | 438 internal::kHistogramFromGWSFirstTextPaint, |
439 timing.first_text_paint.value().InMilliseconds(), 1); | 439 timing.first_text_paint.value().InMilliseconds(), 1); |
440 } else { | 440 } else { |
441 histogram_tester().ExpectTotalCount( | 441 histogram_tester().ExpectTotalCount( |
442 internal::kHistogramFromGWSFirstTextPaint, 0); | 442 internal::kHistogramFromGWSFirstTextPaint, 0); |
443 } | 443 } |
444 } | 444 } |
445 | 445 |
446 TEST_F(FromGWSPageLoadMetricsObserverTest, UnknownNavigationBeforeCommit) { | 446 TEST_F(FromGWSPageLoadMetricsObserverTest, NewNavigationBeforeCommit) { |
447 NavigateAndCommit(GURL(kGoogleSearchResultsUrl)); | 447 NavigateAndCommit(GURL(kGoogleSearchResultsUrl)); |
448 StartNavigation(GURL("http://example.test")); | 448 StartNavigation(GURL("http://example.test")); |
449 | 449 |
450 // Simulate the user performing another navigation before commit. | 450 // Simulate the user performing another navigation before commit. |
451 StartNavigation(GURL("https://www.example.com")); | 451 NavigateAndCommit(GURL("https://www.example.com")); |
452 histogram_tester().ExpectTotalCount( | 452 histogram_tester().ExpectTotalCount( |
453 internal::kHistogramFromGWSAbortUnknownNavigationBeforeCommit, 1); | 453 internal::kHistogramFromGWSAbortNewNavigationBeforeCommit, 1); |
454 } | 454 } |
455 | 455 |
456 TEST_F(FromGWSPageLoadMetricsObserverTest, NewNavigationBeforePaint) { | 456 TEST_F(FromGWSPageLoadMetricsObserverTest, NewNavigationBeforePaint) { |
457 NavigateAndCommit(GURL(kGoogleSearchResultsUrl)); | 457 NavigateAndCommit(GURL(kGoogleSearchResultsUrl)); |
458 NavigateAndCommit(GURL("http://example.test")); | 458 NavigateAndCommit(GURL("http://example.test")); |
459 SimulateTimingWithoutPaint(); | 459 SimulateTimingWithoutPaint(); |
460 // Simulate the user performing another navigation before paint. | 460 // Simulate the user performing another navigation before paint. |
461 NavigateAndCommit(GURL("https://www.example.com")); | 461 NavigateAndCommit(GURL("https://www.example.com")); |
462 histogram_tester().ExpectTotalCount( | 462 histogram_tester().ExpectTotalCount( |
463 internal::kHistogramFromGWSAbortNewNavigationBeforePaint, 1); | 463 internal::kHistogramFromGWSAbortNewNavigationBeforePaint, 1); |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 logger.ShouldLogPostCommitMetrics(GURL("https://www.google.com/about/"))); | 912 logger.ShouldLogPostCommitMetrics(GURL("https://www.google.com/about/"))); |
913 } | 913 } |
914 | 914 |
915 TEST_F(FromGWSPageLoadMetricsLoggerTest, NavigationFromSearchRedirector) { | 915 TEST_F(FromGWSPageLoadMetricsLoggerTest, NavigationFromSearchRedirector) { |
916 FromGWSPageLoadMetricsLogger logger; | 916 FromGWSPageLoadMetricsLogger logger; |
917 logger.SetPreviouslyCommittedUrl( | 917 logger.SetPreviouslyCommittedUrl( |
918 GURL("https://www.google.com/url?source=web")); | 918 GURL("https://www.google.com/url?source=web")); |
919 logger.set_navigation_initiated_via_link(true); | 919 logger.set_navigation_initiated_via_link(true); |
920 ASSERT_TRUE(logger.ShouldLogPostCommitMetrics(GURL(kExampleUrl))); | 920 ASSERT_TRUE(logger.ShouldLogPostCommitMetrics(GURL(kExampleUrl))); |
921 } | 921 } |
OLD | NEW |