summaryrefslogtreecommitdiffstats
path: root/webkit/database/database_tracker_unittest.cc
diff options
context:
space:
mode:
authormichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-02 00:29:51 +0000
committermichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-02 00:29:51 +0000
commit49cd5dabaf1f0e520c9598a1176c3390091e74a0 (patch)
treeec5f627d008db3c53508908ff9c38e33922ef609 /webkit/database/database_tracker_unittest.cc
parentc01631a1fcc2827db01ddaacf4038e284d4af912 (diff)
downloadchromium_src-49cd5dabaf1f0e520c9598a1176c3390091e74a0.zip
chromium_src-49cd5dabaf1f0e520c9598a1176c3390091e74a0.tar.gz
chromium_src-49cd5dabaf1f0e520c9598a1176c3390091e74a0.tar.bz2
Reapply 43381 - Add some safeguards in DatabaseTracker to prevent writing anything to disk for incognito. This time with more unit tests.
TEST=manual and database_tracker_unittest.cc BUG=none Review URL: http://codereview.chromium.org/1572017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43417 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/database/database_tracker_unittest.cc')
-rw-r--r--webkit/database/database_tracker_unittest.cc36
1 files changed, 35 insertions, 1 deletions
diff --git a/webkit/database/database_tracker_unittest.cc b/webkit/database/database_tracker_unittest.cc
index 88e8981..14bd480 100644
--- a/webkit/database/database_tracker_unittest.cc
+++ b/webkit/database/database_tracker_unittest.cc
@@ -167,7 +167,7 @@ TEST(DatabaseTrackerTest, DeleteOpenDatabase) {
tracker->RemoveObserver(&observer);
}
-TEST(DatabaseTrackerTest, TestIt) {
+TEST(DatabaseTrackerTest, DatabaseTracker) {
// Initialize the tracker database.
ScopedTempDir temp_dir;
EXPECT_TRUE(temp_dir.CreateUniqueTempDir());
@@ -361,4 +361,38 @@ TEST(DatabaseTrackerTest, TestIt) {
EXPECT_EQ(origin1_quota, tracker->GetOriginSpaceAvailable(kOrigin1));
}
+TEST(DatabaseTrackerTest, NoInitIncognito) {
+ const string16 kOrigin = ASCIIToUTF16("origin");
+ const string16 kName = ASCIIToUTF16("name");
+ const string16 kDescription = ASCIIToUTF16("description");
+ const DatabaseConnections kEmptyCollection;
+
+ std::vector<OriginInfo> infos;
+ scoped_refptr<DatabaseTracker> tracker(new DatabaseTracker(FilePath()));
+ EXPECT_TRUE(tracker->is_incognito_);
+ EXPECT_FALSE(tracker->LazyInit());
+ EXPECT_TRUE(tracker->DatabaseDirectory().empty());
+ EXPECT_TRUE(tracker->GetFullDBFilePath(kOrigin, kName).empty());
+ EXPECT_FALSE(tracker->GetAllOriginsInfo(&infos));
+ EXPECT_FALSE(tracker->IsDatabaseScheduledForDeletion(kOrigin, kName));
+ EXPECT_EQ(net::ERR_FAILED,
+ tracker->DeleteDatabase(kOrigin, kName, NULL));
+ EXPECT_EQ(net::ERR_FAILED,
+ tracker->DeleteDataModifiedSince(base::Time(), NULL));
+ EXPECT_EQ(net::ERR_FAILED,
+ tracker->DeleteDataForOrigin(kOrigin, NULL));
+
+ // These should not assert or crash when called in this state.
+ int64 size_out(0), space_available_out(0);
+ tracker->DatabaseOpened(kOrigin, kName, kDescription, 1,
+ &size_out, &space_available_out);
+ tracker->DatabaseModified(kOrigin, kName);
+ tracker->DatabaseClosed(kOrigin, kName);
+ tracker->CloseDatabases(kEmptyCollection);
+ tracker->CloseTrackerDatabaseAndClearCaches();
+ tracker->SetOriginQuota(kOrigin, 5);
+ tracker->SetOriginQuotaInMemory(kOrigin, 5);
+ tracker->ResetOriginQuotaInMemory(kOrigin);
+}
+
} // namespace webkit_database