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

Unified Diff: content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc

Issue 15564008: Migrate the IndexedDB backend from Blink to Chromium (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update to ToT again Created 7 years, 7 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: content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc
diff --git a/content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc b/content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..af86147a99f8cf3400f406abb459f5321e3495d1
--- /dev/null
+++ b/content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc
@@ -0,0 +1,74 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/files/file_path.h"
+#include "base/files/scoped_temp_dir.h"
+#include "base/string16.h"
+#include "base/strings/utf_string_conversions.h"
+#include "content/browser/indexed_db/indexed_db_backing_store.h"
+#include "content/browser/indexed_db/leveldb/leveldb_database.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
+
+using WebKit::WebSecurityOrigin;
+using content::IndexedDBBackingStore;
+using content::LevelDBComparator;
+using content::LevelDBDatabase;
+using content::LevelDBFactory;
+using content::LevelDBSlice;
+using content::LevelDBSnapshot;
+
+namespace {
+
+class BustedLevelDBDatabase : public LevelDBDatabase {
+ public:
+ static scoped_ptr<LevelDBDatabase> Open(
+ const base::FilePath& file_name,
+ const LevelDBComparator* /*comparator*/) {
+ return scoped_ptr<LevelDBDatabase>(new BustedLevelDBDatabase);
+ }
+ virtual bool Get(const LevelDBSlice& key,
+ std::vector<char>& value,
+ bool& found,
+ const LevelDBSnapshot* = 0) OVERRIDE {
+ // false means IO error.
+ return false;
+ }
+};
+
+class MockLevelDBFactory : public LevelDBFactory {
+ public:
+ MockLevelDBFactory() : destroy_called_(false) {}
+ virtual scoped_ptr<LevelDBDatabase> OpenLevelDB(
+ const base::FilePath& file_name,
+ const LevelDBComparator* comparator) OVERRIDE {
+ return BustedLevelDBDatabase::Open(file_name, comparator);
+ }
+ virtual bool DestroyLevelDB(const base::FilePath& file_name) OVERRIDE {
+ EXPECT_FALSE(destroy_called_);
+ destroy_called_ = true;
+ return false;
+ }
+ virtual ~MockLevelDBFactory() { EXPECT_TRUE(destroy_called_); }
+
+ private:
+ bool destroy_called_;
+};
+
+TEST(IndexedDBIOErrorTest, CleanUpTest) {
+ WebSecurityOrigin origin(
+ WebSecurityOrigin::createFromString("http://localhost:81"));
+ base::ScopedTempDir temp_directory;
+ ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
+ const base::FilePath path = temp_directory.path();
+ string16 dummy_file_identifier;
+ MockLevelDBFactory mock_leveldb_factory;
+ scoped_refptr<IndexedDBBackingStore> backing_store =
+ IndexedDBBackingStore::Open(origin.databaseIdentifier(),
+ UTF8ToUTF16(path.AsUTF8Unsafe()),
+ dummy_file_identifier,
+ &mock_leveldb_factory);
+}
+
+} // namespace
« no previous file with comments | « content/browser/indexed_db/indexed_db_callbacks_wrapper.cc ('k') | content/browser/indexed_db/indexed_db_context_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698