diff options
Diffstat (limited to 'webkit/database/database_tracker_unittest.cc')
-rw-r--r-- | webkit/database/database_tracker_unittest.cc | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/webkit/database/database_tracker_unittest.cc b/webkit/database/database_tracker_unittest.cc index 641c207..a8d2928 100644 --- a/webkit/database/database_tracker_unittest.cc +++ b/webkit/database/database_tracker_unittest.cc @@ -12,9 +12,25 @@ #include "net/base/test_completion_callback.h" #include "testing/gtest/include/gtest/gtest.h" #include "webkit/database/database_tracker.h" +#include "webkit/database/database_util.h" +#include "webkit/quota/special_storage_policy.h" namespace { +const char kOrigin1Url[] = "http://origin1"; +const char kOrigin2Url[] = "http://protected_origin2"; + +class TestSpecialStoragePolicy : public quota::SpecialStoragePolicy { + public: + virtual bool IsStorageProtected(const GURL& origin) { + return origin == GURL(kOrigin2Url); + } + + virtual bool IsStorageUnlimited(const GURL& origin) { + return false; + } +}; + class TestObserver : public webkit_database::DatabaseTracker::Observer { public: TestObserver() : new_notification_received_(false) {} @@ -85,13 +101,16 @@ class DatabaseTracker_TestHelper_Test { ScopedTempDir temp_dir; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); scoped_refptr<DatabaseTracker> tracker( - new DatabaseTracker(temp_dir.path(), incognito_mode)); + new DatabaseTracker(temp_dir.path(), incognito_mode, + new TestSpecialStoragePolicy)); // Create and open three databases. int64 database_size = 0; int64 space_available = 0; - const string16 kOrigin1 = ASCIIToUTF16("origin1"); - const string16 kOrigin2 = ASCIIToUTF16("origin2"); + const string16 kOrigin1 = + DatabaseUtil::GetOriginIdentifier(GURL(kOrigin1Url)); + const string16 kOrigin2 = + DatabaseUtil::GetOriginIdentifier(GURL(kOrigin2Url)); const string16 kDB1 = ASCIIToUTF16("db1"); const string16 kDB2 = ASCIIToUTF16("db2"); const string16 kDB3 = ASCIIToUTF16("db3"); @@ -160,10 +179,8 @@ class DatabaseTracker_TestHelper_Test { // Delete databases modified since yesterday. db2 is whitelisted. base::Time yesterday = base::Time::Now(); yesterday -= base::TimeDelta::FromDays(1); - std::vector<string16> protected_origins; - protected_origins.push_back(kOrigin2); result = tracker->DeleteDataModifiedSince( - yesterday, protected_origins, &callback); + yesterday, &callback); EXPECT_EQ(net::ERR_IO_PENDING, result); ASSERT_FALSE(callback.have_result()); EXPECT_TRUE(observer.DidReceiveNewNotification()); @@ -187,7 +204,8 @@ class DatabaseTracker_TestHelper_Test { ScopedTempDir temp_dir; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); scoped_refptr<DatabaseTracker> tracker( - new DatabaseTracker(temp_dir.path(), incognito_mode)); + new DatabaseTracker(temp_dir.path(), incognito_mode, + new TestSpecialStoragePolicy)); // Add two observers. TestObserver observer1; @@ -198,8 +216,10 @@ class DatabaseTracker_TestHelper_Test { // Open three new databases. int64 database_size = 0; int64 space_available = 0; - const string16 kOrigin1 = ASCIIToUTF16("origin1"); - const string16 kOrigin2 = ASCIIToUTF16("origin2"); + const string16 kOrigin1 = + DatabaseUtil::GetOriginIdentifier(GURL(kOrigin1Url)); + const string16 kOrigin2 = + DatabaseUtil::GetOriginIdentifier(GURL(kOrigin2Url)); const string16 kDB1 = ASCIIToUTF16("db1"); const string16 kDB2 = ASCIIToUTF16("db2"); const string16 kDB3 = ASCIIToUTF16("db3"); |