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

Unified Diff: content/browser/dom_storage/dom_storage_area_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_area_unittest.cc
diff --git a/webkit/browser/dom_storage/dom_storage_area_unittest.cc b/content/browser/dom_storage/dom_storage_area_unittest.cc
similarity index 83%
rename from webkit/browser/dom_storage/dom_storage_area_unittest.cc
rename to content/browser/dom_storage/dom_storage_area_unittest.cc
index 68aff17fc1c23df4e175572c51ad1cbe38dfc66c..83f2b1da50727b08c65553c679472a6961d936ab 100644
--- a/webkit/browser/dom_storage/dom_storage_area_unittest.cc
+++ b/content/browser/dom_storage/dom_storage_area_unittest.cc
@@ -10,20 +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_database.h"
+#include "content/browser/dom_storage/dom_storage_database_adapter.h"
+#include "content/browser/dom_storage/dom_storage_task_runner.h"
+#include "content/browser/dom_storage/local_storage_database_adapter.h"
+#include "content/common/dom_storage/dom_storage_types.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/dom_storage/dom_storage_area.h"
-#include "webkit/browser/dom_storage/dom_storage_database.h"
-#include "webkit/browser/dom_storage/dom_storage_database_adapter.h"
-#include "webkit/browser/dom_storage/dom_storage_task_runner.h"
-#include "webkit/browser/dom_storage/local_storage_database_adapter.h"
-#include "webkit/common/dom_storage/dom_storage_types.h"
-namespace dom_storage {
+namespace content {
-class DomStorageAreaTest : public testing::Test {
+class DOMStorageAreaTest : public testing::Test {
public:
- DomStorageAreaTest()
+ DOMStorageAreaTest()
: kOrigin(GURL("http://dom_storage/")),
kKey(ASCIIToUTF16("key")),
kValue(ASCIIToUTF16("value")),
@@ -38,7 +38,7 @@ class DomStorageAreaTest : public testing::Test {
const base::string16 kValue2;
// Method used in the CommitTasks test case.
- void InjectedCommitSequencingTask(DomStorageArea* area) {
+ void InjectedCommitSequencingTask(DOMStorageArea* area) {
// At this point the OnCommitTimer has run.
// Verify that it put a commit in flight.
EXPECT_EQ(1, area->commit_batches_in_flight_);
@@ -54,13 +54,13 @@ class DomStorageAreaTest : public testing::Test {
}
// Class used in the CommitChangesAtShutdown test case.
- class VerifyChangesCommittedDatabase : public DomStorageDatabase {
+ class VerifyChangesCommittedDatabase : public DOMStorageDatabase {
public:
VerifyChangesCommittedDatabase() {}
virtual ~VerifyChangesCommittedDatabase() {
const base::string16 kKey(ASCIIToUTF16("key"));
const base::string16 kValue(ASCIIToUTF16("value"));
- ValuesMap values;
+ DOMStorageValuesMap values;
ReadAllValues(&values);
EXPECT_EQ(1u, values.size());
EXPECT_EQ(kValue, values[kKey].string());
@@ -71,14 +71,14 @@ class DomStorageAreaTest : public testing::Test {
base::MessageLoop message_loop_;
};
-TEST_F(DomStorageAreaTest, DomStorageAreaBasics) {
- scoped_refptr<DomStorageArea> area(
- new DomStorageArea(1, std::string(), kOrigin, NULL, NULL));
+TEST_F(DOMStorageAreaTest, DOMStorageAreaBasics) {
+ scoped_refptr<DOMStorageArea> area(
+ new DOMStorageArea(1, std::string(), kOrigin, NULL, NULL));
base::string16 old_value;
base::NullableString16 old_nullable_value;
- scoped_refptr<DomStorageArea> copy;
+ scoped_refptr<DOMStorageArea> copy;
- // We don't focus on the underlying DomStorageMap functionality
+ // We don't focus on the underlying DOMStorageMap functionality
// since that's covered by seperate unit tests.
EXPECT_EQ(kOrigin, area->origin());
EXPECT_EQ(1, area->namespace_id());
@@ -122,17 +122,17 @@ TEST_F(DomStorageAreaTest, DomStorageAreaBasics) {
EXPECT_FALSE(area->Clear());
}
-TEST_F(DomStorageAreaTest, BackingDatabaseOpened) {
+TEST_F(DOMStorageAreaTest, BackingDatabaseOpened) {
const int64 kSessionStorageNamespaceId = kLocalStorageNamespaceId + 1;
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
const base::FilePath kExpectedOriginFilePath = temp_dir.path().Append(
- DomStorageArea::DatabaseFileNameFromOrigin(kOrigin));
+ DOMStorageArea::DatabaseFileNameFromOrigin(kOrigin));
// No directory, backing should be null.
{
- scoped_refptr<DomStorageArea> area(
- new DomStorageArea(kOrigin, base::FilePath(), NULL));
+ scoped_refptr<DOMStorageArea> area(
+ new DOMStorageArea(kOrigin, base::FilePath(), NULL));
EXPECT_EQ(NULL, area->backing_.get());
EXPECT_TRUE(area->is_initial_import_done_);
EXPECT_FALSE(base::PathExists(kExpectedOriginFilePath));
@@ -141,8 +141,8 @@ TEST_F(DomStorageAreaTest, BackingDatabaseOpened) {
// Valid directory and origin but no session storage backing. Backing should
// be null.
{
- scoped_refptr<DomStorageArea> area(
- new DomStorageArea(kSessionStorageNamespaceId, std::string(), kOrigin,
+ scoped_refptr<DOMStorageArea> area(
+ new DOMStorageArea(kSessionStorageNamespaceId, std::string(), kOrigin,
NULL, NULL));
EXPECT_EQ(NULL, area->backing_.get());
EXPECT_TRUE(area->is_initial_import_done_);
@@ -156,15 +156,15 @@ TEST_F(DomStorageAreaTest, BackingDatabaseOpened) {
EXPECT_FALSE(base::PathExists(kExpectedOriginFilePath));
}
- // This should set up a DomStorageArea that is correctly backed to disk.
+ // This should set up a DOMStorageArea that is correctly backed to disk.
{
- scoped_refptr<DomStorageArea> area(new DomStorageArea(
+ scoped_refptr<DOMStorageArea> area(new DOMStorageArea(
kOrigin,
temp_dir.path(),
- new MockDomStorageTaskRunner(base::MessageLoopProxy::current().get())));
+ new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get())));
EXPECT_TRUE(area->backing_.get());
- DomStorageDatabase* database = static_cast<LocalStorageDatabaseAdapter*>(
+ DOMStorageDatabase* database = static_cast<LocalStorageDatabaseAdapter*>(
area->backing_.get())->db_.get();
EXPECT_FALSE(database->IsOpen());
EXPECT_FALSE(area->is_initial_import_done_);
@@ -194,21 +194,21 @@ TEST_F(DomStorageAreaTest, BackingDatabaseOpened) {
EXPECT_EQ(kValue, area->GetItem(kKey).string());
// Verify the content made it to the in memory database.
- ValuesMap values;
+ DOMStorageValuesMap values;
area->backing_->ReadAllValues(&values);
EXPECT_EQ(1u, values.size());
EXPECT_EQ(kValue, values[kKey].string());
}
}
-TEST_F(DomStorageAreaTest, CommitTasks) {
+TEST_F(DOMStorageAreaTest, CommitTasks) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- scoped_refptr<DomStorageArea> area(new DomStorageArea(
+ scoped_refptr<DOMStorageArea> area(new DOMStorageArea(
kOrigin,
temp_dir.path(),
- new MockDomStorageTaskRunner(base::MessageLoopProxy::current().get())));
+ new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get())));
// Inject an in-memory db to speed up the test.
area->backing_.reset(new LocalStorageDatabaseAdapter());
@@ -218,7 +218,7 @@ TEST_F(DomStorageAreaTest, CommitTasks) {
EXPECT_EQ(0u, area->Length());
EXPECT_TRUE(area->is_initial_import_done_);
- ValuesMap values;
+ DOMStorageValuesMap values;
base::NullableString16 old_value;
// See that changes are batched up.
@@ -266,7 +266,7 @@ TEST_F(DomStorageAreaTest, CommitTasks) {
// we'll make an additional SetItem() call.
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(&DomStorageAreaTest::InjectedCommitSequencingTask,
+ base::Bind(&DOMStorageAreaTest::InjectedCommitSequencingTask,
base::Unretained(this),
area));
base::MessageLoop::current()->RunUntilIdle();
@@ -280,20 +280,20 @@ TEST_F(DomStorageAreaTest, CommitTasks) {
EXPECT_EQ(kValue2, values[kKey2].string());
}
-TEST_F(DomStorageAreaTest, CommitChangesAtShutdown) {
+TEST_F(DOMStorageAreaTest, CommitChangesAtShutdown) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- scoped_refptr<DomStorageArea> area(new DomStorageArea(
+ scoped_refptr<DOMStorageArea> area(new DOMStorageArea(
kOrigin,
temp_dir.path(),
- new MockDomStorageTaskRunner(base::MessageLoopProxy::current().get())));
+ new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get())));
// Inject an in-memory db to speed up the test and also to verify
// the final changes are commited in it's dtor.
static_cast<LocalStorageDatabaseAdapter*>(area->backing_.get())->db_.reset(
new VerifyChangesCommittedDatabase());
- ValuesMap values;
+ DOMStorageValuesMap values;
base::NullableString16 old_value;
EXPECT_TRUE(area->SetItem(kKey, kValue, &old_value));
EXPECT_TRUE(area->HasUncommittedChanges());
@@ -307,19 +307,19 @@ TEST_F(DomStorageAreaTest, CommitChangesAtShutdown) {
// were committed.
}
-TEST_F(DomStorageAreaTest, DeleteOrigin) {
+TEST_F(DOMStorageAreaTest, DeleteOrigin) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- scoped_refptr<DomStorageArea> area(new DomStorageArea(
+ scoped_refptr<DOMStorageArea> area(new DOMStorageArea(
kOrigin,
temp_dir.path(),
- new MockDomStorageTaskRunner(base::MessageLoopProxy::current().get())));
+ new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get())));
// This test puts files on disk.
base::FilePath db_file_path = static_cast<LocalStorageDatabaseAdapter*>(
area->backing_.get())->db_->file_path();
base::FilePath db_journal_file_path =
- DomStorageDatabase::GetJournalFilePath(db_file_path);
+ DOMStorageDatabase::GetJournalFilePath(db_file_path);
// Nothing bad should happen when invoked w/o any files on disk.
area->DeleteOrigin();
@@ -368,28 +368,28 @@ TEST_F(DomStorageAreaTest, DeleteOrigin) {
EXPECT_FALSE(base::PathExists(db_file_path));
}
-TEST_F(DomStorageAreaTest, PurgeMemory) {
+TEST_F(DOMStorageAreaTest, PurgeMemory) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- scoped_refptr<DomStorageArea> area(new DomStorageArea(
+ scoped_refptr<DOMStorageArea> area(new DOMStorageArea(
kOrigin,
temp_dir.path(),
- new MockDomStorageTaskRunner(base::MessageLoopProxy::current().get())));
+ new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get())));
// Inject an in-memory db to speed up the test.
area->backing_.reset(new LocalStorageDatabaseAdapter());
// Unowned ptrs we use to verify that 'purge' has happened.
- DomStorageDatabase* original_backing =
+ DOMStorageDatabase* original_backing =
static_cast<LocalStorageDatabaseAdapter*>(
area->backing_.get())->db_.get();
- DomStorageMap* original_map = area->map_.get();
+ DOMStorageMap* original_map = area->map_.get();
// Should do no harm when called on a newly constructed object.
EXPECT_FALSE(area->is_initial_import_done_);
area->PurgeMemory();
EXPECT_FALSE(area->is_initial_import_done_);
- DomStorageDatabase* new_backing = static_cast<LocalStorageDatabaseAdapter*>(
+ DOMStorageDatabase* new_backing = static_cast<LocalStorageDatabaseAdapter*>(
area->backing_.get())->db_.get();
EXPECT_EQ(original_backing, new_backing);
EXPECT_EQ(original_map, area->map_.get());
@@ -425,7 +425,7 @@ TEST_F(DomStorageAreaTest, PurgeMemory) {
EXPECT_NE(original_map, area->map_.get());
}
-TEST_F(DomStorageAreaTest, DatabaseFileNames) {
+TEST_F(DOMStorageAreaTest, DatabaseFileNames) {
struct {
const char* origin;
const char* file_name;
@@ -444,30 +444,31 @@ TEST_F(DomStorageAreaTest, DatabaseFileNames) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kCases); ++i) {
GURL origin = GURL(kCases[i].origin).GetOrigin();
- base::FilePath file_name = base::FilePath().AppendASCII(kCases[i].file_name);
+ base::FilePath file_name =
+ base::FilePath().AppendASCII(kCases[i].file_name);
base::FilePath journal_file_name =
base::FilePath().AppendASCII(kCases[i].journal_file_name);
EXPECT_EQ(file_name,
- DomStorageArea::DatabaseFileNameFromOrigin(origin));
+ DOMStorageArea::DatabaseFileNameFromOrigin(origin));
EXPECT_EQ(origin,
- DomStorageArea::OriginFromDatabaseFileName(file_name));
+ DOMStorageArea::OriginFromDatabaseFileName(file_name));
EXPECT_EQ(journal_file_name,
- DomStorageDatabase::GetJournalFilePath(file_name));
+ DOMStorageDatabase::GetJournalFilePath(file_name));
}
- // Also test some DomStorageDatabase::GetJournalFilePath cases here.
+ // Also test some DOMStorageDatabase::GetJournalFilePath cases here.
base::FilePath parent = base::FilePath().AppendASCII("a").AppendASCII("b");
EXPECT_EQ(
parent.AppendASCII("file-journal"),
- DomStorageDatabase::GetJournalFilePath(parent.AppendASCII("file")));
+ DOMStorageDatabase::GetJournalFilePath(parent.AppendASCII("file")));
EXPECT_EQ(
base::FilePath().AppendASCII("-journal"),
- DomStorageDatabase::GetJournalFilePath(base::FilePath()));
+ DOMStorageDatabase::GetJournalFilePath(base::FilePath()));
EXPECT_EQ(
base::FilePath().AppendASCII(".extensiononly-journal"),
- DomStorageDatabase::GetJournalFilePath(
+ DOMStorageDatabase::GetJournalFilePath(
base::FilePath().AppendASCII(".extensiononly")));
}
-} // namespace dom_storage
+} // namespace content
« no previous file with comments | « content/browser/dom_storage/dom_storage_area.cc ('k') | content/browser/dom_storage/dom_storage_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698