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

Unified Diff: net/cookies/cookie_monster_unittest.cc

Issue 2974363002: Simplify CookieMonster::SetAllCookies{,Async}() implementation. (Closed)
Patch Set: Sync['d up to latest PS on base CL. Created 3 years, 5 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 | « net/cookies/cookie_monster.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/cookie_monster_unittest.cc
diff --git a/net/cookies/cookie_monster_unittest.cc b/net/cookies/cookie_monster_unittest.cc
index 34c4888f0b3cdf5c50ee320459bf2d0b3deb9ac2..7ec0ad22b3cfb9187caf685c0880c06f44e45ab5 100644
--- a/net/cookies/cookie_monster_unittest.cc
+++ b/net/cookies/cookie_monster_unittest.cc
@@ -2660,125 +2660,6 @@ TEST_F(CookieMonsterTest, SetAllCookies) {
EXPECT_EQ("Z", it->Value());
}
-TEST_F(CookieMonsterTest, ComputeCookieDiff) {
- std::unique_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
-
- base::Time now = base::Time::Now();
- base::Time creation_time = now - base::TimeDelta::FromSeconds(1);
-
- std::unique_ptr<CanonicalCookie> cookie1(base::MakeUnique<CanonicalCookie>(
- "A", "B", "." + http_www_foo_.url().host(), "/", creation_time,
- base::Time(), base::Time(), false, false, CookieSameSite::DEFAULT_MODE,
- COOKIE_PRIORITY_DEFAULT));
- std::unique_ptr<CanonicalCookie> cookie2(base::MakeUnique<CanonicalCookie>(
- "C", "D", "." + http_www_foo_.url().host(), "/", creation_time,
- base::Time(), base::Time(), false, false, CookieSameSite::DEFAULT_MODE,
- COOKIE_PRIORITY_DEFAULT));
- std::unique_ptr<CanonicalCookie> cookie3(base::MakeUnique<CanonicalCookie>(
- "E", "F", "." + http_www_foo_.url().host(), "/", creation_time,
- base::Time(), base::Time(), false, false, CookieSameSite::DEFAULT_MODE,
- COOKIE_PRIORITY_DEFAULT));
- std::unique_ptr<CanonicalCookie> cookie4(base::MakeUnique<CanonicalCookie>(
- "G", "H", "." + http_www_foo_.url().host(), "/", creation_time,
- base::Time(), base::Time(), false, false, CookieSameSite::DEFAULT_MODE,
- COOKIE_PRIORITY_DEFAULT));
- std::unique_ptr<CanonicalCookie> cookie4_with_new_value(
- base::MakeUnique<CanonicalCookie>(
- "G", "iamnew", "." + http_www_foo_.url().host(), "/", creation_time,
- base::Time(), base::Time(), false, false,
- CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT));
- std::unique_ptr<CanonicalCookie> cookie5(base::MakeUnique<CanonicalCookie>(
- "I", "J", "." + http_www_foo_.url().host(), "/", creation_time,
- base::Time(), base::Time(), false, false, CookieSameSite::DEFAULT_MODE,
- COOKIE_PRIORITY_DEFAULT));
- std::unique_ptr<CanonicalCookie> cookie5_with_new_creation_time(
- base::MakeUnique<CanonicalCookie>(
- "I", "J", "." + http_www_foo_.url().host(), "/", now, base::Time(),
- base::Time(), false, false, CookieSameSite::DEFAULT_MODE,
- COOKIE_PRIORITY_DEFAULT));
- std::unique_ptr<CanonicalCookie> cookie6(base::MakeUnique<CanonicalCookie>(
- "K", "L", "." + http_www_foo_.url().host(), "/foo", creation_time,
- base::Time(), base::Time(), false, false, CookieSameSite::DEFAULT_MODE,
- COOKIE_PRIORITY_DEFAULT));
- std::unique_ptr<CanonicalCookie> cookie6_with_new_path(
- base::MakeUnique<CanonicalCookie>(
- "K", "L", "." + http_www_foo_.url().host(), "/bar", creation_time,
- base::Time(), base::Time(), false, false,
- CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT));
- std::unique_ptr<CanonicalCookie> cookie7(base::MakeUnique<CanonicalCookie>(
- "M", "N", "." + http_www_foo_.url().host(), "/foo", creation_time,
- base::Time(), base::Time(), false, false, CookieSameSite::DEFAULT_MODE,
- COOKIE_PRIORITY_DEFAULT));
- std::unique_ptr<CanonicalCookie> cookie7_with_new_path(
- base::MakeUnique<CanonicalCookie>(
- "M", "N", "." + http_www_foo_.url().host(), "/bar", creation_time,
- base::Time(), base::Time(), false, false,
- CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT));
-
- CookieList old_cookies;
- old_cookies.push_back(*cookie1);
- old_cookies.push_back(*cookie2);
- old_cookies.push_back(*cookie4);
- old_cookies.push_back(*cookie5);
- old_cookies.push_back(*cookie6);
- old_cookies.push_back(*cookie7);
-
- CookieList new_cookies;
- new_cookies.push_back(*cookie1);
- new_cookies.push_back(*cookie3);
- new_cookies.push_back(*cookie4_with_new_value);
- new_cookies.push_back(*cookie5_with_new_creation_time);
- new_cookies.push_back(*cookie6_with_new_path);
- new_cookies.push_back(*cookie7);
- new_cookies.push_back(*cookie7_with_new_path);
-
- CookieList cookies_to_add;
- CookieList cookies_to_delete;
-
- cm->ComputeCookieDiff(&old_cookies, &new_cookies, &cookies_to_add,
- &cookies_to_delete);
-
- // |cookie1| has not changed.
- EXPECT_FALSE(IsCookieInList(*cookie1, cookies_to_add));
- EXPECT_FALSE(IsCookieInList(*cookie1, cookies_to_delete));
-
- // |cookie2| has been deleted.
- EXPECT_FALSE(IsCookieInList(*cookie2, cookies_to_add));
- EXPECT_TRUE(IsCookieInList(*cookie2, cookies_to_delete));
-
- // |cookie3| has been added.
- EXPECT_TRUE(IsCookieInList(*cookie3, cookies_to_add));
- EXPECT_FALSE(IsCookieInList(*cookie3, cookies_to_delete));
-
- // |cookie4| has a new value: new cookie overrides the old one (which does not
- // need to be explicitly removed).
- EXPECT_FALSE(IsCookieInList(*cookie4, cookies_to_add));
- EXPECT_FALSE(IsCookieInList(*cookie4, cookies_to_delete));
- EXPECT_TRUE(IsCookieInList(*cookie4_with_new_value, cookies_to_add));
- EXPECT_FALSE(IsCookieInList(*cookie4_with_new_value, cookies_to_delete));
-
- // |cookie5| has a new creation time: new cookie overrides the old one (which
- // does not need to be explicitly removed).
- EXPECT_FALSE(IsCookieInList(*cookie5, cookies_to_add));
- EXPECT_FALSE(IsCookieInList(*cookie5, cookies_to_delete));
- EXPECT_TRUE(IsCookieInList(*cookie5_with_new_creation_time, cookies_to_add));
- EXPECT_FALSE(
- IsCookieInList(*cookie5_with_new_creation_time, cookies_to_delete));
-
- // |cookie6| has a new path: the new cookie does not overrides the old one,
- // which needs to be explicitly removed.
- EXPECT_FALSE(IsCookieInList(*cookie6, cookies_to_add));
- EXPECT_TRUE(IsCookieInList(*cookie6, cookies_to_delete));
- EXPECT_TRUE(IsCookieInList(*cookie6_with_new_path, cookies_to_add));
- EXPECT_FALSE(IsCookieInList(*cookie6_with_new_path, cookies_to_delete));
-
- // |cookie7| is kept and |cookie7_with_new_path| is added as a new cookie.
- EXPECT_FALSE(IsCookieInList(*cookie7, cookies_to_add));
- EXPECT_FALSE(IsCookieInList(*cookie7, cookies_to_delete));
- EXPECT_TRUE(IsCookieInList(*cookie7_with_new_path, cookies_to_add));
- EXPECT_FALSE(IsCookieInList(*cookie7_with_new_path, cookies_to_delete));
-}
-
// Check that DeleteAll does flush (as a sanity check that flush_count()
// works).
TEST_F(CookieMonsterTest, DeleteAll) {
« no previous file with comments | « net/cookies/cookie_monster.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698