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

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: 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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::CorruptSizeInHeaderOfDB() {
36 return sql::test::CorruptSizeInHeader(db_path());
37 }
38
39 void SQLTestBase::WriteJunkToDatabase(WriteJunkType type) {
40 base::ScopedFILE file(base::OpenFile(
41 db_path(),
42 type == TYPE_OVERWRITE_AND_TRUNCATE ? "wb" : "rb+"));
43 ASSERT_TRUE(file.get() != NULL);
44 ASSERT_EQ(0, fseek(file.get(), 0, SEEK_SET));
45
46 const char* kJunk = "Now is the winter of our discontent.";
47 fputs(kJunk, file.get());
48 }
49
50 void SQLTestBase::TruncateDatabase() {
51 base::ScopedFILE file(base::OpenFile(db_path(), "rb+"));
52 ASSERT_TRUE(file.get() != NULL);
53 ASSERT_EQ(0, fseek(file.get(), 0, SEEK_SET));
54 ASSERT_TRUE(base::TruncateFile(file.get()));
55 }
56
57 void SQLTestBase::SetUp() {
58 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
59 ASSERT_TRUE(db_.Open(db_path()));
60 }
61
62 void SQLTestBase::TearDown() {
63 db_.Close();
64 }
65
66 } // namespace sql
OLDNEW
« 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