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

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

Issue 1016643004: Moves SQLitePersistentCookieStore to net/extras/sqlite. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cookies
Patch Set: Better timestamp fix. Created 5 years, 8 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/content/browser/net/sqlite_persistent_cookie_store_unittest.cc b/net/extras/sqlite/sqlite_persistent_cookie_store_unittest.cc
similarity index 90%
rename from content/browser/net/sqlite_persistent_cookie_store_unittest.cc
rename to net/extras/sqlite/sqlite_persistent_cookie_store_unittest.cc
index af7859a26a9f1695dc4e8aa7a809245b2ebfad18..b0d6c506795fc1c1b36cd16765c104ce3b10da36 100644
--- a/content/browser/net/sqlite_persistent_cookie_store_unittest.cc
+++ b/net/extras/sqlite/sqlite_persistent_cookie_store_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/net/sqlite_persistent_cookie_store.h"
+#include "net/extras/sqlite/sqlite_persistent_cookie_store.h"
#include <map>
#include <set>
@@ -11,15 +11,14 @@
#include "base/callback.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
+#include "base/location.h"
#include "base/memory/ref_counted.h"
-#include "base/message_loop/message_loop.h"
#include "base/sequenced_task_runner.h"
#include "base/stl_util.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/sequenced_worker_pool_owner.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/time/time.h"
-#include "content/public/browser/cookie_store_factory.h"
#include "crypto/encryptor.h"
#include "crypto/symmetric_key.h"
#include "net/cookies/canonical_cookie.h"
@@ -31,13 +30,13 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
-namespace content {
+namespace net {
namespace {
const base::FilePath::CharType kCookieFilename[] = FILE_PATH_LITERAL("Cookies");
-class CookieCryptor : public net::CookieCryptoDelegate {
+class CookieCryptor : public CookieCryptoDelegate {
public:
CookieCryptor();
bool EncryptString(const std::string& plaintext,
@@ -69,7 +68,7 @@ bool CookieCryptor::DecryptString(const std::string& ciphertext,
} // namespace
-typedef std::vector<net::CanonicalCookie*> CanonicalCookieVector;
+typedef std::vector<CanonicalCookie*> CanonicalCookieVector;
class SQLitePersistentCookieStoreTest : public testing::Test {
public:
@@ -136,7 +135,6 @@ class SQLitePersistentCookieStoreTest : public testing::Test {
client_task_runner(),
background_task_runner(),
restore_old_session_cookies,
- NULL,
cookie_crypto_delegate_.get());
Load(cookies);
}
@@ -159,9 +157,9 @@ class SQLitePersistentCookieStoreTest : public testing::Test {
const std::string& domain,
const std::string& path,
const base::Time& creation) {
- store_->AddCookie(net::CanonicalCookie(
+ store_->AddCookie(CanonicalCookie(
GURL(), name, value, domain, path, creation, creation, creation, false,
- false, false, net::COOKIE_PRIORITY_DEFAULT));
+ false, false, COOKIE_PRIORITY_DEFAULT));
}
void AddCookieWithExpiration(const std::string& name,
@@ -170,9 +168,9 @@ class SQLitePersistentCookieStoreTest : public testing::Test {
const std::string& path,
const base::Time& creation,
const base::Time& expiration) {
- store_->AddCookie(net::CanonicalCookie(
+ store_->AddCookie(CanonicalCookie(
GURL(), name, value, domain, path, creation, expiration, creation,
- false, false, false, net::COOKIE_PRIORITY_DEFAULT));
+ false, false, false, COOKIE_PRIORITY_DEFAULT));
}
std::string ReadRawDBContents() {
@@ -191,7 +189,6 @@ class SQLitePersistentCookieStoreTest : public testing::Test {
}
protected:
- base::MessageLoop main_loop_;
scoped_ptr<base::SequencedWorkerPoolOwner> pool_owner_;
base::WaitableEvent loaded_event_;
base::WaitableEvent key_loaded_event_;
@@ -199,7 +196,7 @@ class SQLitePersistentCookieStoreTest : public testing::Test {
CanonicalCookieVector cookies_;
base::ScopedTempDir temp_dir_;
scoped_refptr<SQLitePersistentCookieStore> store_;
- scoped_ptr<net::CookieCryptoDelegate> cookie_crypto_delegate_;
+ scoped_ptr<CookieCryptoDelegate> cookie_crypto_delegate_;
};
TEST_F(SQLitePersistentCookieStoreTest, TestInvalidMetaTableRecovery) {
@@ -300,7 +297,7 @@ TEST_F(SQLitePersistentCookieStoreTest, TestSessionCookiesDeletedOnStartup) {
temp_dir_.path().Append(kCookieFilename),
client_task_runner(),
background_task_runner(),
- false, NULL, NULL);
+ false, NULL);
// Posting a blocking task to db_thread_ makes sure that the DB thread waits
// until both Load and Flush have been posted to its task queue.
@@ -336,7 +333,7 @@ TEST_F(SQLitePersistentCookieStoreTest, TestSessionCookiesDeletedOnStartup) {
temp_dir_.path().Append(kCookieFilename),
client_task_runner(),
background_task_runner(),
- true, NULL, NULL);
+ true, NULL);
store_->Load(base::Bind(&SQLitePersistentCookieStoreTest::OnLoaded,
base::Unretained(this)));
loaded_event_.Wait();
@@ -362,7 +359,7 @@ TEST_F(SQLitePersistentCookieStoreTest, TestLoadCookiesForKey) {
temp_dir_.path().Append(kCookieFilename),
client_task_runner(),
background_task_runner(),
- false, NULL, NULL);
+ false, NULL);
Ryan Sleevi 2015/05/06 00:44:19 Since you have to change all these, does it make s
rohitrao (ping after 24h) 2015/05/11 19:25:30 Might as well, changed everywhere in this file.
// Posting a blocking task to db_thread_ makes sure that the DB thread waits
// until both Load and LoadCookiesForKey have been posted to its task queue.
@@ -447,10 +444,10 @@ TEST_F(SQLitePersistentCookieStoreTest, TestLoadOldSessionCookies) {
InitializeStore(false, true);
// Add a session cookie.
- store_->AddCookie(net::CanonicalCookie(GURL(), "C", "D", "sessioncookie.com",
- "/", base::Time::Now(), base::Time(),
- base::Time::Now(), false, false, false,
- net::COOKIE_PRIORITY_DEFAULT));
+ store_->AddCookie(CanonicalCookie(GURL(), "C", "D", "sessioncookie.com",
+ "/", base::Time::Now(), base::Time(),
+ base::Time::Now(), false, false, false,
+ COOKIE_PRIORITY_DEFAULT));
// Force the store to write its data to the disk.
DestroyStore();
@@ -464,7 +461,7 @@ TEST_F(SQLitePersistentCookieStoreTest, TestLoadOldSessionCookies) {
ASSERT_STREQ("sessioncookie.com", cookies[0]->Domain().c_str());
ASSERT_STREQ("C", cookies[0]->Name().c_str());
ASSERT_STREQ("D", cookies[0]->Value().c_str());
- ASSERT_EQ(net::COOKIE_PRIORITY_DEFAULT, cookies[0]->Priority());
+ ASSERT_EQ(COOKIE_PRIORITY_DEFAULT, cookies[0]->Priority());
STLDeleteElements(&cookies);
}
@@ -474,10 +471,10 @@ TEST_F(SQLitePersistentCookieStoreTest, TestDontLoadOldSessionCookies) {
InitializeStore(false, true);
// Add a session cookie.
- store_->AddCookie(net::CanonicalCookie(GURL(), "C", "D", "sessioncookie.com",
- "/", base::Time::Now(), base::Time(),
- base::Time::Now(), false, false, false,
- net::COOKIE_PRIORITY_DEFAULT));
+ store_->AddCookie(CanonicalCookie(GURL(), "C", "D", "sessioncookie.com",
+ "/", base::Time::Now(), base::Time(),
+ base::Time::Now(), false, false, false,
+ COOKIE_PRIORITY_DEFAULT));
// Force the store to write its data to the disk.
DestroyStore();
@@ -504,16 +501,16 @@ TEST_F(SQLitePersistentCookieStoreTest, PersistIsPersistent) {
static const char kPersistentName[] = "persistent";
// Add a session cookie.
- store_->AddCookie(net::CanonicalCookie(
+ store_->AddCookie(CanonicalCookie(
GURL(), kSessionName, "val", "sessioncookie.com", "/", base::Time::Now(),
base::Time(), base::Time::Now(), false, false, false,
- net::COOKIE_PRIORITY_DEFAULT));
+ COOKIE_PRIORITY_DEFAULT));
// Add a persistent cookie.
- store_->AddCookie(net::CanonicalCookie(
+ store_->AddCookie(CanonicalCookie(
GURL(), kPersistentName, "val", "sessioncookie.com", "/",
base::Time::Now() - base::TimeDelta::FromDays(1),
base::Time::Now() + base::TimeDelta::FromDays(1), base::Time::Now(),
- false, false, false, net::COOKIE_PRIORITY_DEFAULT));
+ false, false, false, COOKIE_PRIORITY_DEFAULT));
// Force the store to write its data to the disk.
DestroyStore();
@@ -524,14 +521,14 @@ TEST_F(SQLitePersistentCookieStoreTest, PersistIsPersistent) {
CreateAndLoad(false, true, &cookies);
ASSERT_EQ(2U, cookies.size());
- std::map<std::string, net::CanonicalCookie*> cookie_map;
+ std::map<std::string, CanonicalCookie*> cookie_map;
for (CanonicalCookieVector::const_iterator it = cookies.begin();
it != cookies.end();
++it) {
cookie_map[(*it)->Name()] = *it;
}
- std::map<std::string, net::CanonicalCookie*>::const_iterator it =
+ std::map<std::string, CanonicalCookie*>::const_iterator it =
cookie_map.find(kSessionName);
ASSERT_TRUE(it != cookie_map.end());
EXPECT_FALSE(cookie_map[kSessionName]->IsPersistent());
@@ -554,25 +551,25 @@ TEST_F(SQLitePersistentCookieStoreTest, PriorityIsPersistent) {
InitializeStore(false, true);
// Add a low-priority persistent cookie.
- store_->AddCookie(net::CanonicalCookie(
+ store_->AddCookie(CanonicalCookie(
GURL(), kLowName, kCookieValue, kCookieDomain, kCookiePath,
base::Time::Now() - base::TimeDelta::FromMinutes(1),
base::Time::Now() + base::TimeDelta::FromDays(1), base::Time::Now(),
- false, false, false, net::COOKIE_PRIORITY_LOW));
+ false, false, false, COOKIE_PRIORITY_LOW));
// Add a medium-priority persistent cookie.
- store_->AddCookie(net::CanonicalCookie(
+ store_->AddCookie(CanonicalCookie(
GURL(), kMediumName, kCookieValue, kCookieDomain, kCookiePath,
base::Time::Now() - base::TimeDelta::FromMinutes(2),
base::Time::Now() + base::TimeDelta::FromDays(1), base::Time::Now(),
- false, false, false, net::COOKIE_PRIORITY_MEDIUM));
+ false, false, false, COOKIE_PRIORITY_MEDIUM));
// Add a high-priority peristent cookie.
- store_->AddCookie(net::CanonicalCookie(
+ store_->AddCookie(CanonicalCookie(
GURL(), kHighName, kCookieValue, kCookieDomain, kCookiePath,
base::Time::Now() - base::TimeDelta::FromMinutes(3),
base::Time::Now() + base::TimeDelta::FromDays(1), base::Time::Now(),
- false, false, false, net::COOKIE_PRIORITY_HIGH));
+ false, false, false, COOKIE_PRIORITY_HIGH));
// Force the store to write its data to the disk.
DestroyStore();
@@ -584,7 +581,7 @@ TEST_F(SQLitePersistentCookieStoreTest, PriorityIsPersistent) {
ASSERT_EQ(3U, cookies.size());
// Put the cookies into a map, by name, so we can easily find them.
- std::map<std::string, net::CanonicalCookie*> cookie_map;
+ std::map<std::string, CanonicalCookie*> cookie_map;
for (CanonicalCookieVector::const_iterator it = cookies.begin();
it != cookies.end();
++it) {
@@ -592,18 +589,18 @@ TEST_F(SQLitePersistentCookieStoreTest, PriorityIsPersistent) {
}
// Validate that each cookie has the correct priority.
- std::map<std::string, net::CanonicalCookie*>::const_iterator it =
+ std::map<std::string, CanonicalCookie*>::const_iterator it =
cookie_map.find(kLowName);
ASSERT_TRUE(it != cookie_map.end());
- EXPECT_EQ(net::COOKIE_PRIORITY_LOW, cookie_map[kLowName]->Priority());
+ EXPECT_EQ(COOKIE_PRIORITY_LOW, cookie_map[kLowName]->Priority());
it = cookie_map.find(kMediumName);
ASSERT_TRUE(it != cookie_map.end());
- EXPECT_EQ(net::COOKIE_PRIORITY_MEDIUM, cookie_map[kMediumName]->Priority());
+ EXPECT_EQ(COOKIE_PRIORITY_MEDIUM, cookie_map[kMediumName]->Priority());
it = cookie_map.find(kHighName);
ASSERT_TRUE(it != cookie_map.end());
- EXPECT_EQ(net::COOKIE_PRIORITY_HIGH, cookie_map[kHighName]->Priority());
+ EXPECT_EQ(COOKIE_PRIORITY_HIGH, cookie_map[kHighName]->Priority());
STLDeleteElements(&cookies);
}
@@ -639,8 +636,8 @@ TEST_F(SQLitePersistentCookieStoreTest, UpdateToEncryption) {
STLDeleteElements(&cookies_);
CreateAndLoad(true, false, &cookies);
EXPECT_EQ(2U, cookies_.size());
- net::CanonicalCookie* cookie_name = NULL;
- net::CanonicalCookie* cookie_other = NULL;
+ CanonicalCookie* cookie_name = NULL;
+ CanonicalCookie* cookie_other = NULL;
Ryan Sleevi 2015/05/06 00:44:19 nullptr
rohitrao (ping after 24h) 2015/05/11 19:25:30 Done.
if (cookies_[0]->Name() == "name") {
cookie_name = cookies_[0];
cookie_other = cookies_[1];
@@ -678,4 +675,4 @@ TEST_F(SQLitePersistentCookieStoreTest, UpdateToEncryption) {
EXPECT_EQ(contents.find("something456ABC"), std::string::npos);
}
-} // namespace content
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698