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

Side by Side Diff: net/cookies/canonical_cookie_unittest.cc

Issue 11308270: Remove unused parameter from the method IsDomainMatch of the class CanonicalCookie (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | « net/cookies/canonical_cookie.cc ('k') | net/cookies/cookie_monster.cc » ('j') | 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) 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 "net/cookies/canonical_cookie.h" 5 #include "net/cookies/canonical_cookie.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "net/cookies/cookie_options.h" 9 #include "net/cookies/cookie_options.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 194 }
195 195
196 TEST(CanonicalCookieTest, IsDomainMatch) { 196 TEST(CanonicalCookieTest, IsDomainMatch) {
197 GURL url("http://www.example.com/test/foo.html"); 197 GURL url("http://www.example.com/test/foo.html");
198 base::Time creation_time = base::Time::Now(); 198 base::Time creation_time = base::Time::Now();
199 CookieOptions options; 199 CookieOptions options;
200 200
201 scoped_ptr<CanonicalCookie> cookie( 201 scoped_ptr<CanonicalCookie> cookie(
202 CanonicalCookie::Create(url, "A=2", creation_time, options)); 202 CanonicalCookie::Create(url, "A=2", creation_time, options));
203 EXPECT_TRUE(cookie->IsHostCookie()); 203 EXPECT_TRUE(cookie->IsHostCookie());
204 EXPECT_TRUE(cookie->IsDomainMatch("http", "www.example.com")); 204 EXPECT_TRUE(cookie->IsDomainMatch("www.example.com"));
205 EXPECT_TRUE(cookie->IsDomainMatch("https", "www.example.com")); 205 EXPECT_TRUE(cookie->IsDomainMatch("www.example.com"));
206 EXPECT_FALSE(cookie->IsDomainMatch("http", "foo.www.example.com")); 206 EXPECT_FALSE(cookie->IsDomainMatch("foo.www.example.com"));
207 EXPECT_FALSE(cookie->IsDomainMatch("http", "www0.example.com")); 207 EXPECT_FALSE(cookie->IsDomainMatch("www0.example.com"));
208 EXPECT_FALSE(cookie->IsDomainMatch("http", "example.com")); 208 EXPECT_FALSE(cookie->IsDomainMatch("example.com"));
209 209
210 cookie.reset( 210 cookie.reset(
211 CanonicalCookie::Create(url, "A=2; Domain=www.example.com", creation_time, 211 CanonicalCookie::Create(url, "A=2; Domain=www.example.com", creation_time,
212 options)); 212 options));
213 EXPECT_TRUE(cookie->IsDomainCookie()); 213 EXPECT_TRUE(cookie->IsDomainCookie());
214 EXPECT_TRUE(cookie->IsDomainMatch("http", "www.example.com")); 214 EXPECT_TRUE(cookie->IsDomainMatch("www.example.com"));
215 EXPECT_TRUE(cookie->IsDomainMatch("https", "www.example.com")); 215 EXPECT_TRUE(cookie->IsDomainMatch("www.example.com"));
216 EXPECT_TRUE(cookie->IsDomainMatch("http", "foo.www.example.com")); 216 EXPECT_TRUE(cookie->IsDomainMatch("foo.www.example.com"));
217 EXPECT_FALSE(cookie->IsDomainMatch("http", "www0.example.com")); 217 EXPECT_FALSE(cookie->IsDomainMatch("www0.example.com"));
218 EXPECT_FALSE(cookie->IsDomainMatch("http", "example.com")); 218 EXPECT_FALSE(cookie->IsDomainMatch("example.com"));
219 219
220 cookie.reset( 220 cookie.reset(
221 CanonicalCookie::Create(url, "A=2; Domain=.www.example.com", 221 CanonicalCookie::Create(url, "A=2; Domain=.www.example.com",
222 creation_time, options)); 222 creation_time, options));
223 EXPECT_TRUE(cookie->IsDomainMatch("http", "www.example.com")); 223 EXPECT_TRUE(cookie->IsDomainMatch("www.example.com"));
224 EXPECT_TRUE(cookie->IsDomainMatch("https", "www.example.com")); 224 EXPECT_TRUE(cookie->IsDomainMatch("www.example.com"));
225 EXPECT_TRUE(cookie->IsDomainMatch("http", "foo.www.example.com")); 225 EXPECT_TRUE(cookie->IsDomainMatch("foo.www.example.com"));
226 EXPECT_FALSE(cookie->IsDomainMatch("http", "www0.example.com")); 226 EXPECT_FALSE(cookie->IsDomainMatch("www0.example.com"));
227 EXPECT_FALSE(cookie->IsDomainMatch("http", "example.com")); 227 EXPECT_FALSE(cookie->IsDomainMatch("example.com"));
228 } 228 }
229 229
230 TEST(CanonicalCookieTest, IsOnPath) { 230 TEST(CanonicalCookieTest, IsOnPath) {
231 base::Time creation_time = base::Time::Now(); 231 base::Time creation_time = base::Time::Now();
232 CookieOptions options; 232 CookieOptions options;
233 233
234 scoped_ptr<CanonicalCookie> cookie( 234 scoped_ptr<CanonicalCookie> cookie(
235 CanonicalCookie::Create(GURL("http://www.example.com"), 235 CanonicalCookie::Create(GURL("http://www.example.com"),
236 "A=2", creation_time, options)); 236 "A=2", creation_time, options));
237 EXPECT_TRUE(cookie->IsOnPath("/")); 237 EXPECT_TRUE(cookie->IsOnPath("/"));
238 EXPECT_TRUE(cookie->IsOnPath("/test")); 238 EXPECT_TRUE(cookie->IsOnPath("/test"));
239 EXPECT_TRUE(cookie->IsOnPath("/test/bar.html")); 239 EXPECT_TRUE(cookie->IsOnPath("/test/bar.html"));
240 240
241 // Test the empty string edge case. 241 // Test the empty string edge case.
242 EXPECT_FALSE(cookie->IsOnPath("")); 242 EXPECT_FALSE(cookie->IsOnPath(""));
243 243
244 cookie.reset( 244 cookie.reset(
245 CanonicalCookie::Create(GURL("http://www.example.com/test/foo.html"), 245 CanonicalCookie::Create(GURL("http://www.example.com/test/foo.html"),
246 "A=2", creation_time, options)); 246 "A=2", creation_time, options));
247 EXPECT_FALSE(cookie->IsOnPath("/")); 247 EXPECT_FALSE(cookie->IsOnPath("/"));
248 EXPECT_TRUE(cookie->IsOnPath("/test")); 248 EXPECT_TRUE(cookie->IsOnPath("/test"));
249 EXPECT_TRUE(cookie->IsOnPath("/test/bar.html")); 249 EXPECT_TRUE(cookie->IsOnPath("/test/bar.html"));
250 EXPECT_TRUE(cookie->IsOnPath("/test/sample/bar.html")); 250 EXPECT_TRUE(cookie->IsOnPath("/test/sample/bar.html"));
251 } 251 }
252 252
253 } // namespace net 253 } // namespace net
OLDNEW
« no previous file with comments | « net/cookies/canonical_cookie.cc ('k') | net/cookies/cookie_monster.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698