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

Side by Side Diff: chrome/browser/page_load_metrics/metrics_web_contents_observer_unittest.cc

Issue 2189543002: Notify page load metrics when the app enters the background. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clankbackgroundcallback
Patch Set: fix histogram description Created 4 years, 4 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 (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
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
OLDNEW
« no previous file with comments | « chrome/browser/page_load_metrics/metrics_web_contents_observer.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698