OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/google/google_url_tracker.h" | 5 #include "chrome/browser/google/google_url_tracker.h" |
6 #include "chrome/browser/google/google_util.h" | 6 #include "chrome/browser/google/google_util.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 using google_util::IsGoogleDomainUrl; | |
9 using google_util::IsGoogleHomePageUrl; | 10 using google_util::IsGoogleHomePageUrl; |
10 using google_util::IsGoogleSearchUrl; | 11 using google_util::IsGoogleSearchUrl; |
11 | 12 |
12 TEST(GoogleUtilTest, GoodHomePagesNonSecure) { | 13 TEST(GoogleUtilTest, GoodHomePagesNonSecure) { |
13 // Valid home page hosts. | 14 // Valid home page hosts. |
14 EXPECT_TRUE(IsGoogleHomePageUrl(GoogleURLTracker::kDefaultGoogleHomepage)); | 15 EXPECT_TRUE(IsGoogleHomePageUrl(GoogleURLTracker::kDefaultGoogleHomepage)); |
15 EXPECT_TRUE(IsGoogleHomePageUrl("http://google.com")); | 16 EXPECT_TRUE(IsGoogleHomePageUrl("http://google.com")); |
16 EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.com")); | 17 EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.com")); |
17 EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.ca")); | 18 EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.ca")); |
18 EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.co.uk")); | 19 EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.co.uk")); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 EXPECT_FALSE(IsGoogleSearchUrl( | 235 EXPECT_FALSE(IsGoogleSearchUrl( |
235 "http://www.google.com/webhp/nogood#q=something")); | 236 "http://www.google.com/webhp/nogood#q=something")); |
236 EXPECT_FALSE(IsGoogleSearchUrl("")); | 237 EXPECT_FALSE(IsGoogleSearchUrl("")); |
237 | 238 |
238 // Case sensitive paths. | 239 // Case sensitive paths. |
239 EXPECT_FALSE(IsGoogleSearchUrl( | 240 EXPECT_FALSE(IsGoogleSearchUrl( |
240 "http://www.google.com/SEARCH?q=something")); | 241 "http://www.google.com/SEARCH?q=something")); |
241 EXPECT_FALSE(IsGoogleSearchUrl( | 242 EXPECT_FALSE(IsGoogleSearchUrl( |
242 "http://www.google.com/WEBHP#q=something")); | 243 "http://www.google.com/WEBHP#q=something")); |
243 } | 244 } |
245 | |
246 TEST(GoogleUtilTest, GoogleDomains) { | |
247 // Test some good Google domains (valid TLDs). | |
248 EXPECT_TRUE(IsGoogleDomainUrl("http://www.google.com", | |
249 google_util::ALLOW_SUBDOMAIN)); | |
250 EXPECT_TRUE(IsGoogleDomainUrl("http://google.com", | |
251 google_util::ALLOW_SUBDOMAIN)); | |
252 EXPECT_TRUE(IsGoogleDomainUrl("http://www.google.ca", | |
253 google_util::ALLOW_SUBDOMAIN)); | |
254 EXPECT_TRUE(IsGoogleDomainUrl("http://www.google.biz.tj", | |
255 google_util::ALLOW_SUBDOMAIN)); | |
256 EXPECT_TRUE(IsGoogleDomainUrl("http://www.google.com/search?q=something", | |
257 google_util::ALLOW_SUBDOMAIN)); | |
258 EXPECT_TRUE(IsGoogleDomainUrl("http://www.google.com/webhp", | |
259 google_util::ALLOW_SUBDOMAIN)); | |
260 | |
261 // Test some bad Google domains (invalid TLDs). | |
262 EXPECT_FALSE(IsGoogleDomainUrl("http://www.google.notrealtld", | |
263 google_util::ALLOW_SUBDOMAIN)); | |
264 EXPECT_FALSE(IsGoogleDomainUrl("http://www.google.faketld/search?q=something", | |
265 google_util::ALLOW_SUBDOMAIN)); | |
266 EXPECT_FALSE(IsGoogleDomainUrl("http://www.yahoo.com", | |
267 google_util::ALLOW_SUBDOMAIN)); | |
268 | |
269 // Test subdomain checks. | |
270 EXPECT_TRUE(IsGoogleDomainUrl("http://images.google.com", | |
271 google_util::ALLOW_SUBDOMAIN)); | |
272 EXPECT_FALSE(IsGoogleDomainUrl("http://images.google.com", | |
273 google_util::DISALLOW_SUBDOMAIN)); | |
274 EXPECT_TRUE(IsGoogleDomainUrl("http://google.com", | |
275 google_util::DISALLOW_SUBDOMAIN)); | |
276 EXPECT_TRUE(IsGoogleDomainUrl("http://www.google.com", | |
277 google_util::DISALLOW_SUBDOMAIN)); | |
battre
2012/04/17 20:33:02
do you want to add tests for scheme and port filte
SteveT
2012/04/17 23:26:44
Done.
| |
278 } | |
OLD | NEW |