This source file includes following definitions.
- kNormalHistogram_
- SetUp
- TEST_F
- TEST_F
- TEST_F
#include "content/renderer/render_thread_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
#include <string>
namespace content {
class RenderThreadImplUnittest : public testing::Test {
public:
RenderThreadImplUnittest()
: kCustomizableHistogram_("Histogram1"),
kNormalHistogram_("Histogram2") {}
virtual ~RenderThreadImplUnittest() {}
protected:
virtual void SetUp() OVERRIDE {
histogram_customizer_.custom_histograms_.clear();
histogram_customizer_.custom_histograms_.insert(kCustomizableHistogram_);
}
RenderThreadImpl::HistogramCustomizer histogram_customizer_;
const char* kCustomizableHistogram_;
const char* kNormalHistogram_;
};
TEST_F(RenderThreadImplUnittest, CustomHistogramsWithNoNavigations) {
EXPECT_EQ(kCustomizableHistogram_,
histogram_customizer_.ConvertToCustomHistogramName(
kCustomizableHistogram_));
EXPECT_EQ(kNormalHistogram_,
histogram_customizer_.ConvertToCustomHistogramName(
kNormalHistogram_));
}
TEST_F(RenderThreadImplUnittest, CustomHistogramsForOneRenderView) {
histogram_customizer_.RenderViewNavigatedToHost("mail.google.com", 1);
EXPECT_EQ(std::string(kCustomizableHistogram_) + ".gmail",
histogram_customizer_.ConvertToCustomHistogramName(
kCustomizableHistogram_));
EXPECT_EQ(kNormalHistogram_,
histogram_customizer_.ConvertToCustomHistogramName(
kNormalHistogram_));
histogram_customizer_.RenderViewNavigatedToHost("docs.google.com", 1);
EXPECT_EQ(std::string(kCustomizableHistogram_) + ".docs",
histogram_customizer_.ConvertToCustomHistogramName(
kCustomizableHistogram_));
histogram_customizer_.RenderViewNavigatedToHost("nottracked.com", 1);
EXPECT_EQ(kCustomizableHistogram_,
histogram_customizer_.ConvertToCustomHistogramName(
kCustomizableHistogram_));
}
TEST_F(RenderThreadImplUnittest, CustomHistogramsForTwoRenderViews) {
histogram_customizer_.RenderViewNavigatedToHost("mail.google.com", 1);
histogram_customizer_.RenderViewNavigatedToHost("mail.google.com", 2);
EXPECT_EQ(std::string(kCustomizableHistogram_) + ".gmail",
histogram_customizer_.ConvertToCustomHistogramName(
kCustomizableHistogram_));
EXPECT_EQ(kNormalHistogram_,
histogram_customizer_.ConvertToCustomHistogramName(
kNormalHistogram_));
histogram_customizer_.RenderViewNavigatedToHost("docs.google.com", 2);
EXPECT_EQ(kCustomizableHistogram_,
histogram_customizer_.ConvertToCustomHistogramName(
kCustomizableHistogram_));
histogram_customizer_.RenderViewNavigatedToHost("mail.google.com", 2);
EXPECT_EQ(kCustomizableHistogram_,
histogram_customizer_.ConvertToCustomHistogramName(
kCustomizableHistogram_));
}
}