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

Side by Side Diff: chrome/browser/prerender/prerender_util_unittest.cc

Issue 7812011: Tighten conditions for when a URL is a search result, and move (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/prerender/prerender_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/prerender/prerender_util.h" 5 #include "chrome/browser/prerender/prerender_util.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 namespace prerender { 8 namespace prerender {
9 9
10 class PrerenderUtilTest : public testing::Test { 10 class PrerenderUtilTest : public testing::Test {
(...skipping 16 matching lines...) Expand all
27 GURL("http://www.google.com/?url=INVALIDurlsAREsoMUCHfun.com"), &result)); 27 GURL("http://www.google.com/?url=INVALIDurlsAREsoMUCHfun.com"), &result));
28 EXPECT_TRUE(MaybeGetQueryStringBasedAliasURL( 28 EXPECT_TRUE(MaybeGetQueryStringBasedAliasURL(
29 GURL("http://www.google.com/?url=http://validURLSareGREAT.com"), 29 GURL("http://www.google.com/?url=http://validURLSareGREAT.com"),
30 &result)); 30 &result));
31 ASSERT_EQ(GURL("http://validURLSareGREAT.com").spec(), result.spec()); 31 ASSERT_EQ(GURL("http://validURLSareGREAT.com").spec(), result.spec());
32 } 32 }
33 33
34 // Ensure that extracting an experiment in the lpe= query string component 34 // Ensure that extracting an experiment in the lpe= query string component
35 // works. 35 // works.
36 TEST_F(PrerenderUtilTest, ExtractExperimentInQueryStringTest) { 36 TEST_F(PrerenderUtilTest, ExtractExperimentInQueryStringTest) {
37 GURL result;
38 EXPECT_EQ(GetQueryStringBasedExperiment( 37 EXPECT_EQ(GetQueryStringBasedExperiment(
39 GURL("http://www.google.com/url?sa=t&source=web&cd=1&ved=0CBcQFjAA&url=htt p%3A%2F%2Fwww.abercrombie.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2FStoreLocator%3 FcatalogId%3D%26storeId%3D10051%26langId%3D-1&rct=j&q=allinurl%3A%26&ei=KLyUTYGS EdTWiAKUmLCdCQ&usg=AFQjCNF8nJ2MpBFfr1ijO39_f22bcKyccw&sig2=2ymyGpO0unJwU1d4kdCUj Q&lpe=4&asdf=test")), 4); 38 GURL("http://www.google.com/url?sa=t&source=web&cd=1&ved=0CBcQFjAA&url=htt p%3A%2F%2Fwww.abercrombie.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2FStoreLocator%3 FcatalogId%3D%26storeId%3D10051%26langId%3D-1&rct=j&q=allinurl%3A%26&ei=KLyUTYGS EdTWiAKUmLCdCQ&usg=AFQjCNF8nJ2MpBFfr1ijO39_f22bcKyccw&sig2=2ymyGpO0unJwU1d4kdCUj Q&lpe=4&asdf=test")), 4);
40 EXPECT_EQ(GetQueryStringBasedExperiment( 39 EXPECT_EQ(GetQueryStringBasedExperiment(
41 GURL("http://www.google.com/test.php?a=b")), kNoExperiment); 40 GURL("http://www.google.com/test.php?a=b")), kNoExperiment);
42 EXPECT_EQ(GetQueryStringBasedExperiment( 41 EXPECT_EQ(GetQueryStringBasedExperiment(
43 GURL("http://www.google.com/test.php?lpe=5")), 5); 42 GURL("http://www.google.com/test.php?lpe=5")), 5);
44 EXPECT_EQ(GetQueryStringBasedExperiment( 43 EXPECT_EQ(GetQueryStringBasedExperiment(
45 GURL("http://www.google.com/test.php?lpe=50")), kNoExperiment); 44 GURL("http://www.google.com/test.php?lpe=50")), kNoExperiment);
46 EXPECT_EQ(GetQueryStringBasedExperiment( 45 EXPECT_EQ(GetQueryStringBasedExperiment(
47 GURL("http://www.google.com/test.php?lpe=0")), kNoExperiment); 46 GURL("http://www.google.com/test.php?lpe=0")), kNoExperiment);
48 EXPECT_EQ(GetQueryStringBasedExperiment( 47 EXPECT_EQ(GetQueryStringBasedExperiment(
49 GURL("http://www.google.com/test.php?lpe=10")), kNoExperiment); 48 GURL("http://www.google.com/test.php?lpe=10")), kNoExperiment);
50 } 49 }
51 50
51 // Ensure that we detect Google search result URLs correctly.
52 TEST_F(PrerenderUtilTest, DetectGoogleSearchREsultURLTest) {
53 EXPECT_TRUE(IsGoogleSearchResultURL(GURL("http://www.google.com/#asdf")));
54 EXPECT_TRUE(IsGoogleSearchResultURL(GURL("http://www.google.com/")));
55 EXPECT_TRUE(IsGoogleSearchResultURL(GURL("http://www.google.com/?a=b")));
56 EXPECT_TRUE(IsGoogleSearchResultURL(
57 GURL("http://www.google.com/search?q=hi")));
58 EXPECT_TRUE(IsGoogleSearchResultURL(GURL("http://www.google.com/search")));
59 EXPECT_TRUE(IsGoogleSearchResultURL(GURL("http://www.google.com/webhp")));
60 EXPECT_TRUE(IsGoogleSearchResultURL(
61 GURL("http://www.google.com/webhp?a=b#123")));
62 EXPECT_FALSE(IsGoogleSearchResultURL(GURL("http://www.google.com/imgres")));
63 EXPECT_FALSE(IsGoogleSearchResultURL(
64 GURL("http://www.google.com/imgres?q=hi")));
65 EXPECT_FALSE(IsGoogleSearchResultURL(
66 GURL("http://www.google.com/imgres?q=hi#123")));
67 EXPECT_FALSE(IsGoogleSearchResultURL(GURL("http://google.com/search")));
68 EXPECT_TRUE(IsGoogleSearchResultURL(GURL("http://WWW.GooGLE.CoM/search")));
69 EXPECT_FALSE(IsGoogleSearchResultURL(GURL("http://WWW.GooGLE.CoM/SeArcH")));
70 EXPECT_TRUE(IsGoogleSearchResultURL(GURL("http://www.google.co.uk/search")));
71 EXPECT_FALSE(IsGoogleSearchResultURL(GURL("http://google.co.uk/search")));
72 EXPECT_FALSE(IsGoogleSearchResultURL(GURL("http://www.chromium.org/search")));
73 }
74
52 } // namespace prerender 75 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698