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

Unified Diff: webkit/database/database_tracker_unittest.cc

Issue 7633016: Test cleanup: Using MockSpecialStoragePolicy instead of local subclasses of SpecialStoragePolicy. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Oops, cleaning up leftover TestSpecialStoragePolicy classes. Created 9 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: webkit/database/database_tracker_unittest.cc
diff --git a/webkit/database/database_tracker_unittest.cc b/webkit/database/database_tracker_unittest.cc
index c6404b1980baa7e3cef6bbec63bff0dfbd935b03..ee423a9dbab39244acc54367f452e16b26bd5f34 100644
--- a/webkit/database/database_tracker_unittest.cc
+++ b/webkit/database/database_tracker_unittest.cc
@@ -15,29 +15,14 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/database/database_tracker.h"
#include "webkit/database/database_util.h"
+#include "webkit/quota/mock_special_storage_policy.h"
#include "webkit/quota/quota_manager.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;
- }
-
- virtual bool IsFileHandler(const std::string& extension_id) {
- return false;
- }
-};
-
class TestObserver : public webkit_database::DatabaseTracker::Observer {
public:
TestObserver() : new_notification_received_(false) {}
@@ -187,8 +172,7 @@ class DatabaseTracker_TestHelper_Test {
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
scoped_refptr<DatabaseTracker> tracker(
new DatabaseTracker(temp_dir.path(), incognito_mode, false,
- new TestSpecialStoragePolicy,
- NULL, NULL));
+ GetSpecialStoragePolicy(), NULL, NULL));
// Create and open three databases.
int64 database_size = 0;
@@ -290,8 +274,7 @@ class DatabaseTracker_TestHelper_Test {
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
scoped_refptr<DatabaseTracker> tracker(
new DatabaseTracker(temp_dir.path(), incognito_mode, false,
- new TestSpecialStoragePolicy,
- NULL, NULL));
+ GetSpecialStoragePolicy(), NULL, NULL));
// Add two observers.
TestObserver observer1;
@@ -538,8 +521,7 @@ class DatabaseTracker_TestHelper_Test {
scoped_refptr<DatabaseTracker> tracker(
new DatabaseTracker(
temp_dir.path(), false, true,
- new TestSpecialStoragePolicy,
- NULL,
+ GetSpecialStoragePolicy(), NULL,
base::MessageLoopProxy::CreateForCurrentThread()));
// Open three new databases.
@@ -598,8 +580,7 @@ class DatabaseTracker_TestHelper_Test {
// At this point, the database tracker should be gone. Create a new one.
scoped_refptr<DatabaseTracker> tracker(
new DatabaseTracker(temp_dir.path(), false, false,
- new TestSpecialStoragePolicy,
- NULL, NULL));
+ GetSpecialStoragePolicy(), NULL, NULL));
// Get all data for all origins.
std::vector<OriginInfo> origins_info;
@@ -614,8 +595,22 @@ class DatabaseTracker_TestHelper_Test {
// The origin directory should be gone as well.
EXPECT_FALSE(file_util::PathExists(origin1_db_dir));
}
+
+ static quota::SpecialStoragePolicy* GetSpecialStoragePolicy() {
+ if (!special_storage_policy_.get()) {
+ special_storage_policy_ = new quota::MockSpecialStoragePolicy;
+ special_storage_policy_->AddProtected(GURL(kOrigin2Url));
+ }
+ return special_storage_policy_.get();
+ }
+
+ private:
+ static scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_;
michaeln 2011/08/12 18:53:52 i would expect valgrind to complain about leaking
marja 2011/08/16 10:54:25 Hmm, why would valgrind complain: the dtor of the
};
+scoped_refptr<quota::MockSpecialStoragePolicy>
+ DatabaseTracker_TestHelper_Test::special_storage_policy_;
+
TEST(DatabaseTrackerTest, DeleteOpenDatabase) {
DatabaseTracker_TestHelper_Test::TestDeleteOpenDatabase(false);
}

Powered by Google App Engine
This is Rietveld 408576698