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

Side by Side Diff: trunk/src/sql/test/test_helpers.h

Issue 74933002: Revert 235492 "[sql] Recover Favicons v5 databases, with more re..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/sql/recovery_unittest.cc ('k') | trunk/src/sql/test/test_helpers.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SQL_TEST_TEST_HELPERS_H_ 5 #ifndef SQL_TEST_TEST_HELPERS_H_
6 #define SQL_TEST_TEST_HELPERS_H_ 6 #define SQL_TEST_TEST_HELPERS_H_
7 7
8 #include <string>
9
10 #include "base/basictypes.h" 8 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
12 10
13 // Collection of test-only convenience functions. 11 // Collection of test-only convenience functions.
14 12
15 namespace base { 13 namespace base {
16 class FilePath; 14 class FilePath;
17 } 15 }
18 16
19 namespace sql { 17 namespace sql {
20 class Connection; 18 class Connection;
21 } 19 }
22 20
23 namespace sql { 21 namespace sql {
24 namespace test { 22 namespace test {
25 23
26 // SQLite stores the database size in the header, and if the actual
27 // OS-derived size is smaller, the database is considered corrupt.
28 // [This case is actually a common form of corruption in the wild.]
29 // This helper sets the in-header size to one page larger than the
30 // actual file size. The resulting file will return SQLITE_CORRUPT
31 // for most operations unless PRAGMA writable_schema is turned ON.
32 //
33 // Returns false if any error occurs accessing the file.
34 bool CorruptSizeInHeader(const base::FilePath& db_path) WARN_UNUSED_RESULT;
35
36 // Return the number of tables in sqlite_master. 24 // Return the number of tables in sqlite_master.
37 size_t CountSQLTables(sql::Connection* db) WARN_UNUSED_RESULT; 25 size_t CountSQLTables(sql::Connection* db) WARN_UNUSED_RESULT;
38 26
39 // Return the number of indices in sqlite_master. 27 // Return the number of indices in sqlite_master.
40 size_t CountSQLIndices(sql::Connection* db) WARN_UNUSED_RESULT; 28 size_t CountSQLIndices(sql::Connection* db) WARN_UNUSED_RESULT;
41 29
42 // Returns the number of columns in the named table. 0 indicates an 30 // Returns the number of columns in the named table. 0 indicates an
43 // error (probably no such table). 31 // error (probably no such table).
44 size_t CountTableColumns(sql::Connection* db, const char* table) 32 size_t CountTableColumns(sql::Connection* db, const char* table)
45 WARN_UNUSED_RESULT; 33 WARN_UNUSED_RESULT;
46 34
47 // Sets |*count| to the number of rows in |table|. Returns false in 35 // Sets |*count| to the number of rows in |table|. Returns false in
48 // case of error, such as the table not existing. 36 // case of error, such as the table not existing.
49 bool CountTableRows(sql::Connection* db, const char* table, size_t* count); 37 bool CountTableRows(sql::Connection* db, const char* table, size_t* count);
50 38
51 // Creates a SQLite database at |db_path| from the sqlite .dump output 39 // Creates a SQLite database at |db_path| from the sqlite .dump output
52 // at |sql_path|. Returns false if |db_path| already exists, or if 40 // at |sql_path|. Returns false if |db_path| already exists, or if
53 // sql_path does not exist or cannot be read, or if there is an error 41 // sql_path does not exist or cannot be read, or if there is an error
54 // executing the statements. 42 // executing the statements.
55 bool CreateDatabaseFromSQL(const base::FilePath& db_path, 43 bool CreateDatabaseFromSQL(const base::FilePath& db_path,
56 const base::FilePath& sql_path) WARN_UNUSED_RESULT; 44 const base::FilePath& sql_path) WARN_UNUSED_RESULT;
57 45
58 // Return the results of running "PRAGMA integrity_check" on |db|.
59 // TODO(shess): sql::Connection::IntegrityCheck() is basically the
60 // same, but not as convenient for testing. Maybe combine.
61 std::string IntegrityCheck(sql::Connection* db) WARN_UNUSED_RESULT;
62
63 } // namespace test 46 } // namespace test
64 } // namespace sql 47 } // namespace sql
65 48
66 #endif // SQL_TEST_TEST_HELPERS_H_ 49 #endif // SQL_TEST_TEST_HELPERS_H_
OLDNEW
« no previous file with comments | « trunk/src/sql/recovery_unittest.cc ('k') | trunk/src/sql/test/test_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698