blob: de09f6c5a67b196b0bceede1751d958fe7bf0b4d [file] [log] [blame]
jahagird2fd0d882017-03-06 22:58:531// Copyright 2017 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "components/navigation_metrics/navigation_metrics.h"
6
7#include "base/test/histogram_tester.h"
8#include "testing/gtest/include/gtest/gtest.h"
9#include "url/gurl.h"
10
11namespace {
12const char* const kTestUrl = "http://www.example.com";
13const char* const kMainFrameScheme = "Navigation.MainFrameScheme";
14const char* const kMainFrameSchemeDifferentPage =
15 "Navigation.MainFrameSchemeDifferentPage";
16
17} // namespace
18
19namespace navigation_metrics {
20
21TEST(NavigationMetrics, MainFrameSchemeDifferentPage) {
22 base::HistogramTester test;
23
24 RecordMainFrameNavigation(GURL(kTestUrl), false, false, false);
25
26 test.ExpectTotalCount(kMainFrameScheme, 1);
27 test.ExpectUniqueSample(kMainFrameScheme, 1 /* http */, 1);
28 test.ExpectTotalCount(kMainFrameSchemeDifferentPage, 1);
29 test.ExpectUniqueSample(kMainFrameSchemeDifferentPage, 1 /* http */, 1);
30}
31
32TEST(NavigationMetrics, MainFrameSchemeSamePage) {
33 base::HistogramTester test;
34
35 RecordMainFrameNavigation(GURL(kTestUrl), true, false, false);
36
37 test.ExpectTotalCount(kMainFrameScheme, 1);
38 test.ExpectUniqueSample(kMainFrameScheme, 1 /* http */, 1);
39 test.ExpectTotalCount(kMainFrameSchemeDifferentPage, 0);
40}
41
42} // namespace navigation_metrics