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

Unified Diff: webkit/dom_storage/session_storage_database_unittest.cc

Issue 9963107: Persist sessionStorage on disk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review (pkasting) Created 8 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
« no previous file with comments | « webkit/dom_storage/session_storage_database.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/dom_storage/session_storage_database_unittest.cc
diff --git a/webkit/dom_storage/session_storage_database_unittest.cc b/webkit/dom_storage/session_storage_database_unittest.cc
index de71a2fa801273b1b2bc4eddfcf8e76f53d396dd..5796b1cfac6c33b5d9c849f8df62c7ed7561cbbe 100644
--- a/webkit/dom_storage/session_storage_database_unittest.cc
+++ b/webkit/dom_storage/session_storage_database_unittest.cc
@@ -52,6 +52,9 @@ class SessionStorageDatabaseTest : public testing::Test {
void CompareValuesMaps(const ValuesMap& map1, const ValuesMap& map2) const;
void CheckNamespaceIds(
const std::set<std::string>& expected_namespace_ids) const;
+ void CheckOrigins(
+ const std::string& namespace_id,
+ const std::set<GURL>& expected_origins) const;
std::string GetMapForArea(const std::string& namespace_id,
const GURL& origin) const;
int64 GetMapRefCount(const std::string& map_id) const;
@@ -335,18 +338,29 @@ void SessionStorageDatabaseTest::CheckNamespaceIds(
EXPECT_EQ(expected_namespace_ids.size(), namespace_ids.size());
for (std::vector<std::string>::const_iterator it = namespace_ids.begin();
it != namespace_ids.end(); ++it) {
- LOG(WARNING) << *it;
EXPECT_TRUE(expected_namespace_ids.find(*it) !=
expected_namespace_ids.end());
}
}
+void SessionStorageDatabaseTest::CheckOrigins(
+ const std::string& namespace_id,
+ const std::set<GURL>& expected_origins) const {
+ std::vector<GURL> origins;
+ EXPECT_TRUE(db_->ReadOriginsInNamespace(namespace_id, &origins));
+ EXPECT_EQ(expected_origins.size(), origins.size());
+ for (std::vector<GURL>::const_iterator it = origins.begin();
+ it != origins.end(); ++it) {
+ EXPECT_TRUE(expected_origins.find(*it) != expected_origins.end());
+ }
+}
+
std::string SessionStorageDatabaseTest::GetMapForArea(
const std::string& namespace_id, const GURL& origin) const {
bool exists;
std::string map_id;
EXPECT_TRUE(db_->GetMapForArea(namespace_id, origin.spec(),
- &exists, &map_id));
+ leveldb::ReadOptions(), &exists, &map_id));
EXPECT_TRUE(exists);
return map_id;
}
@@ -724,4 +738,37 @@ TEST_F(SessionStorageDatabaseTest, ReadNamespaceIds) {
CheckDatabaseConsistency();
}
+TEST_F(SessionStorageDatabaseTest, ReadNamespaceIdsInEmptyDatabase) {
+ std::set<std::string> expected_namespace_ids;
+ CheckNamespaceIds(expected_namespace_ids);
+}
+
+TEST_F(SessionStorageDatabaseTest, ReadOriginsInNamespace) {
+ ValuesMap data1;
+ data1[kKey1] = kValue1;
+ data1[kKey2] = kValue2;
+ data1[kKey3] = kValue3;
+
+ std::set<GURL> expected_origins1;
+ ASSERT_TRUE(db_->CommitAreaChanges(kNamespace1, kOrigin1, false, data1));
+ ASSERT_TRUE(db_->CommitAreaChanges(kNamespace1, kOrigin2, false, data1));
+ expected_origins1.insert(kOrigin1);
+ expected_origins1.insert(kOrigin2);
+ CheckOrigins(kNamespace1, expected_origins1);
+
+ std::set<GURL> expected_origins2;
+ ASSERT_TRUE(db_->CommitAreaChanges(kNamespace2, kOrigin2, false, data1));
+ expected_origins2.insert(kOrigin2);
+ CheckOrigins(kNamespace2, expected_origins2);
+
+ ASSERT_TRUE(db_->CloneNamespace(kNamespace1, kNamespaceClone));
+ CheckOrigins(kNamespaceClone, expected_origins1);
+
+ ASSERT_TRUE(db_->DeleteArea(kNamespace1, kOrigin2));
+ expected_origins1.erase(kOrigin2);
+ CheckOrigins(kNamespace1, expected_origins1);
+
+ CheckDatabaseConsistency();
+}
+
} // namespace dom_storage
« no previous file with comments | « webkit/dom_storage/session_storage_database.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698