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

Unified Diff: net/cookies/cookie_monster_unittest.cc

Issue 10704242: Fix 6 failures in net unittests on Android (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebase Created 8 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 | « build/android/gtest_filter/net_unittests_disabled ('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 c69c805a6d390f1e2e59d22d03e199c2e3f8b3aa..7c04aebec75e5cf3931979839d3b3c55ab7e3849 100644
--- a/net/cookies/cookie_monster_unittest.cc
+++ b/net/cookies/cookie_monster_unittest.cc
@@ -984,19 +984,34 @@ TEST_F(CookieMonsterTest, TestCookieDeleteAll) {
EXPECT_EQ(2, DeleteAll(cm));
EXPECT_EQ("", GetCookiesWithOptions(cm, url_google_, options));
-
+#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
+ // If a cookie is persistent then its commands will be recorded.
+ // Each above cookie has 2 commands: 1 for add and 1 for delete.
+ EXPECT_EQ(4u, store->commands().size());
+#else
EXPECT_EQ(0u, store->commands().size());
+#endif
// Create a persistent cookie.
EXPECT_TRUE(SetCookie(cm, url_google_,
std::string(kValidCookieLine) +
"; expires=Mon, 18-Apr-22 22:50:13 GMT"));
+#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
+ ASSERT_EQ(5u, store->commands().size());
+ EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[4].type);
+#else
ASSERT_EQ(1u, store->commands().size());
EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[0].type);
+#endif
EXPECT_EQ(1, DeleteAll(cm)); // sync_to_store = true.
+#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
+ ASSERT_EQ(6u, store->commands().size());
+ EXPECT_EQ(CookieStoreCommand::REMOVE, store->commands()[5].type);
+#else
ASSERT_EQ(2u, store->commands().size());
EXPECT_EQ(CookieStoreCommand::REMOVE, store->commands()[1].type);
+#endif
EXPECT_EQ("", GetCookiesWithOptions(cm, url_google_, options));
}
@@ -1431,8 +1446,13 @@ TEST_F(CookieMonsterTest, Delegate) {
EXPECT_TRUE(
SetCookie(cm, url_google_, "a=val1; path=/path1; "
"expires=Mon, 18-Apr-22 22:50:13 GMT"));
+#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
+ ASSERT_EQ(5u, store->commands().size());
+ EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[4].type);
+#else
ASSERT_EQ(1u, store->commands().size());
EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[0].type);
+#endif
ASSERT_EQ(1u, delegate->changes().size());
EXPECT_FALSE(delegate->changes()[0].second);
EXPECT_EQ(url_google_.host(), delegate->changes()[0].first.Domain());
@@ -1449,9 +1469,15 @@ TEST_F(CookieMonsterTest, Delegate) {
"a=val2; path=/path1; httponly; "
"expires=Mon, 18-Apr-22 22:50:14 GMT",
allow_httponly));
+#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
+ ASSERT_EQ(7u, store->commands().size());
+ EXPECT_EQ(CookieStoreCommand::REMOVE, store->commands()[5].type);
+ EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[6].type);
+#else
ASSERT_EQ(3u, store->commands().size());
EXPECT_EQ(CookieStoreCommand::REMOVE, store->commands()[1].type);
EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[2].type);
+#endif
ASSERT_EQ(2u, delegate->changes().size());
EXPECT_EQ(url_google_.host(), delegate->changes()[0].first.Domain());
EXPECT_TRUE(delegate->changes()[0].second);
@@ -1502,7 +1528,11 @@ TEST_F(CookieMonsterTest, SetCookieWithDetails) {
EXPECT_EQ("B", it->Value());
EXPECT_EQ("www.google.izzle", it->Domain());
EXPECT_EQ("/foo", it->Path());
+#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
+ EXPECT_TRUE(it->IsPersistent());
+#else
EXPECT_FALSE(it->IsPersistent());
+#endif
EXPECT_FALSE(it->IsSecure());
EXPECT_FALSE(it->IsHttpOnly());
@@ -2064,8 +2094,13 @@ TEST_F(CookieMonsterTest, HistogramCheck) {
// kValidCookieLine creates a session cookie.
ASSERT_TRUE(SetCookie(cm, url_google_, kValidCookieLine));
expired_histogram->SnapshotSample(&histogram_set_1);
+#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
+ EXPECT_EQ(histogram_set_2.TotalCount() + 1,
+ histogram_set_1.TotalCount());
+#else
EXPECT_EQ(histogram_set_2.TotalCount(),
histogram_set_1.TotalCount());
+#endif
}
namespace {
@@ -2304,7 +2339,11 @@ TEST_F(CookieMonsterTest, InvalidExpiryTime) {
scoped_ptr<CookieMonster::CanonicalCookie> cookie(
CookieMonster::CanonicalCookie::Create(url_google_, pc));
+#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
+ ASSERT_TRUE(cookie->IsPersistent());
+#else
ASSERT_FALSE(cookie->IsPersistent());
+#endif
}
// Test that CookieMonster writes session cookies into the underlying
@@ -2381,7 +2420,11 @@ TEST_F(CookieMonsterTest, PersisentCookieStorageTest) {
// persistent storage.
EXPECT_TRUE(SetCookie(cm, url_google_, "B=Bar"));
this->MatchCookieLines("A=Foo; B=Bar", GetCookies(cm, url_google_));
+#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
+ EXPECT_EQ(6u, store->commands().size());
+#else
EXPECT_EQ(5u, store->commands().size());
+#endif
}
} // namespace net
« no previous file with comments | « build/android/gtest_filter/net_unittests_disabled ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698