OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "components/page_load_metrics/browser/metrics_web_contents_observer.h" | 5 #include "components/page_load_metrics/browser/metrics_web_contents_observer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 rfh_tester->SimulateNavigationStop(); | 408 rfh_tester->SimulateNavigationStop(); |
409 | 409 |
410 web_contents_tester->StartNavigation(GURL(kDefaultTestUrl)); | 410 web_contents_tester->StartNavigation(GURL(kDefaultTestUrl)); |
411 rfh_tester->SimulateNavigationError(GURL(kDefaultTestUrl), net::ERR_ABORTED); | 411 rfh_tester->SimulateNavigationError(GURL(kDefaultTestUrl), net::ERR_ABORTED); |
412 rfh_tester->SimulateNavigationStop(); | 412 rfh_tester->SimulateNavigationStop(); |
413 | 413 |
414 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl2)); | 414 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl2)); |
415 histogram_tester_.ExpectTotalCount(internal::kAbortChainSizeNewNavigation, 1); | 415 histogram_tester_.ExpectTotalCount(internal::kAbortChainSizeNewNavigation, 1); |
416 histogram_tester_.ExpectBucketCount(internal::kAbortChainSizeNewNavigation, 3, | 416 histogram_tester_.ExpectBucketCount(internal::kAbortChainSizeNewNavigation, 3, |
417 1); | 417 1); |
418 CheckNoErrorEvents(); | 418 // The second and third navigation signal multiple aborted provisional loads. |
| 419 // This is due to us not calling WillStartNavigationRequest in unit tests. |
| 420 CheckErrorEvent(ERR_NAVIGATION_SIGNALS_MULIPLE_ABORTED_LOADS, 2); |
| 421 CheckTotalErrorEvents(); |
419 } | 422 } |
420 | 423 |
421 TEST_F(MetricsWebContentsObserverTest, LogAbortChainsSameURL) { | 424 TEST_F(MetricsWebContentsObserverTest, LogAbortChainsSameURL) { |
422 content::WebContentsTester* web_contents_tester = | 425 content::WebContentsTester* web_contents_tester = |
423 content::WebContentsTester::For(web_contents()); | 426 content::WebContentsTester::For(web_contents()); |
424 content::RenderFrameHostTester* rfh_tester = | 427 content::RenderFrameHostTester* rfh_tester = |
425 content::RenderFrameHostTester::For(main_rfh()); | 428 content::RenderFrameHostTester::For(main_rfh()); |
426 // Start and abort three loads before one finally commits. | 429 // Start and abort three loads before one finally commits. |
427 web_contents_tester->StartNavigation(GURL(kDefaultTestUrl)); | 430 web_contents_tester->StartNavigation(GURL(kDefaultTestUrl)); |
428 rfh_tester->SimulateNavigationError(GURL(kDefaultTestUrl), net::ERR_ABORTED); | 431 rfh_tester->SimulateNavigationError(GURL(kDefaultTestUrl), net::ERR_ABORTED); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 rfh_tester->SimulateNavigationStop(); | 466 rfh_tester->SimulateNavigationStop(); |
464 | 467 |
465 web_contents()->Stop(); | 468 web_contents()->Stop(); |
466 | 469 |
467 histogram_tester_.ExpectTotalCount(internal::kAbortChainSizeNoCommit, 1); | 470 histogram_tester_.ExpectTotalCount(internal::kAbortChainSizeNoCommit, 1); |
468 histogram_tester_.ExpectBucketCount(internal::kAbortChainSizeNoCommit, 3, | 471 histogram_tester_.ExpectBucketCount(internal::kAbortChainSizeNoCommit, 3, |
469 1); | 472 1); |
470 } | 473 } |
471 | 474 |
472 } // namespace page_load_metrics | 475 } // namespace page_load_metrics |
OLD | NEW |