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

Unified Diff: net/cookies/canonical_cookie_unittest.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: net/cookies/canonical_cookie_unittest.cc
diff --git a/net/cookies/canonical_cookie_unittest.cc b/net/cookies/canonical_cookie_unittest.cc
index 26e4e1249f1dc95fcae5acd2c56ec155936de74a..6eb82d2855e90fcd9a97ba2b930771df972f046b 100644
--- a/net/cookies/canonical_cookie_unittest.cc
+++ b/net/cookies/canonical_cookie_unittest.cc
@@ -13,24 +13,24 @@
namespace net {
TEST(CanonicalCookieTest, GetCookieSourceFromURL) {
- EXPECT_EQ("http://example.com/",
- CanonicalCookie::GetCookieSourceFromURL(
- GURL("http://example.com")));
- EXPECT_EQ("http://example.com/",
- CanonicalCookie::GetCookieSourceFromURL(
- GURL("http://example.com/")));
- EXPECT_EQ("http://example.com/",
- CanonicalCookie::GetCookieSourceFromURL(
- GURL("http://example.com/test")));
- EXPECT_EQ("file:///tmp/test.html",
- CanonicalCookie::GetCookieSourceFromURL(
- GURL("file:///tmp/test.html")));
+ EXPECT_EQ(
+ "http://example.com/",
+ CanonicalCookie::GetCookieSourceFromURL(GURL("http://example.com")));
+ EXPECT_EQ(
+ "http://example.com/",
+ CanonicalCookie::GetCookieSourceFromURL(GURL("http://example.com/")));
+ EXPECT_EQ(
+ "http://example.com/",
+ CanonicalCookie::GetCookieSourceFromURL(GURL("http://example.com/test")));
+ EXPECT_EQ(
+ "file:///tmp/test.html",
+ CanonicalCookie::GetCookieSourceFromURL(GURL("file:///tmp/test.html")));
EXPECT_EQ("http://example.com/",
CanonicalCookie::GetCookieSourceFromURL(
GURL("http://example.com:1234/")));
- EXPECT_EQ("http://example.com/",
- CanonicalCookie::GetCookieSourceFromURL(
- GURL("https://example.com/")));
+ EXPECT_EQ(
+ "http://example.com/",
+ CanonicalCookie::GetCookieSourceFromURL(GURL("https://example.com/")));
EXPECT_EQ("http://example.com/",
CanonicalCookie::GetCookieSourceFromURL(
GURL("http://user:pwd@example.com/")));
@@ -46,8 +46,16 @@ TEST(CanonicalCookieTest, Constructor) {
GURL url("http://www.example.com/test");
base::Time current_time = base::Time::Now();
- CanonicalCookie cookie(url, "A", "2", "www.example.com", "/test",
- current_time, base::Time(), current_time, false, false,
+ CanonicalCookie cookie(url,
+ "A",
+ "2",
+ "www.example.com",
+ "/test",
+ current_time,
+ base::Time(),
+ current_time,
+ false,
+ false,
COOKIE_PRIORITY_DEFAULT);
EXPECT_EQ(url.GetOrigin().spec(), cookie.Source());
EXPECT_EQ("A", cookie.Name());
@@ -73,7 +81,6 @@ TEST(CanonicalCookieTest, Constructor) {
EXPECT_EQ("", cookie2.Domain());
EXPECT_EQ("", cookie2.Path());
EXPECT_FALSE(cookie2.IsSecure());
-
}
TEST(CanonicalCookieTest, Create) {
@@ -83,7 +90,7 @@ TEST(CanonicalCookieTest, Create) {
CookieOptions options;
scoped_ptr<CanonicalCookie> cookie(
- CanonicalCookie::Create(url, "A=2", creation_time, options));
+ CanonicalCookie::Create(url, "A=2", creation_time, options));
EXPECT_EQ(url.GetOrigin().spec(), cookie->Source());
EXPECT_EQ("A", cookie->Name());
EXPECT_EQ("2", cookie->Value());
@@ -113,16 +120,22 @@ TEST(CanonicalCookieTest, Create) {
EXPECT_FALSE(cookie.get());
CookieOptions httponly_options;
httponly_options.set_include_httponly();
- cookie.reset(
- CanonicalCookie::Create(url, "A=2; HttpOnly", creation_time,
- httponly_options));
+ cookie.reset(CanonicalCookie::Create(
+ url, "A=2; HttpOnly", creation_time, httponly_options));
EXPECT_TRUE(cookie->IsHttpOnly());
// Test the creating cookies using specific parameter instead of a cookie
// string.
- cookie.reset(CanonicalCookie::Create(
- url, "A", "2", "www.example.com", "/test", creation_time, base::Time(),
- false, false, COOKIE_PRIORITY_DEFAULT));
+ cookie.reset(CanonicalCookie::Create(url,
+ "A",
+ "2",
+ "www.example.com",
+ "/test",
+ creation_time,
+ base::Time(),
+ false,
+ false,
+ COOKIE_PRIORITY_DEFAULT));
EXPECT_EQ(url.GetOrigin().spec(), cookie->Source());
EXPECT_EQ("A", cookie->Name());
EXPECT_EQ("2", cookie->Value());
@@ -130,9 +143,16 @@ TEST(CanonicalCookieTest, Create) {
EXPECT_EQ("/test", cookie->Path());
EXPECT_FALSE(cookie->IsSecure());
- cookie.reset(CanonicalCookie::Create(
- url, "A", "2", ".www.example.com", "/test", creation_time, base::Time(),
- false, false, COOKIE_PRIORITY_DEFAULT));
+ cookie.reset(CanonicalCookie::Create(url,
+ "A",
+ "2",
+ ".www.example.com",
+ "/test",
+ creation_time,
+ base::Time(),
+ false,
+ false,
+ COOKIE_PRIORITY_DEFAULT));
EXPECT_EQ(url.GetOrigin().spec(), cookie->Source());
EXPECT_EQ("A", cookie->Name());
EXPECT_EQ("2", cookie->Value());
@@ -148,8 +168,8 @@ TEST(CanonicalCookieTest, EmptyExpiry) {
std::string cookie_line =
"ACSTM=20130308043820420042; path=/; domain=ipdl.inpit.go.jp; Expires=";
- scoped_ptr<CanonicalCookie> cookie(CanonicalCookie::Create(
- url, cookie_line, creation_time, options));
+ scoped_ptr<CanonicalCookie> cookie(
+ CanonicalCookie::Create(url, cookie_line, creation_time, options));
EXPECT_TRUE(cookie.get());
EXPECT_FALSE(cookie->IsPersistent());
EXPECT_FALSE(cookie->IsExpired(creation_time));
@@ -157,8 +177,8 @@ TEST(CanonicalCookieTest, EmptyExpiry) {
// With a stale server time
options.set_server_time(creation_time - base::TimeDelta::FromHours(1));
- cookie.reset(CanonicalCookie::Create(
- url, cookie_line, creation_time, options));
+ cookie.reset(
+ CanonicalCookie::Create(url, cookie_line, creation_time, options));
EXPECT_TRUE(cookie.get());
EXPECT_FALSE(cookie->IsPersistent());
EXPECT_FALSE(cookie->IsExpired(creation_time));
@@ -166,8 +186,8 @@ TEST(CanonicalCookieTest, EmptyExpiry) {
// With a future server time
options.set_server_time(creation_time + base::TimeDelta::FromHours(1));
- cookie.reset(CanonicalCookie::Create(
- url, cookie_line, creation_time, options));
+ cookie.reset(
+ CanonicalCookie::Create(url, cookie_line, creation_time, options));
EXPECT_TRUE(cookie.get());
EXPECT_FALSE(cookie->IsPersistent());
EXPECT_FALSE(cookie->IsExpired(creation_time));
@@ -188,74 +208,130 @@ TEST(CanonicalCookieTest, IsEquivalent) {
// Test that a cookie is equivalent to itself.
scoped_ptr<CanonicalCookie> cookie(
- new CanonicalCookie(url, cookie_name, cookie_value, cookie_domain,
- cookie_path, creation_time, expiration_time,
- last_access_time, secure, httponly,
+ new CanonicalCookie(url,
+ cookie_name,
+ cookie_value,
+ cookie_domain,
+ cookie_path,
+ creation_time,
+ expiration_time,
+ last_access_time,
+ secure,
+ httponly,
COOKIE_PRIORITY_MEDIUM));
EXPECT_TRUE(cookie->IsEquivalent(*cookie));
// Test that two identical cookies are equivalent.
scoped_ptr<CanonicalCookie> other_cookie(
- new CanonicalCookie(url, cookie_name, cookie_value, cookie_domain,
- cookie_path, creation_time, expiration_time,
- last_access_time, secure, httponly,
+ new CanonicalCookie(url,
+ cookie_name,
+ cookie_value,
+ cookie_domain,
+ cookie_path,
+ creation_time,
+ expiration_time,
+ last_access_time,
+ secure,
+ httponly,
COOKIE_PRIORITY_MEDIUM));
EXPECT_TRUE(cookie->IsEquivalent(*other_cookie));
// Tests that use different variations of attribute values that
// DON'T affect cookie equivalence.
- other_cookie.reset(new CanonicalCookie(url, cookie_name, "2", cookie_domain,
- cookie_path, creation_time,
- expiration_time, last_access_time,
- secure, httponly,
+ other_cookie.reset(new CanonicalCookie(url,
+ cookie_name,
+ "2",
+ cookie_domain,
+ cookie_path,
+ creation_time,
+ expiration_time,
+ last_access_time,
+ secure,
+ httponly,
COOKIE_PRIORITY_HIGH));
EXPECT_TRUE(cookie->IsEquivalent(*other_cookie));
base::Time other_creation_time =
creation_time + base::TimeDelta::FromMinutes(2);
- other_cookie.reset(new CanonicalCookie(url, cookie_name, "2", cookie_domain,
- cookie_path, other_creation_time,
- expiration_time, last_access_time,
- secure, httponly,
+ other_cookie.reset(new CanonicalCookie(url,
+ cookie_name,
+ "2",
+ cookie_domain,
+ cookie_path,
+ other_creation_time,
+ expiration_time,
+ last_access_time,
+ secure,
+ httponly,
COOKIE_PRIORITY_MEDIUM));
EXPECT_TRUE(cookie->IsEquivalent(*other_cookie));
- other_cookie.reset(new CanonicalCookie(url, cookie_name, cookie_name,
- cookie_domain, cookie_path,
- creation_time, expiration_time,
- last_access_time, true, httponly,
+ other_cookie.reset(new CanonicalCookie(url,
+ cookie_name,
+ cookie_name,
+ cookie_domain,
+ cookie_path,
+ creation_time,
+ expiration_time,
+ last_access_time,
+ true,
+ httponly,
COOKIE_PRIORITY_LOW));
EXPECT_TRUE(cookie->IsEquivalent(*other_cookie));
// Tests that use different variations of attribute values that
// DO affect cookie equivalence.
- other_cookie.reset(new CanonicalCookie(url, "B", cookie_value, cookie_domain,
- cookie_path, creation_time,
- expiration_time, last_access_time,
- secure, httponly,
+ other_cookie.reset(new CanonicalCookie(url,
+ "B",
+ cookie_value,
+ cookie_domain,
+ cookie_path,
+ creation_time,
+ expiration_time,
+ last_access_time,
+ secure,
+ httponly,
COOKIE_PRIORITY_MEDIUM));
EXPECT_FALSE(cookie->IsEquivalent(*other_cookie));
- other_cookie.reset(new CanonicalCookie(url, cookie_name, cookie_value,
- "www.example.com", cookie_path,
- creation_time, expiration_time,
- last_access_time, secure, httponly,
+ other_cookie.reset(new CanonicalCookie(url,
+ cookie_name,
+ cookie_value,
+ "www.example.com",
+ cookie_path,
+ creation_time,
+ expiration_time,
+ last_access_time,
+ secure,
+ httponly,
COOKIE_PRIORITY_MEDIUM));
EXPECT_TRUE(cookie->IsDomainCookie());
EXPECT_FALSE(other_cookie->IsDomainCookie());
EXPECT_FALSE(cookie->IsEquivalent(*other_cookie));
- other_cookie.reset(new CanonicalCookie(url, cookie_name, cookie_value,
- ".example.com", cookie_path,
- creation_time, expiration_time,
- last_access_time, secure, httponly,
+ other_cookie.reset(new CanonicalCookie(url,
+ cookie_name,
+ cookie_value,
+ ".example.com",
+ cookie_path,
+ creation_time,
+ expiration_time,
+ last_access_time,
+ secure,
+ httponly,
COOKIE_PRIORITY_MEDIUM));
EXPECT_FALSE(cookie->IsEquivalent(*other_cookie));
- other_cookie.reset(new CanonicalCookie(url, cookie_name, cookie_value,
- cookie_domain, "/test/0",
- creation_time, expiration_time,
- last_access_time, secure, httponly,
+ other_cookie.reset(new CanonicalCookie(url,
+ cookie_name,
+ cookie_value,
+ cookie_domain,
+ "/test/0",
+ creation_time,
+ expiration_time,
+ last_access_time,
+ secure,
+ httponly,
COOKIE_PRIORITY_MEDIUM));
EXPECT_FALSE(cookie->IsEquivalent(*other_cookie));
}
@@ -274,9 +350,8 @@ TEST(CanonicalCookieTest, IsDomainMatch) {
EXPECT_FALSE(cookie->IsDomainMatch("www0.example.com"));
EXPECT_FALSE(cookie->IsDomainMatch("example.com"));
- cookie.reset(
- CanonicalCookie::Create(url, "A=2; Domain=www.example.com", creation_time,
- options));
+ cookie.reset(CanonicalCookie::Create(
+ url, "A=2; Domain=www.example.com", creation_time, options));
EXPECT_TRUE(cookie->IsDomainCookie());
EXPECT_TRUE(cookie->IsDomainMatch("www.example.com"));
EXPECT_TRUE(cookie->IsDomainMatch("www.example.com"));
@@ -284,9 +359,8 @@ TEST(CanonicalCookieTest, IsDomainMatch) {
EXPECT_FALSE(cookie->IsDomainMatch("www0.example.com"));
EXPECT_FALSE(cookie->IsDomainMatch("example.com"));
- cookie.reset(
- CanonicalCookie::Create(url, "A=2; Domain=.www.example.com",
- creation_time, options));
+ cookie.reset(CanonicalCookie::Create(
+ url, "A=2; Domain=.www.example.com", creation_time, options));
EXPECT_TRUE(cookie->IsDomainMatch("www.example.com"));
EXPECT_TRUE(cookie->IsDomainMatch("www.example.com"));
EXPECT_TRUE(cookie->IsDomainMatch("foo.www.example.com"));
@@ -298,9 +372,8 @@ TEST(CanonicalCookieTest, IsOnPath) {
base::Time creation_time = base::Time::Now();
CookieOptions options;
- scoped_ptr<CanonicalCookie> cookie(
- CanonicalCookie::Create(GURL("http://www.example.com"),
- "A=2", creation_time, options));
+ scoped_ptr<CanonicalCookie> cookie(CanonicalCookie::Create(
+ GURL("http://www.example.com"), "A=2", creation_time, options));
EXPECT_TRUE(cookie->IsOnPath("/"));
EXPECT_TRUE(cookie->IsOnPath("/test"));
EXPECT_TRUE(cookie->IsOnPath("/test/bar.html"));
@@ -310,7 +383,9 @@ TEST(CanonicalCookieTest, IsOnPath) {
cookie.reset(
CanonicalCookie::Create(GURL("http://www.example.com/test/foo.html"),
- "A=2", creation_time, options));
+ "A=2",
+ creation_time,
+ options));
EXPECT_FALSE(cookie->IsOnPath("/"));
EXPECT_TRUE(cookie->IsOnPath("/test"));
EXPECT_TRUE(cookie->IsOnPath("/test/bar.html"));
@@ -329,23 +404,23 @@ TEST(CanonicalCookieTest, IncludeForRequestURL) {
GURL("http://www.example.com/foo/bar"), options));
EXPECT_TRUE(cookie->IncludeForRequestURL(
GURL("https://www.example.com/foo/bar"), options));
- EXPECT_FALSE(cookie->IncludeForRequestURL(GURL("https://sub.example.com"),
- options));
+ EXPECT_FALSE(
+ cookie->IncludeForRequestURL(GURL("https://sub.example.com"), options));
EXPECT_FALSE(cookie->IncludeForRequestURL(GURL("https://sub.www.example.com"),
options));
// Test that cookie with a cookie path that does not match the url path are
// not included.
- cookie.reset(CanonicalCookie::Create(url, "A=2; Path=/foo/bar", creation_time,
- options));
+ cookie.reset(CanonicalCookie::Create(
+ url, "A=2; Path=/foo/bar", creation_time, options));
EXPECT_FALSE(cookie->IncludeForRequestURL(url, options));
EXPECT_TRUE(cookie->IncludeForRequestURL(
GURL("http://www.example.com/foo/bar/index.html"), options));
// Test that a secure cookie is not included for a non secure URL.
GURL secure_url("https://www.example.com");
- cookie.reset(CanonicalCookie::Create(secure_url, "A=2; Secure", creation_time,
- options));
+ cookie.reset(CanonicalCookie::Create(
+ secure_url, "A=2; Secure", creation_time, options));
EXPECT_TRUE(cookie->IsSecure());
EXPECT_TRUE(cookie->IncludeForRequestURL(secure_url, options));
EXPECT_FALSE(cookie->IncludeForRequestURL(url, options));

Powered by Google App Engine
This is Rietveld 408576698