[safe_browsing] Remove unused ContainsBrowseUrl() parameter.
[chromium-blink-merge.git] / content / renderer / render_thread_impl_unittest.cc
blob89cafc16b7a7e589851ed0a14106eac6fb65f048
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 virtual ~RenderThreadImplUnittest() {}
18 protected:
19 virtual void SetUp() OVERRIDE {
20 histogram_customizer_.custom_histograms_.clear();
21 histogram_customizer_.custom_histograms_.insert(kCustomizableHistogram_);
23 RenderThreadImpl::HistogramCustomizer histogram_customizer_;
24 const char* kCustomizableHistogram_;
25 const char* kNormalHistogram_;
28 TEST_F(RenderThreadImplUnittest, CustomHistogramsWithNoNavigations) {
29 // First there is no page -> no custom histograms.
30 EXPECT_EQ(kCustomizableHistogram_,
31 histogram_customizer_.ConvertToCustomHistogramName(
32 kCustomizableHistogram_));
33 EXPECT_EQ(kNormalHistogram_,
34 histogram_customizer_.ConvertToCustomHistogramName(
35 kNormalHistogram_));
38 TEST_F(RenderThreadImplUnittest, CustomHistogramsForOneRenderView) {
39 histogram_customizer_.RenderViewNavigatedToHost("mail.google.com", 1);
40 EXPECT_EQ(std::string(kCustomizableHistogram_) + ".gmail",
41 histogram_customizer_.ConvertToCustomHistogramName(
42 kCustomizableHistogram_));
43 EXPECT_EQ(kNormalHistogram_,
44 histogram_customizer_.ConvertToCustomHistogramName(
45 kNormalHistogram_));
46 histogram_customizer_.RenderViewNavigatedToHost("docs.google.com", 1);
47 EXPECT_EQ(std::string(kCustomizableHistogram_) + ".docs",
48 histogram_customizer_.ConvertToCustomHistogramName(
49 kCustomizableHistogram_));
50 histogram_customizer_.RenderViewNavigatedToHost("nottracked.com", 1);
51 EXPECT_EQ(kCustomizableHistogram_,
52 histogram_customizer_.ConvertToCustomHistogramName(
53 kCustomizableHistogram_));
56 TEST_F(RenderThreadImplUnittest, CustomHistogramsForTwoRenderViews) {
57 // First there is only one view.
58 histogram_customizer_.RenderViewNavigatedToHost("mail.google.com", 1);
59 // Second view created and it navigates to the same host -> we can have a
60 // custom diagram.
61 histogram_customizer_.RenderViewNavigatedToHost("mail.google.com", 2);
62 EXPECT_EQ(std::string(kCustomizableHistogram_) + ".gmail",
63 histogram_customizer_.ConvertToCustomHistogramName(
64 kCustomizableHistogram_));
65 EXPECT_EQ(kNormalHistogram_,
66 histogram_customizer_.ConvertToCustomHistogramName(
67 kNormalHistogram_));
68 // Now the views diverge (one of them navigates to a different host) -> no
69 // custom diagram.
70 histogram_customizer_.RenderViewNavigatedToHost("docs.google.com", 2);
71 EXPECT_EQ(kCustomizableHistogram_,
72 histogram_customizer_.ConvertToCustomHistogramName(
73 kCustomizableHistogram_));
74 // After this point, there will never be a custom diagram again, even if the
75 // view navigated back to the common host.
76 histogram_customizer_.RenderViewNavigatedToHost("mail.google.com", 2);
77 EXPECT_EQ(kCustomizableHistogram_,
78 histogram_customizer_.ConvertToCustomHistogramName(
79 kCustomizableHistogram_));
82 } // namespace content