| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/navigation_metrics/navigation_metrics.h" | 5 #include "components/navigation_metrics/navigation_metrics.h" |
| 6 | 6 |
| 7 #include "base/test/histogram_tester.h" | 7 #include "base/test/histogram_tester.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "url/gurl.h" | 9 #include "url/gurl.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 const char* const kTestUrl = "http://www.example.com"; | 12 const char* const kTestUrl = "http://www.example.com"; |
| 13 const char* const kMainFrameScheme = "Navigation.MainFrameScheme"; | 13 const char* const kMainFrameScheme = "Navigation.MainFrameScheme"; |
| 14 const char* const kMainFrameSchemeDifferentPage = | 14 const char* const kMainFrameSchemeDifferentPage = |
| 15 "Navigation.MainFrameSchemeDifferentPage"; | 15 "Navigation.MainFrameSchemeDifferentPage"; |
| 16 | 16 |
| 17 } // namespace | 17 } // namespace |
| 18 | 18 |
| 19 namespace navigation_metrics { | 19 namespace navigation_metrics { |
| 20 | 20 |
| 21 TEST(NavigationMetrics, MainFrameSchemeDifferentDocument) { | 21 TEST(NavigationMetrics, MainFrameSchemeDifferentDocument) { |
| 22 base::HistogramTester test; | 22 base::HistogramTester test; |
| 23 | 23 |
| 24 RecordMainFrameNavigation(GURL(kTestUrl), false, false, false); | 24 RecordMainFrameNavigation(GURL(kTestUrl), false, false); |
| 25 | 25 |
| 26 test.ExpectTotalCount(kMainFrameScheme, 1); | 26 test.ExpectTotalCount(kMainFrameScheme, 1); |
| 27 test.ExpectUniqueSample(kMainFrameScheme, 1 /* http */, 1); | 27 test.ExpectUniqueSample(kMainFrameScheme, 1 /* http */, 1); |
| 28 test.ExpectTotalCount(kMainFrameSchemeDifferentPage, 1); | 28 test.ExpectTotalCount(kMainFrameSchemeDifferentPage, 1); |
| 29 test.ExpectUniqueSample(kMainFrameSchemeDifferentPage, 1 /* http */, 1); | 29 test.ExpectUniqueSample(kMainFrameSchemeDifferentPage, 1 /* http */, 1); |
| 30 } | 30 } |
| 31 | 31 |
| 32 TEST(NavigationMetrics, MainFrameSchemeSameDocument) { | 32 TEST(NavigationMetrics, MainFrameSchemeSameDocument) { |
| 33 base::HistogramTester test; | 33 base::HistogramTester test; |
| 34 | 34 |
| 35 RecordMainFrameNavigation(GURL(kTestUrl), true, false, false); | 35 RecordMainFrameNavigation(GURL(kTestUrl), true, false); |
| 36 | 36 |
| 37 test.ExpectTotalCount(kMainFrameScheme, 1); | 37 test.ExpectTotalCount(kMainFrameScheme, 1); |
| 38 test.ExpectUniqueSample(kMainFrameScheme, 1 /* http */, 1); | 38 test.ExpectUniqueSample(kMainFrameScheme, 1 /* http */, 1); |
| 39 test.ExpectTotalCount(kMainFrameSchemeDifferentPage, 0); | 39 test.ExpectTotalCount(kMainFrameSchemeDifferentPage, 0); |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace navigation_metrics | 42 } // namespace navigation_metrics |
| OLD | NEW |