OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/test/histogram_tester.h" | 6 #include "base/test/histogram_tester.h" |
7 #include "chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_ observer.h" | 7 #include "chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_ observer.h" |
8 #include "chrome/browser/page_load_metrics/observers/google_captcha_observer.h" | |
8 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
9 #include "components/page_load_metrics/browser/metrics_web_contents_observer.h" | 10 #include "components/page_load_metrics/browser/metrics_web_contents_observer.h" |
10 #include "components/page_load_metrics/common/page_load_metrics_messages.h" | 11 #include "components/page_load_metrics/common/page_load_metrics_messages.h" |
11 #include "content/public/test/web_contents_tester.h" | 12 #include "content/public/test/web_contents_tester.h" |
12 #include "url/gurl.h" | 13 #include "url/gurl.h" |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 const char kHistogramNameFromGWSFirstTextPaint[] = | 17 const char kHistogramNameFromGWSFirstTextPaint[] = |
17 "PageLoad.Clients.FromGWS.Timing2.NavigationToFirstTextPaint"; | 18 "PageLoad.Clients.FromGWS.Timing2.NavigationToFirstTextPaint"; |
(...skipping 171 matching lines...) Loading... | |
189 GURL("https://www.anothersite.com"), blink::WebReferrerPolicyDefault)); | 190 GURL("https://www.anothersite.com"), blink::WebReferrerPolicyDefault)); |
190 | 191 |
191 observer_->OnMessageReceived( | 192 observer_->OnMessageReceived( |
192 PageLoadMetricsMsg_TimingUpdated(observer_->routing_id(), timing), | 193 PageLoadMetricsMsg_TimingUpdated(observer_->routing_id(), timing), |
193 web_contents()->GetMainFrame()); | 194 web_contents()->GetMainFrame()); |
194 | 195 |
195 // Navigate again to force logging. | 196 // Navigate again to force logging. |
196 NavigateAndCommit(GURL("https://www.google.com")); | 197 NavigateAndCommit(GURL("https://www.google.com")); |
197 histogram_tester_.ExpectTotalCount(kHistogramNameFromGWSFirstTextPaint, 0); | 198 histogram_tester_.ExpectTotalCount(kHistogramNameFromGWSFirstTextPaint, 0); |
198 } | 199 } |
200 | |
201 TEST_F(PageLoadMetricsObserverTest, IsGoogleCaptcha) { | |
Randy Smith (Not in Mondays)
2015/11/14 01:45:48
Charles: Did we have a conversation about all the
| |
202 struct { | |
203 std::string url; | |
204 bool expected; | |
205 } test_cases[] = { | |
206 {"", false}, | |
207 {"http://www.google.com/", false}, | |
208 {"http://www.cnn.com/", false}, | |
209 {"http://ipv4.google.com/", false}, | |
210 {"https://ipv4.google.com/sorry/IndexRedirect?continue=http://a", true}, | |
211 {"https://ipv6.google.com/sorry/IndexRedirect?continue=http://a", true}, | |
212 {"https://ipv7.google.com/sorry/IndexRedirect?continue=http://a", false}, | |
213 }; | |
214 for (const auto& test : test_cases) { | |
215 EXPECT_EQ(test.expected, | |
216 google_captcha_observer::IsGoogleCaptcha(GURL(test.url))) | |
217 << "for URL: " << test.url; | |
218 } | |
219 } | |
OLD | NEW |