Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2032)

Unified Diff: content/renderer/render_thread_impl_unittest.cc

Issue 10828342: Per-host V8 histograms. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: lame fix attempt for V8ValueConverterImplTest.BasicRoundTrip Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_thread_impl.cc ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_thread_impl_unittest.cc
diff --git a/content/renderer/render_thread_impl_unittest.cc b/content/renderer/render_thread_impl_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..44b3a7cb72f8ab4b96bfe2b795b1ac61348b678b
--- /dev/null
+++ b/content/renderer/render_thread_impl_unittest.cc
@@ -0,0 +1,78 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/render_thread_impl.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+#include <string>
+
+class RenderThreadImplUnittest : public testing::Test {
+ public:
+ RenderThreadImplUnittest()
+ : kCustomizableHistogram_("Histogram1"),
+ kNormalHistogram_("Histogram2") {}
+ ~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) {
+ // First there is no page -> no custom histograms.
+ 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) {
+ // First there is only one view.
+ histogram_customizer_.RenderViewNavigatedToHost("mail.google.com", 1);
+ // Second view created and it navigates to the same host -> we can have a
+ // custom diagram.
+ histogram_customizer_.RenderViewNavigatedToHost("mail.google.com", 2);
+ EXPECT_EQ(std::string(kCustomizableHistogram_) + ".gmail",
+ histogram_customizer_.ConvertToCustomHistogramName(
+ kCustomizableHistogram_));
+ EXPECT_EQ(kNormalHistogram_,
+ histogram_customizer_.ConvertToCustomHistogramName(
+ kNormalHistogram_));
+ // Now the views diverge (one of them navigates to a different host) -> no
+ // custom diagram.
+ histogram_customizer_.RenderViewNavigatedToHost("docs.google.com", 2);
+ EXPECT_EQ(kCustomizableHistogram_,
+ histogram_customizer_.ConvertToCustomHistogramName(
+ kCustomizableHistogram_));
+ // After this point, there will never be a custom diagram again, even if the
+ // view navigated back to the common host.
+ histogram_customizer_.RenderViewNavigatedToHost("mail.google.com", 2);
+ EXPECT_EQ(kCustomizableHistogram_,
+ histogram_customizer_.ConvertToCustomHistogramName(
+ kCustomizableHistogram_));
+}
« no previous file with comments | « content/renderer/render_thread_impl.cc ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698