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

Unified Diff: net/extras/sqlite/sqlite_persistent_cookie_store_unittest.cc

Issue 1231493002: mandoline filesystem: Save cookie data to the mojo:filesystem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with ToT Created 5 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
Index: net/extras/sqlite/sqlite_persistent_cookie_store_unittest.cc
diff --git a/net/extras/sqlite/sqlite_persistent_cookie_store_unittest.cc b/net/extras/sqlite/sqlite_persistent_cookie_store_unittest.cc
index 6dc3810f8f63501b64be06cca7e5d2af5ed45975..aa7efbc365ee62d2ac36ae660eed5bccc78b13d9 100644
--- a/net/extras/sqlite/sqlite_persistent_cookie_store_unittest.cc
+++ b/net/extras/sqlite/sqlite_persistent_cookie_store_unittest.cc
@@ -127,9 +127,7 @@ class SQLitePersistentCookieStoreTest : public testing::Test {
pool_owner_.reset(new base::SequencedWorkerPoolOwner(3, "Background Pool"));
}
- void CreateAndLoad(bool crypt_cookies,
- bool restore_old_session_cookies,
- CanonicalCookieVector* cookies) {
+ void Create(bool crypt_cookies, bool restore_old_session_cookies) {
if (crypt_cookies)
cookie_crypto_delegate_.reset(new CookieCryptor());
@@ -137,6 +135,12 @@ class SQLitePersistentCookieStoreTest : public testing::Test {
temp_dir_.path().Append(kCookieFilename), client_task_runner(),
background_task_runner(), restore_old_session_cookies,
cookie_crypto_delegate_.get());
+ }
+
+ void CreateAndLoad(bool crypt_cookies,
+ bool restore_old_session_cookies,
+ CanonicalCookieVector* cookies) {
+ Create(crypt_cookies, restore_old_session_cookies);
Load(cookies);
}
@@ -660,4 +664,34 @@ TEST_F(SQLitePersistentCookieStoreTest, UpdateToEncryption) {
EXPECT_EQ(contents.find("something456ABC"), std::string::npos);
}
+namespace {
+void WasCalledWithNoCookies(bool* was_called_with_no_cookies,
+ const std::vector<CanonicalCookie*>& cookies) {
+ *was_called_with_no_cookies = cookies.empty();
+}
+}
+
+TEST_F(SQLitePersistentCookieStoreTest, EmptyLoadAfterClose) {
+ // Create unencrypted cookie store and write something to it.
+ InitializeStore(false, false);
+ AddCookie("name", "value123XYZ", "foo.bar", "/", base::Time::Now());
+ DestroyStore();
+
+ // Create the cookie store, but immediately close it.
+ Create(false, false);
+ store_->Close(base::Closure());
+
+ // Expect any attempt to call Load() to synchronously respond with an empty
+ // vector of cookies after we've Close()d the database.
+ bool was_called_with_no_cookies = false;
+ store_->Load(base::Bind(WasCalledWithNoCookies, &was_called_with_no_cookies));
+ EXPECT_TRUE(was_called_with_no_cookies);
+
+ // Same with trying to load a specific cookie.
+ was_called_with_no_cookies = false;
+ store_->LoadCookiesForKey("foo.bar", base::Bind(WasCalledWithNoCookies,
+ &was_called_with_no_cookies));
+ EXPECT_TRUE(was_called_with_no_cookies);
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698