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

Unified Diff: content/browser/dom_storage/dom_storage_context_impl_unittest.cc

Issue 22297005: Move webkit/{browser,common}/dom_storage into content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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: content/browser/dom_storage/dom_storage_context_impl_unittest.cc
diff --git a/webkit/browser/dom_storage/dom_storage_context_unittest.cc b/content/browser/dom_storage/dom_storage_context_impl_unittest.cc
similarity index 78%
rename from webkit/browser/dom_storage/dom_storage_context_unittest.cc
rename to content/browser/dom_storage/dom_storage_context_impl_unittest.cc
index 8c0d155ec3613807146ba39fe44ba14608021c94..6a00055e7514566d906fa73137ed0f23fad55bca 100644
--- a/webkit/browser/dom_storage/dom_storage_context_unittest.cc
+++ b/content/browser/dom_storage/dom_storage_context_impl_unittest.cc
@@ -10,19 +10,20 @@
#include "base/strings/utf_string_conversions.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/time/time.h"
+#include "content/browser/dom_storage/dom_storage_area.h"
+#include "content/browser/dom_storage/dom_storage_context_impl.h"
+#include "content/browser/dom_storage/dom_storage_namespace.h"
+#include "content/browser/dom_storage/dom_storage_task_runner.h"
+#include "content/public/browser/local_storage_usage_info.h"
+#include "content/public/browser/session_storage_usage_info.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/dom_storage/dom_storage_area.h"
-#include "webkit/browser/dom_storage/dom_storage_context.h"
-#include "webkit/browser/dom_storage/dom_storage_namespace.h"
-#include "webkit/browser/dom_storage/dom_storage_task_runner.h"
#include "webkit/browser/quota/mock_special_storage_policy.h"
-#include "webkit/common/dom_storage/dom_storage_types.h"
-namespace dom_storage {
+namespace content {
-class DomStorageContextTest : public testing::Test {
+class DOMStorageContextImplTest : public testing::Test {
public:
- DomStorageContextTest()
+ DOMStorageContextImplTest()
: kOrigin(GURL("http://dom_storage/")),
kKey(ASCIIToUTF16("key")),
kValue(ASCIIToUTF16("value")),
@@ -40,11 +41,11 @@ class DomStorageContextTest : public testing::Test {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
storage_policy_ = new quota::MockSpecialStoragePolicy;
task_runner_ =
- new MockDomStorageTaskRunner(base::MessageLoopProxy::current().get());
- context_ = new DomStorageContext(temp_dir_.path(),
- base::FilePath(),
- storage_policy_.get(),
- task_runner_.get());
+ new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get());
+ context_ = new DOMStorageContextImpl(temp_dir_.path(),
+ base::FilePath(),
+ storage_policy_.get(),
+ task_runner_.get());
}
virtual void TearDown() {
@@ -53,8 +54,9 @@ class DomStorageContextTest : public testing::Test {
void VerifySingleOriginRemains(const GURL& origin) {
// Use a new instance to examine the contexts of temp_dir_.
- scoped_refptr<DomStorageContext> context =
- new DomStorageContext(temp_dir_.path(), base::FilePath(), NULL, NULL);
+ scoped_refptr<DOMStorageContextImpl> context =
+ new DOMStorageContextImpl(temp_dir_.path(), base::FilePath(),
+ NULL, NULL);
std::vector<LocalStorageUsageInfo> infos;
context->GetLocalStorageUsage(&infos, kDontIncludeFileInfo);
ASSERT_EQ(1u, infos.size());
@@ -65,12 +67,12 @@ class DomStorageContextTest : public testing::Test {
base::MessageLoop message_loop_;
base::ScopedTempDir temp_dir_;
scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy_;
- scoped_refptr<MockDomStorageTaskRunner> task_runner_;
- scoped_refptr<DomStorageContext> context_;
- DISALLOW_COPY_AND_ASSIGN(DomStorageContextTest);
+ scoped_refptr<MockDOMStorageTaskRunner> task_runner_;
+ scoped_refptr<DOMStorageContextImpl> context_;
+ DISALLOW_COPY_AND_ASSIGN(DOMStorageContextImplTest);
};
-TEST_F(DomStorageContextTest, Basics) {
+TEST_F(DOMStorageContextImplTest, Basics) {
// This test doesn't do much, checks that the constructor
// initializes members properly and that invoking methods
// on a newly created object w/o any data on disk do no harm.
@@ -89,7 +91,7 @@ TEST_F(DomStorageContextTest, Basics) {
context_->Shutdown();
}
-TEST_F(DomStorageContextTest, UsageInfo) {
+TEST_F(DOMStorageContextImplTest, UsageInfo) {
// Should be empty initially
std::vector<LocalStorageUsageInfo> infos;
context_->GetLocalStorageUsage(&infos, kDontIncludeFileInfo);
@@ -108,7 +110,8 @@ TEST_F(DomStorageContextTest, UsageInfo) {
// Create a new context that points to the same directory, see that
// it knows about the origin that we stored data for.
- context_ = new DomStorageContext(temp_dir_.path(), base::FilePath(), NULL, NULL);
+ context_ = new DOMStorageContextImpl(temp_dir_.path(), base::FilePath(),
+ NULL, NULL);
context_->GetLocalStorageUsage(&infos, kDontIncludeFileInfo);
EXPECT_EQ(1u, infos.size());
EXPECT_EQ(kOrigin, infos[0].origin);
@@ -122,7 +125,7 @@ TEST_F(DomStorageContextTest, UsageInfo) {
EXPECT_NE(base::Time(), infos[0].last_modified);
}
-TEST_F(DomStorageContextTest, SessionOnly) {
+TEST_F(DOMStorageContextImplTest, SessionOnly) {
const GURL kSessionOnlyOrigin("http://www.sessiononly.com/");
storage_policy_->AddSessionOnly(kSessionOnlyOrigin);
@@ -142,7 +145,7 @@ TEST_F(DomStorageContextTest, SessionOnly) {
VerifySingleOriginRemains(kOrigin);
}
-TEST_F(DomStorageContextTest, SetForceKeepSessionState) {
+TEST_F(DOMStorageContextImplTest, SetForceKeepSessionState) {
const GURL kSessionOnlyOrigin("http://www.sessiononly.com/");
storage_policy_->AddSessionOnly(kSessionOnlyOrigin);
@@ -159,17 +162,17 @@ TEST_F(DomStorageContextTest, SetForceKeepSessionState) {
VerifySingleOriginRemains(kSessionOnlyOrigin);
}
-TEST_F(DomStorageContextTest, PersistentIds) {
+TEST_F(DOMStorageContextImplTest, PersistentIds) {
const int kFirstSessionStorageNamespaceId = 1;
const std::string kPersistentId = "persistent";
context_->CreateSessionNamespace(kFirstSessionStorageNamespaceId,
kPersistentId);
- DomStorageNamespace* dom_namespace =
+ DOMStorageNamespace* dom_namespace =
context_->GetStorageNamespace(kFirstSessionStorageNamespaceId);
ASSERT_TRUE(dom_namespace);
EXPECT_EQ(kPersistentId, dom_namespace->persistent_namespace_id());
// Verify that the areas inherit the persistent ID.
- DomStorageArea* area = dom_namespace->OpenStorageArea(kOrigin);
+ DOMStorageArea* area = dom_namespace->OpenStorageArea(kOrigin);
EXPECT_EQ(kPersistentId, area->persistent_namespace_id_);
// Verify that the persistent IDs are handled correctly when cloning.
@@ -178,22 +181,22 @@ TEST_F(DomStorageContextTest, PersistentIds) {
context_->CloneSessionNamespace(kFirstSessionStorageNamespaceId,
kClonedSessionStorageNamespaceId,
kClonedPersistentId);
- DomStorageNamespace* cloned_dom_namespace =
+ DOMStorageNamespace* cloned_dom_namespace =
context_->GetStorageNamespace(kClonedSessionStorageNamespaceId);
ASSERT_TRUE(dom_namespace);
EXPECT_EQ(kClonedPersistentId,
cloned_dom_namespace->persistent_namespace_id());
// Verify that the areas inherit the persistent ID.
- DomStorageArea* cloned_area = cloned_dom_namespace->OpenStorageArea(kOrigin);
+ DOMStorageArea* cloned_area = cloned_dom_namespace->OpenStorageArea(kOrigin);
EXPECT_EQ(kClonedPersistentId, cloned_area->persistent_namespace_id_);
}
-TEST_F(DomStorageContextTest, DeleteSessionStorage) {
- // Create a DomStorageContext which will save sessionStorage on disk.
- context_ = new DomStorageContext(temp_dir_.path(),
- temp_dir_.path(),
- storage_policy_.get(),
- task_runner_.get());
+TEST_F(DOMStorageContextImplTest, DeleteSessionStorage) {
+ // Create a DOMStorageContextImpl which will save sessionStorage on disk.
+ context_ = new DOMStorageContextImpl(temp_dir_.path(),
+ temp_dir_.path(),
+ storage_policy_.get(),
+ task_runner_.get());
context_->SetSaveSessionStorageOnDisk();
ASSERT_EQ(temp_dir_.path(), context_->sessionstorage_directory());
@@ -202,20 +205,20 @@ TEST_F(DomStorageContextTest, DeleteSessionStorage) {
const std::string kPersistentId = "persistent";
context_->CreateSessionNamespace(kSessionStorageNamespaceId,
kPersistentId);
- DomStorageNamespace* dom_namespace =
+ DOMStorageNamespace* dom_namespace =
context_->GetStorageNamespace(kSessionStorageNamespaceId);
- DomStorageArea* area = dom_namespace->OpenStorageArea(kOrigin);
+ DOMStorageArea* area = dom_namespace->OpenStorageArea(kOrigin);
const base::string16 kKey(ASCIIToUTF16("foo"));
const base::string16 kValue(ASCIIToUTF16("bar"));
base::NullableString16 old_nullable_value;
area->SetItem(kKey, kValue, &old_nullable_value);
dom_namespace->CloseStorageArea(area);
- // Destroy and recreate the DomStorageContext.
+ // Destroy and recreate the DOMStorageContextImpl.
context_->Shutdown();
context_ = NULL;
base::MessageLoop::current()->RunUntilIdle();
- context_ = new DomStorageContext(
+ context_ = new DOMStorageContextImpl(
temp_dir_.path(), temp_dir_.path(),
storage_policy_.get(), task_runner_.get());
context_->SetSaveSessionStorageOnDisk();
@@ -239,7 +242,7 @@ TEST_F(DomStorageContextTest, DeleteSessionStorage) {
context_->Shutdown();
context_ = NULL;
base::MessageLoop::current()->RunUntilIdle();
- context_ = new DomStorageContext(
+ context_ = new DOMStorageContextImpl(
temp_dir_.path(), temp_dir_.path(),
storage_policy_.get(), task_runner_.get());
context_->SetSaveSessionStorageOnDisk();
@@ -257,4 +260,4 @@ TEST_F(DomStorageContextTest, DeleteSessionStorage) {
base::MessageLoop::current()->RunUntilIdle();
}
-} // namespace dom_storage
+} // namespace content
« no previous file with comments | « content/browser/dom_storage/dom_storage_context_impl.cc ('k') | content/browser/dom_storage/dom_storage_context_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698