| 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::IsGoogleDomainUrl; |
| 10 using google_util::IsGoogleHomePageUrl; | 10 using google_util::IsGoogleHomePageUrl; |
| 11 using google_util::IsGoogleSearchUrl; | 11 using google_util::IsGoogleSearchUrl; |
| 12 using google_util::IsInstantExtendedAPIGoogleSearchUrl; |
| 12 | 13 |
| 13 TEST(GoogleUtilTest, GoodHomePagesNonSecure) { | 14 TEST(GoogleUtilTest, GoodHomePagesNonSecure) { |
| 14 // Valid home page hosts. | 15 // Valid home page hosts. |
| 15 EXPECT_TRUE(IsGoogleHomePageUrl(GoogleURLTracker::kDefaultGoogleHomepage)); | 16 EXPECT_TRUE(IsGoogleHomePageUrl(GoogleURLTracker::kDefaultGoogleHomepage)); |
| 16 EXPECT_TRUE(IsGoogleHomePageUrl("http://google.com")); | 17 EXPECT_TRUE(IsGoogleHomePageUrl("http://google.com")); |
| 17 EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.com")); | 18 EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.com")); |
| 18 EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.ca")); | 19 EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.ca")); |
| 19 EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.co.uk")); | 20 EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.co.uk")); |
| 20 EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.com:80/")); | 21 EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.com:80/")); |
| 21 | 22 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 "http://www.google.com/webhp/nogood#q=something")); | 237 "http://www.google.com/webhp/nogood#q=something")); |
| 237 EXPECT_FALSE(IsGoogleSearchUrl("")); | 238 EXPECT_FALSE(IsGoogleSearchUrl("")); |
| 238 | 239 |
| 239 // Case sensitive paths. | 240 // Case sensitive paths. |
| 240 EXPECT_FALSE(IsGoogleSearchUrl( | 241 EXPECT_FALSE(IsGoogleSearchUrl( |
| 241 "http://www.google.com/SEARCH?q=something")); | 242 "http://www.google.com/SEARCH?q=something")); |
| 242 EXPECT_FALSE(IsGoogleSearchUrl( | 243 EXPECT_FALSE(IsGoogleSearchUrl( |
| 243 "http://www.google.com/WEBHP#q=something")); | 244 "http://www.google.com/WEBHP#q=something")); |
| 244 } | 245 } |
| 245 | 246 |
| 247 TEST(GoogleUtilTest, IsInstantExtendedAPIGoogleSearchUrl) { |
| 248 EXPECT_TRUE(IsInstantExtendedAPIGoogleSearchUrl( |
| 249 "http://www.google.com/search?q=something&espv=1")); |
| 250 EXPECT_TRUE(IsInstantExtendedAPIGoogleSearchUrl( |
| 251 "http://www.google.com/search?q=something&espv=3")); |
| 252 EXPECT_TRUE(IsInstantExtendedAPIGoogleSearchUrl( |
| 253 "http://www.google.com/search?q=something&espv=42")); |
| 254 |
| 255 EXPECT_FALSE(IsInstantExtendedAPIGoogleSearchUrl( |
| 256 "http://www.google.com/search?q=something&espv=")); |
| 257 EXPECT_FALSE(IsInstantExtendedAPIGoogleSearchUrl( |
| 258 "http://www.google.com/search?q=something&espv=0")); |
| 259 EXPECT_FALSE(IsInstantExtendedAPIGoogleSearchUrl( |
| 260 "http://www.google.com/search?q=something&espv=00")); |
| 261 |
| 262 EXPECT_FALSE(IsInstantExtendedAPIGoogleSearchUrl( |
| 263 "http://www.foo.com/search?q=something&espv=0")); |
| 264 EXPECT_FALSE(IsInstantExtendedAPIGoogleSearchUrl( |
| 265 "http://www.foo.com/search?q=something&espv=1")); |
| 266 EXPECT_FALSE(IsInstantExtendedAPIGoogleSearchUrl( |
| 267 "http://www.google.com/bing?q=something&espv=1")); |
| 268 EXPECT_FALSE(IsInstantExtendedAPIGoogleSearchUrl( |
| 269 "http://www.google.com/search?q=something&vespv=1")); |
| 270 EXPECT_FALSE(IsInstantExtendedAPIGoogleSearchUrl( |
| 271 "http://www.google.com/search?q=something&espvx=1")); |
| 272 EXPECT_FALSE(IsInstantExtendedAPIGoogleSearchUrl( |
| 273 "http://www.google.com/search#q=something&espv=1")); |
| 274 } |
| 275 |
| 246 TEST(GoogleUtilTest, GoogleDomains) { | 276 TEST(GoogleUtilTest, GoogleDomains) { |
| 247 // Test some good Google domains (valid TLDs). | 277 // Test some good Google domains (valid TLDs). |
| 248 EXPECT_TRUE(IsGoogleDomainUrl("http://www.google.com", | 278 EXPECT_TRUE(IsGoogleDomainUrl("http://www.google.com", |
| 249 google_util::ALLOW_SUBDOMAIN)); | 279 google_util::ALLOW_SUBDOMAIN)); |
| 250 EXPECT_TRUE(IsGoogleDomainUrl("http://google.com", | 280 EXPECT_TRUE(IsGoogleDomainUrl("http://google.com", |
| 251 google_util::ALLOW_SUBDOMAIN)); | 281 google_util::ALLOW_SUBDOMAIN)); |
| 252 EXPECT_TRUE(IsGoogleDomainUrl("http://www.google.ca", | 282 EXPECT_TRUE(IsGoogleDomainUrl("http://www.google.ca", |
| 253 google_util::ALLOW_SUBDOMAIN)); | 283 google_util::ALLOW_SUBDOMAIN)); |
| 254 EXPECT_TRUE(IsGoogleDomainUrl("http://www.google.biz.tj", | 284 EXPECT_TRUE(IsGoogleDomainUrl("http://www.google.biz.tj", |
| 255 google_util::ALLOW_SUBDOMAIN)); | 285 google_util::ALLOW_SUBDOMAIN)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 283 google_util::DISALLOW_SUBDOMAIN)); | 313 google_util::DISALLOW_SUBDOMAIN)); |
| 284 EXPECT_TRUE(IsGoogleDomainUrl("https://www.google.com:443", | 314 EXPECT_TRUE(IsGoogleDomainUrl("https://www.google.com:443", |
| 285 google_util::DISALLOW_SUBDOMAIN)); | 315 google_util::DISALLOW_SUBDOMAIN)); |
| 286 EXPECT_FALSE(IsGoogleDomainUrl("https://www.google.com:123", | 316 EXPECT_FALSE(IsGoogleDomainUrl("https://www.google.com:123", |
| 287 google_util::DISALLOW_SUBDOMAIN)); | 317 google_util::DISALLOW_SUBDOMAIN)); |
| 288 EXPECT_FALSE(IsGoogleDomainUrl("file://www.google.com", | 318 EXPECT_FALSE(IsGoogleDomainUrl("file://www.google.com", |
| 289 google_util::DISALLOW_SUBDOMAIN)); | 319 google_util::DISALLOW_SUBDOMAIN)); |
| 290 EXPECT_FALSE(IsGoogleDomainUrl("doesnotexist://www.google.com", | 320 EXPECT_FALSE(IsGoogleDomainUrl("doesnotexist://www.google.com", |
| 291 google_util::DISALLOW_SUBDOMAIN)); | 321 google_util::DISALLOW_SUBDOMAIN)); |
| 292 } | 322 } |
| OLD | NEW |