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

Unified Diff: net/cookies/canonical_cookie_unittest.cc

Issue 929303003: clang-formatting files in //net/cookies to clear up a diff. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | net/cookies/cookie_monster.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..46d730bead62a67573cd35d06d9502f762a06bae 100644
--- a/net/cookies/canonical_cookie_unittest.cc
+++ b/net/cookies/canonical_cookie_unittest.cc
@@ -13,33 +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:1234/")));
- EXPECT_EQ("http://example.com/",
- CanonicalCookie::GetCookieSourceFromURL(
- GURL("https://example.com/")));
- EXPECT_EQ("http://example.com/",
- CanonicalCookie::GetCookieSourceFromURL(
- GURL("http://user:pwd@example.com/")));
- EXPECT_EQ("http://example.com/",
- CanonicalCookie::GetCookieSourceFromURL(
- GURL("http://example.com/test?foo")));
- EXPECT_EQ("http://example.com/",
- CanonicalCookie::GetCookieSourceFromURL(
- GURL("http://example.com/test#foo")));
+ 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("http://user:pwd@example.com/")));
+ EXPECT_EQ("http://example.com/", CanonicalCookie::GetCookieSourceFromURL(
+ GURL("http://example.com/test?foo")));
+ EXPECT_EQ("http://example.com/", CanonicalCookie::GetCookieSourceFromURL(
+ GURL("http://example.com/test#foo")));
}
TEST(CanonicalCookieTest, Constructor) {
@@ -56,24 +47,15 @@ TEST(CanonicalCookieTest, Constructor) {
EXPECT_EQ("/test", cookie.Path());
EXPECT_FALSE(cookie.IsSecure());
- CanonicalCookie cookie2(url,
- "A",
- "2",
- std::string(),
- std::string(),
- current_time,
- base::Time(),
- current_time,
- false,
- false,
- COOKIE_PRIORITY_DEFAULT);
+ CanonicalCookie cookie2(url, "A", "2", std::string(), std::string(),
+ current_time, base::Time(), current_time, false,
+ false, COOKIE_PRIORITY_DEFAULT);
EXPECT_EQ(url.GetOrigin().spec(), cookie.Source());
EXPECT_EQ("A", cookie2.Name());
EXPECT_EQ("2", cookie2.Value());
EXPECT_EQ("", cookie2.Domain());
EXPECT_EQ("", cookie2.Path());
EXPECT_FALSE(cookie2.IsSecure());
-
}
TEST(CanonicalCookieTest, Create) {
@@ -83,7 +65,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 +95,15 @@ 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 +111,9 @@ 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 +129,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 +138,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 +147,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));
@@ -187,76 +168,66 @@ TEST(CanonicalCookieTest, IsEquivalent) {
bool httponly(false);
// 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,
- COOKIE_PRIORITY_MEDIUM));
+ scoped_ptr<CanonicalCookie> cookie(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,
- COOKIE_PRIORITY_MEDIUM));
+ 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,
+ 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,
- COOKIE_PRIORITY_HIGH));
+ 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,
- COOKIE_PRIORITY_MEDIUM));
+ 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,
- COOKIE_PRIORITY_LOW));
+ 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,
- COOKIE_PRIORITY_MEDIUM));
+ 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,
- COOKIE_PRIORITY_MEDIUM));
+ 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,
- COOKIE_PRIORITY_MEDIUM));
+ 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,
- COOKIE_PRIORITY_MEDIUM));
+ 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 +245,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 +254,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 +267,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"));
@@ -329,8 +297,8 @@ 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));
« no previous file with comments | « no previous file | net/cookies/cookie_monster.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698