| // Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "base/test/metrics/histogram_tester.h" |
| #include "chrome/browser/tab_contents/navigation_metrics_recorder.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| #include "chrome/test/base/in_process_browser_test.h" |
| #include "chrome/test/base/ui_test_utils.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/test/browser_test_utils.h" |
| #include "content/public/test/test_navigation_observer.h" |
| |
| namespace { |
| |
| typedef InProcessBrowserTest NavigationMetricsRecorderBrowserTest; |
| |
| IN_PROC_BROWSER_TEST_F(NavigationMetricsRecorderBrowserTest, TestMetrics) { |
| content::WebContents* web_contents = |
| browser()->tab_strip_model()->GetActiveWebContents(); |
| |
| NavigationMetricsRecorder* recorder = |
| content::WebContentsUserData<NavigationMetricsRecorder>::FromWebContents( |
| web_contents); |
| ASSERT_TRUE(recorder); |
| |
| base::HistogramTester histograms; |
| ui_test_utils::NavigateToURL(browser(), |
| GURL("data:text/html, <html></html>")); |
| histograms.ExpectTotalCount("Navigation.MainFrameScheme", 1); |
| histograms.ExpectBucketCount("Navigation.MainFrameScheme", 5 /* data: */, 1); |
| histograms.ExpectTotalCount("Navigation.MainFrameSchemeDifferentPage", 1); |
| histograms.ExpectBucketCount("Navigation.MainFrameSchemeDifferentPage", |
| 5 /* data: */, 1); |
| } |
| |
| } // namespace |