diff options
Diffstat (limited to 'chromium/content/browser/indexed_db/indexed_db_backing_store_unittest.cc')
-rw-r--r-- | chromium/content/browser/indexed_db/indexed_db_backing_store_unittest.cc | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/chromium/content/browser/indexed_db/indexed_db_backing_store_unittest.cc b/chromium/content/browser/indexed_db/indexed_db_backing_store_unittest.cc index cc6ea1f2a64..50fb2f07a5d 100644 --- a/chromium/content/browser/indexed_db/indexed_db_backing_store_unittest.cc +++ b/chromium/content/browser/indexed_db/indexed_db_backing_store_unittest.cc @@ -12,6 +12,7 @@ #include "content/browser/indexed_db/indexed_db_factory.h" #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" #include "third_party/WebKit/public/platform/WebIDBTypes.h" #include "url/gurl.h" #include "webkit/common/database/database_identifier.h" @@ -325,10 +326,12 @@ class MockIDBFactory : public IndexedDBFactory { const base::FilePath& data_directory) { WebKit::WebIDBCallbacks::DataLoss data_loss = WebKit::WebIDBCallbacks::DataLossNone; + bool disk_full; scoped_refptr<IndexedDBBackingStore> backing_store = OpenBackingStore(webkit_database::GetIdentifierFromOrigin(origin), data_directory, - &data_loss); + &data_loss, + &disk_full); EXPECT_EQ(WebKit::WebIDBCallbacks::DataLossNone, data_loss); return backing_store; } @@ -413,6 +416,50 @@ TEST(IndexedDBFactoryTest, RejectLongOrigins) { EXPECT_TRUE(diskStore2); } +class DiskFullFactory : public IndexedDBFactory { + private: + virtual ~DiskFullFactory() {} + virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore( + const std::string& origin_identifier, + const base::FilePath& data_directory, + WebKit::WebIDBCallbacks::DataLoss* data_loss, + bool* disk_full) OVERRIDE { + *disk_full = true; + return scoped_refptr<IndexedDBBackingStore>(); + } +}; + +class LookingForQuotaErrorMockCallbacks : public IndexedDBCallbacks { + public: + LookingForQuotaErrorMockCallbacks() + : IndexedDBCallbacks(NULL, 0, 0), error_called_(false) {} + virtual void OnError(const IndexedDBDatabaseError& error) OVERRIDE { + error_called_ = true; + EXPECT_EQ(WebKit::WebIDBDatabaseExceptionQuotaError, error.code()); + } + private: + virtual ~LookingForQuotaErrorMockCallbacks() { + EXPECT_TRUE(error_called_); + } + bool error_called_; +}; + +TEST(IndexedDBFactoryTest, QuotaErrorOnDiskFull) { + scoped_refptr<DiskFullFactory> factory = new DiskFullFactory; + scoped_refptr<LookingForQuotaErrorMockCallbacks> callbacks = + new LookingForQuotaErrorMockCallbacks; + scoped_refptr<IndexedDBDatabaseCallbacks> dummy_database_callbacks = + new IndexedDBDatabaseCallbacks(NULL, 0, 0); + const string16 name(ASCIIToUTF16("name")); + factory->Open(name, + 1, /* version */ + 2, /* transaction_id */ + callbacks, + dummy_database_callbacks, + "origin", + base::FilePath(FILE_PATH_LITERAL("/dummy"))); +} + } // namespace } // namespace content |