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

Unified Diff: sql/test/sql_test_base.cc

Issue 1176653002: mandoline filesystem: add a sqlite3 vfs to proxy filesystem usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix win 8 Created 5 years, 6 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
« no previous file with comments | « sql/test/sql_test_base.h ('k') | sql/test/test_helpers.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/test/sql_test_base.cc
diff --git a/sql/test/sql_test_base.cc b/sql/test/sql_test_base.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bdd427fe7c105a0840bf43fb50c4d95573c4e58f
--- /dev/null
+++ b/sql/test/sql_test_base.cc
@@ -0,0 +1,66 @@
+// Copyright 2015 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 "sql/test/sql_test_base.h"
+
+#include "base/files/file_util.h"
+#include "sql/test/test_helpers.h"
+
+namespace sql {
+
+SQLTestBase::SQLTestBase() {
+}
+
+SQLTestBase::~SQLTestBase() {
+}
+
+base::FilePath SQLTestBase::db_path() {
+ return temp_dir_.path().AppendASCII("SQLTest.db");
+}
+
+sql::Connection& SQLTestBase::db() {
+ return db_;
+}
+
+bool SQLTestBase::Reopen() {
+ db_.Close();
+ return db_.Open(db_path());
+}
+
+bool SQLTestBase::GetPathExists(const base::FilePath& path) {
+ return base::PathExists(path);
+}
+
+bool SQLTestBase::CorruptSizeInHeaderOfDB() {
+ return sql::test::CorruptSizeInHeader(db_path());
+}
+
+void SQLTestBase::WriteJunkToDatabase(WriteJunkType type) {
+ base::ScopedFILE file(base::OpenFile(
+ db_path(),
+ type == TYPE_OVERWRITE_AND_TRUNCATE ? "wb" : "rb+"));
+ ASSERT_TRUE(file.get() != NULL);
+ ASSERT_EQ(0, fseek(file.get(), 0, SEEK_SET));
+
+ const char* kJunk = "Now is the winter of our discontent.";
+ fputs(kJunk, file.get());
+}
+
+void SQLTestBase::TruncateDatabase() {
+ base::ScopedFILE file(base::OpenFile(db_path(), "rb+"));
+ ASSERT_TRUE(file.get() != NULL);
+ ASSERT_EQ(0, fseek(file.get(), 0, SEEK_SET));
+ ASSERT_TRUE(base::TruncateFile(file.get()));
+}
+
+void SQLTestBase::SetUp() {
+ ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
+ ASSERT_TRUE(db_.Open(db_path()));
+}
+
+void SQLTestBase::TearDown() {
+ db_.Close();
+}
+
+} // namespace sql
« no previous file with comments | « sql/test/sql_test_base.h ('k') | sql/test/test_helpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698