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

Unified Diff: components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc

Issue 1441393002: Add UMA to count the number of Google CAPTCHA pages shown and solved by users. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed to using histogram, updated test Created 5 years, 1 month 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
Index: components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc
diff --git a/components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc b/components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc
index de5431f8f1e43b2c86523cc5b6def588104a4667..a61f585862e12f97d932edb82788615cfcd0399b 100644
--- a/components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc
+++ b/components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc
@@ -7,10 +7,12 @@
#include "base/memory/scoped_ptr.h"
#include "base/process/kill.h"
#include "base/test/histogram_tester.h"
+#include "base/test/user_action_tester.h"
#include "base/time/time.h"
#include "components/page_load_metrics/common/page_load_metrics_messages.h"
#include "components/rappor/rappor_utils.h"
#include "components/rappor/test_rappor_service.h"
+#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/test/test_renderer_host.h"
@@ -97,6 +99,7 @@ class MetricsWebContentsObserverTest
protected:
base::HistogramTester histogram_tester_;
+ base::UserActionTester user_action_tester_;
rappor::TestRapporService rappor_tester_;
scoped_ptr<MetricsWebContentsObserver> observer_;
@@ -676,4 +679,23 @@ TEST_F(MetricsWebContentsObserverTest, RapporQuickPageLoad) {
EXPECT_EQ(0u, flag_it->second);
}
+TEST_F(MetricsWebContentsObserverTest, IsGoogleCaptcha) {
+ struct {
+ std::string url;
+ bool expected;
+ } test_cases[] = {
+ {"", false},
+ {"http://www.google.com/", false},
+ {"http://www.cnn.com/", false},
+ {"http://ipv4.google.com/", false},
+ {"https://ipv4.google.com/sorry/IndexRedirect?continue=http://a", true},
+ {"https://ipv6.google.com/sorry/IndexRedirect?continue=http://a", true},
+ {"https://ipv7.google.com/sorry/IndexRedirect?continue=http://a", false},
+ };
+ for (const auto& test : test_cases) {
+ EXPECT_EQ(test.expected, IsGoogleCaptcha(GURL(test.url)))
+ << "for URL: " << test.url;
+ }
+}
+
} // namespace page_load_metrics

Powered by Google App Engine
This is Rietveld 408576698