Fix a couple bugs in the settings_page_header wrt breadcrumbs.
[chromium-blink-merge.git] / content / renderer / render_thread_impl_unittest.cc
blob659eba4410ef8f447565d639ce88aca3d93ccbd3
1 // Copyright (c) 2012 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.
5 #include "content/renderer/render_thread_impl.h"
6 #include "testing/gtest/include/gtest/gtest.h"
8 #include <string>
10 namespace content {
12 class RenderThreadImplUnittest : public testing::Test {
13 public:
14 RenderThreadImplUnittest()
15 : kCustomizableHistogram_("Histogram1"),
16 kNormalHistogram_("Histogram2") {}
17 ~RenderThreadImplUnittest() override {}
19 protected:
20 void SetUp() override {
21 histogram_customizer_.custom_histograms_.clear();
22 histogram_customizer_.custom_histograms_.insert(kCustomizableHistogram_);
24 RenderThreadImpl::HistogramCustomizer histogram_customizer_;
25 const char* kCustomizableHistogram_;
26 const char* kNormalHistogram_;
29 TEST_F(RenderThreadImplUnittest, CustomHistogramsWithNoNavigations) {
30 // First there is no page -> no custom histograms.
31 EXPECT_EQ(kCustomizableHistogram_,
32 histogram_customizer_.ConvertToCustomHistogramName(
33 kCustomizableHistogram_));
34 EXPECT_EQ(kNormalHistogram_,
35 histogram_customizer_.ConvertToCustomHistogramName(
36 kNormalHistogram_));
39 TEST_F(RenderThreadImplUnittest, CustomHistogramsForOneRenderView) {
40 histogram_customizer_.RenderViewNavigatedToHost("mail.google.com", 1);
41 EXPECT_EQ(std::string(kCustomizableHistogram_) + ".gmail",
42 histogram_customizer_.ConvertToCustomHistogramName(
43 kCustomizableHistogram_));
44 EXPECT_EQ(kNormalHistogram_,
45 histogram_customizer_.ConvertToCustomHistogramName(
46 kNormalHistogram_));
47 histogram_customizer_.RenderViewNavigatedToHost("docs.google.com", 1);
48 EXPECT_EQ(std::string(kCustomizableHistogram_) + ".docs",
49 histogram_customizer_.ConvertToCustomHistogramName(
50 kCustomizableHistogram_));
51 histogram_customizer_.RenderViewNavigatedToHost("nottracked.com", 1);
52 EXPECT_EQ(kCustomizableHistogram_,
53 histogram_customizer_.ConvertToCustomHistogramName(
54 kCustomizableHistogram_));
57 TEST_F(RenderThreadImplUnittest, CustomHistogramsForTwoRenderViews) {
58 // First there is only one view.
59 histogram_customizer_.RenderViewNavigatedToHost("mail.google.com", 1);
60 // Second view created and it navigates to the same host -> we can have a
61 // custom diagram.
62 histogram_customizer_.RenderViewNavigatedToHost("mail.google.com", 2);
63 EXPECT_EQ(std::string(kCustomizableHistogram_) + ".gmail",
64 histogram_customizer_.ConvertToCustomHistogramName(
65 kCustomizableHistogram_));
66 EXPECT_EQ(kNormalHistogram_,
67 histogram_customizer_.ConvertToCustomHistogramName(
68 kNormalHistogram_));
69 // Now the views diverge (one of them navigates to a different host) -> no
70 // custom diagram.
71 histogram_customizer_.RenderViewNavigatedToHost("docs.google.com", 2);
72 EXPECT_EQ(kCustomizableHistogram_,
73 histogram_customizer_.ConvertToCustomHistogramName(
74 kCustomizableHistogram_));
75 // After this point, there will never be a custom diagram again, even if the
76 // view navigated back to the common host.
77 histogram_customizer_.RenderViewNavigatedToHost("mail.google.com", 2);
78 EXPECT_EQ(kCustomizableHistogram_,
79 histogram_customizer_.ConvertToCustomHistogramName(
80 kCustomizableHistogram_));
83 } // namespace content