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

Side by Side 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: Patch cleanup now that gn check passes. 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sql/test/sql_test_base.h"
6
7 #include "base/files/file_util.h"
8 #include "sql/test/test_helpers.h"
9
10 namespace sql {
11
12 SQLTestBase::SQLTestBase() {
13 }
14
15 SQLTestBase::~SQLTestBase() {
16 }
17
18 base::FilePath SQLTestBase::db_path() {
19 return temp_dir_.path().AppendASCII("SQLTest.db");
20 }
21
22 sql::Connection& SQLTestBase::db() {
23 return db_;
24 }
25
26 bool SQLTestBase::Reopen() {
27 db_.Close();
28 return db_.Open(db_path());
29 }
30
31 bool SQLTestBase::GetPathExists(const base::FilePath& path) {
32 return base::PathExists(path);
33 }
34
35 bool SQLTestBase::CorruptSizeInHeaderOfPath(const base::FilePath& db_path) {
36 return sql::test::CorruptSizeInHeader(db_path);
37 }
38
39 void SQLTestBase::WriteJunkToDatabase(bool truncate) {
40 base::ScopedFILE file(base::OpenFile(db_path(), truncate ? "wb" : "rb+"));
41 ASSERT_TRUE(file.get() != NULL);
42 ASSERT_EQ(0, fseek(file.get(), 0, SEEK_SET));
43
44 const char* kJunk = "Now is the winter of our discontent.";
45 fputs(kJunk, file.get());
46 }
47
48 void SQLTestBase::TruncateDatabase() {
49 base::ScopedFILE file(base::OpenFile(db_path(), "rb+"));
50 ASSERT_TRUE(file.get() != NULL);
51 ASSERT_EQ(0, fseek(file.get(), 0, SEEK_SET));
52 ASSERT_TRUE(base::TruncateFile(file.get()));
53 }
54
55 void SQLTestBase::SetUp() {
56 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
57 ASSERT_TRUE(db_.Open(db_path()));
58 }
59
60 void SQLTestBase::TearDown() {
61 db_.Close();
62 }
63
64 } // namespace sql
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698