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

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

Issue 1476503004: [page_load_metrics] User Initiated Abort Tracking (Observer version) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new_observer
Patch Set: Remove dcheck for STILL_RUNNING Created 5 years 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 "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 "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/process/kill.h" 8 #include "base/process/kill.h"
9 #include "base/test/histogram_tester.h" 9 #include "base/test/histogram_tester.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 content::RenderFrameHostTester* rfh_tester = 467 content::RenderFrameHostTester* rfh_tester =
468 content::RenderFrameHostTester::For(main_rfh()); 468 content::RenderFrameHostTester::For(main_rfh());
469 rfh_tester->SimulateNavigationError(GURL(kDefaultTestUrl), net::ERR_ABORTED); 469 rfh_tester->SimulateNavigationError(GURL(kDefaultTestUrl), net::ERR_ABORTED);
470 rfh_tester->SimulateNavigationStop(); 470 rfh_tester->SimulateNavigationStop();
471 471
472 CheckProvisionalEvent(PROVISIONAL_LOAD_ERR_FAILED_NON_ABORT, 0, false); 472 CheckProvisionalEvent(PROVISIONAL_LOAD_ERR_FAILED_NON_ABORT, 0, false);
473 CheckProvisionalEvent(PROVISIONAL_LOAD_ERR_ABORTED, 1, false); 473 CheckProvisionalEvent(PROVISIONAL_LOAD_ERR_ABORTED, 1, false);
474 CheckTotalEvents(); 474 CheckTotalEvents();
475 } 475 }
476 476
477 TEST_F(MetricsWebContentsObserverTest, BackgroundBeforePaint) {
478 page_load_metrics::PageLoadTiming timing;
479 timing.navigation_start = base::Time::FromDoubleT(1);
480 timing.first_paint = base::TimeDelta::FromSeconds(10);
481 content::WebContentsTester* web_contents_tester =
482 content::WebContentsTester::For(web_contents());
483 web_contents_tester->NavigateAndCommit(GURL("https://www.google.com"));
484 // Background the tab and go for a coffee or something.
485 observer_->WasHidden();
486 observer_->OnMessageReceived(
487 PageLoadMetricsMsg_TimingUpdated(observer_->routing_id(), timing),
488 main_rfh());
489 // Come back and start browsing again.
490 observer_->WasShown();
491 // Simulate the user performaning another navigation.
492 web_contents_tester->NavigateAndCommit(GURL("https://www.example.com"));
493 histogram_tester_.ExpectTotalCount(kHistogramBackgroundBeforePaint, 1);
494 }
495
477 TEST_F(MetricsWebContentsObserverTest, AbortProvisionalLoadInBackground) { 496 TEST_F(MetricsWebContentsObserverTest, AbortProvisionalLoadInBackground) {
478 content::WebContentsTester* web_contents_tester = 497 content::WebContentsTester* web_contents_tester =
479 content::WebContentsTester::For(web_contents()); 498 content::WebContentsTester::For(web_contents());
480 499
481 observer_->WasHidden(); 500 observer_->WasHidden();
482 web_contents_tester->StartNavigation(GURL(kDefaultTestUrl)); 501 web_contents_tester->StartNavigation(GURL(kDefaultTestUrl));
483 content::RenderFrameHostTester* rfh_tester = 502 content::RenderFrameHostTester* rfh_tester =
484 content::RenderFrameHostTester::For(main_rfh()); 503 content::RenderFrameHostTester::For(main_rfh());
485 rfh_tester->SimulateNavigationError(GURL(kDefaultTestUrl), net::ERR_ABORTED); 504 rfh_tester->SimulateNavigationError(GURL(kDefaultTestUrl), net::ERR_ABORTED);
486 rfh_tester->SimulateNavigationStop(); 505 rfh_tester->SimulateNavigationStop();
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 EXPECT_NE(string_it, sample_obj->string_fields.end()); 730 EXPECT_NE(string_it, sample_obj->string_fields.end());
712 EXPECT_EQ(rappor::GetDomainAndRegistrySampleFromGURL(GURL(kDefaultTestUrl)), 731 EXPECT_EQ(rappor::GetDomainAndRegistrySampleFromGURL(GURL(kDefaultTestUrl)),
713 string_it->second); 732 string_it->second);
714 733
715 const auto& flag_it = sample_obj->flag_fields.find("IsSlow"); 734 const auto& flag_it = sample_obj->flag_fields.find("IsSlow");
716 EXPECT_NE(flag_it, sample_obj->flag_fields.end()); 735 EXPECT_NE(flag_it, sample_obj->flag_fields.end());
717 EXPECT_EQ(0u, flag_it->second); 736 EXPECT_EQ(0u, flag_it->second);
718 } 737 }
719 738
720 } // namespace page_load_metrics 739 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698