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

Unified Diff: chrome/browser/google/google_util_unittest.cc

Issue 8728004: Add more flexible handling of what is considered a google home page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix using directive Created 9 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: chrome/browser/google/google_util_unittest.cc
===================================================================
--- chrome/browser/google/google_util_unittest.cc (revision 0)
+++ chrome/browser/google/google_util_unittest.cc (revision 0)
@@ -0,0 +1,62 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/google/google_url_tracker.h"
+#include "chrome/browser/google/google_util.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using google_util::IsGoogleHomePageUrl;
+
+TEST(GoogleUtilTest, GoodHomePages) {
+ // Valid home page URLs.
+ EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.com"));
+ EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.ca"));
+ EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.co.uk"));
+ EXPECT_TRUE(IsGoogleHomePageUrl(GoogleURLTracker::kDefaultGoogleHomepage));
+
+ // Only the paths /, /webhp, and /ig.* are valid. Query parameters are
+ // ignored.
+ EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.com/"));
+ EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.com/webhp"));
+ EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.com/webhp?rlz=TEST"));
+ EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.com/ig"));
+ EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.com/ig/foo"));
+ EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.com/ig?rlz=TEST"));
+ EXPECT_TRUE(IsGoogleHomePageUrl("http://www.google.com/ig/foo?rlz=TEST"));
+
+ // Protocol https is valid.
+ EXPECT_TRUE(IsGoogleHomePageUrl("https://www.google.com/"));
+}
+
+TEST(GoogleUtilTest, BadHomePages) {
+ EXPECT_FALSE(IsGoogleHomePageUrl(""));
+
+ // Only the "www" subdomain is OK.
+ EXPECT_FALSE(IsGoogleHomePageUrl("http://maps.google.com"));
+ EXPECT_FALSE(IsGoogleHomePageUrl("http://foo.google.com"));
+ EXPECT_FALSE(IsGoogleHomePageUrl("http://google.com"));
+
+ // No non-standard port numbers.
+ EXPECT_FALSE(IsGoogleHomePageUrl("http://www.google.com:1234"));
+ EXPECT_FALSE(IsGoogleHomePageUrl("https://www.google.com:5678"));
+
+ // Invalid TLDs.
+ EXPECT_FALSE(IsGoogleHomePageUrl("http://www.google.abc"));
+ EXPECT_FALSE(IsGoogleHomePageUrl("http://www.google.com.abc"));
+ EXPECT_FALSE(IsGoogleHomePageUrl("http://www.google.abc.com"));
+ EXPECT_FALSE(IsGoogleHomePageUrl("http://www.google.ab.cd"));
+ EXPECT_FALSE(IsGoogleHomePageUrl("http://www.google.uk.qq"));
+
+ // Must be http or https.
SteveT 2011/11/28 21:04:49 Add a case for "www.google.com" (schemeless but va
Roger Tawa OOO till Jul 10th 2011/11/29 16:00:09 Done.
+ EXPECT_FALSE(IsGoogleHomePageUrl("ftp://www.google.com"));
+ EXPECT_FALSE(IsGoogleHomePageUrl("file://does/not/exist"));
+ EXPECT_FALSE(IsGoogleHomePageUrl("bad://www.google.com"));
+
+ // Only the paths /, /webhp, and /ig.* are valid.
+ EXPECT_FALSE(IsGoogleHomePageUrl("http://www.google.com/abc"));
+ EXPECT_FALSE(IsGoogleHomePageUrl("http://www.google.com/webhpabc"));
+ EXPECT_FALSE(IsGoogleHomePageUrl("http://www.google.com/webhp/abc"));
+ EXPECT_FALSE(IsGoogleHomePageUrl("http://www.google.com/abcig"));
+ EXPECT_FALSE(IsGoogleHomePageUrl("http://www.google.com/webhp/ig"));
+}
Property changes on: chrome\browser\google\google_util_unittest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698