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 "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" | 5 #include "chrome/browser/page_load_metrics/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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 web_contents_tester->StartNavigation(GURL(kDefaultTestUrl)); | 465 web_contents_tester->StartNavigation(GURL(kDefaultTestUrl)); |
466 rfh_tester->SimulateNavigationError(GURL(kDefaultTestUrl), net::ERR_ABORTED); | 466 rfh_tester->SimulateNavigationError(GURL(kDefaultTestUrl), net::ERR_ABORTED); |
467 rfh_tester->SimulateNavigationStop(); | 467 rfh_tester->SimulateNavigationStop(); |
468 | 468 |
469 web_contents()->Stop(); | 469 web_contents()->Stop(); |
470 | 470 |
471 histogram_tester_.ExpectTotalCount(internal::kAbortChainSizeNoCommit, 1); | 471 histogram_tester_.ExpectTotalCount(internal::kAbortChainSizeNoCommit, 1); |
472 histogram_tester_.ExpectBucketCount(internal::kAbortChainSizeNoCommit, 3, 1); | 472 histogram_tester_.ExpectBucketCount(internal::kAbortChainSizeNoCommit, 3, 1); |
473 } | 473 } |
474 | 474 |
| 475 TEST_F(MetricsWebContentsObserverTest, FlushMetricsOnAppEnterBackground) { |
| 476 content::WebContentsTester* web_contents_tester = |
| 477 content::WebContentsTester::For(web_contents()); |
| 478 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl)); |
| 479 |
| 480 histogram_tester_.ExpectTotalCount( |
| 481 internal::kPageLoadCompletedAfterAppBackground, 0); |
| 482 |
| 483 observer_->FlushMetricsOnAppEnterBackground(); |
| 484 |
| 485 histogram_tester_.ExpectTotalCount( |
| 486 internal::kPageLoadCompletedAfterAppBackground, 1); |
| 487 histogram_tester_.ExpectBucketCount( |
| 488 internal::kPageLoadCompletedAfterAppBackground, false, 1); |
| 489 histogram_tester_.ExpectBucketCount( |
| 490 internal::kPageLoadCompletedAfterAppBackground, true, 0); |
| 491 |
| 492 observer_.reset(); |
| 493 |
| 494 histogram_tester_.ExpectTotalCount( |
| 495 internal::kPageLoadCompletedAfterAppBackground, 2); |
| 496 histogram_tester_.ExpectBucketCount( |
| 497 internal::kPageLoadCompletedAfterAppBackground, false, 1); |
| 498 histogram_tester_.ExpectBucketCount( |
| 499 internal::kPageLoadCompletedAfterAppBackground, true, 1); |
| 500 } |
| 501 |
475 } // namespace page_load_metrics | 502 } // namespace page_load_metrics |
OLD | NEW |