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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/page_load_metrics/browser/metrics_web_contents_observer.h" 5 #include "components/page_load_metrics/browser/metrics_web_contents_observer.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/process/kill.h" 8 #include "base/process/kill.h"
9 #include "base/test/histogram_tester.h" 9 #include "base/test/histogram_tester.h"
10 #include "base/test/user_action_tester.h"
10 #include "base/time/time.h" 11 #include "base/time/time.h"
11 #include "components/page_load_metrics/common/page_load_metrics_messages.h" 12 #include "components/page_load_metrics/common/page_load_metrics_messages.h"
12 #include "components/rappor/rappor_utils.h" 13 #include "components/rappor/rappor_utils.h"
13 #include "components/rappor/test_rappor_service.h" 14 #include "components/rappor/test_rappor_service.h"
15 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/navigation_handle.h" 16 #include "content/public/browser/navigation_handle.h"
15 #include "content/public/browser/render_frame_host.h" 17 #include "content/public/browser/render_frame_host.h"
16 #include "content/public/test/test_renderer_host.h" 18 #include "content/public/test/test_renderer_host.h"
17 #include "content/public/test/web_contents_tester.h" 19 #include "content/public/test/web_contents_tester.h"
18 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
19 21
20 namespace page_load_metrics { 22 namespace page_load_metrics {
21 23
22 namespace { 24 namespace {
23 25
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 histogram_tester_.ExpectTotalCount(kCommittedEvents, num_committed_events_); 92 histogram_tester_.ExpectTotalCount(kCommittedEvents, num_committed_events_);
91 histogram_tester_.ExpectTotalCount(kBGProvisionalEvents, 93 histogram_tester_.ExpectTotalCount(kBGProvisionalEvents,
92 num_provisional_events_bg_); 94 num_provisional_events_bg_);
93 histogram_tester_.ExpectTotalCount(kBGCommittedEvents, 95 histogram_tester_.ExpectTotalCount(kBGCommittedEvents,
94 num_committed_events_bg_); 96 num_committed_events_bg_);
95 histogram_tester_.ExpectTotalCount(kErrorEvents, num_errors_); 97 histogram_tester_.ExpectTotalCount(kErrorEvents, num_errors_);
96 } 98 }
97 99
98 protected: 100 protected:
99 base::HistogramTester histogram_tester_; 101 base::HistogramTester histogram_tester_;
102 base::UserActionTester user_action_tester_;
100 rappor::TestRapporService rappor_tester_; 103 rappor::TestRapporService rappor_tester_;
101 scoped_ptr<MetricsWebContentsObserver> observer_; 104 scoped_ptr<MetricsWebContentsObserver> observer_;
102 105
103 private: 106 private:
104 int num_provisional_events_; 107 int num_provisional_events_;
105 int num_provisional_events_bg_; 108 int num_provisional_events_bg_;
106 int num_committed_events_; 109 int num_committed_events_;
107 int num_committed_events_bg_; 110 int num_committed_events_bg_;
108 int num_errors_; 111 int num_errors_;
109 112
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 const auto& string_it = sample_obj->string_fields.find("Domain"); 672 const auto& string_it = sample_obj->string_fields.find("Domain");
670 EXPECT_NE(string_it, sample_obj->string_fields.end()); 673 EXPECT_NE(string_it, sample_obj->string_fields.end());
671 EXPECT_EQ(rappor::GetDomainAndRegistrySampleFromGURL(GURL(kDefaultTestUrl)), 674 EXPECT_EQ(rappor::GetDomainAndRegistrySampleFromGURL(GURL(kDefaultTestUrl)),
672 string_it->second); 675 string_it->second);
673 676
674 const auto& flag_it = sample_obj->flag_fields.find("IsSlow"); 677 const auto& flag_it = sample_obj->flag_fields.find("IsSlow");
675 EXPECT_NE(flag_it, sample_obj->flag_fields.end()); 678 EXPECT_NE(flag_it, sample_obj->flag_fields.end());
676 EXPECT_EQ(0u, flag_it->second); 679 EXPECT_EQ(0u, flag_it->second);
677 } 680 }
678 681
682 TEST_F(MetricsWebContentsObserverTest, IsGoogleCaptcha) {
683 {
Alexei Svitkine (slow) 2015/11/13 17:45:12 Nit: Can you make this a table driven test?
Matt Welsh 2015/11/13 19:37:16 Done.
684 EXPECT_FALSE(IsGoogleCaptcha(GURL()));
685 }
686 {
687 EXPECT_FALSE(IsGoogleCaptcha(GURL("http://www.cnn.com/")));
688 }
689 {
690 EXPECT_FALSE(IsGoogleCaptcha(GURL("http://ipv4.google.com/")));
691 }
692 {
693 EXPECT_TRUE(IsGoogleCaptcha(
694 GURL("https://ipv4.google.com/sorry/IndexRedirect?continue=http://a")));
695 }
696 {
697 EXPECT_TRUE(IsGoogleCaptcha(
698 GURL("https://ipv6.google.com/sorry/IndexRedirect?continue=http://a")));
699 }
700 {
701 EXPECT_FALSE(IsGoogleCaptcha(
702 GURL("https://ipv7.google.com/sorry/IndexRedirect?continue=http://a")));
703 }
704 }
705
679 } // namespace page_load_metrics 706 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698