- add sources.
[platform/framework/web/crosswalk.git] / src / sql / test / test_helpers.h
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
3 // found in the LICENSE file.
4
5 #ifndef SQL_TEST_TEST_HELPERS_H_
6 #define SQL_TEST_TEST_HELPERS_H_
7
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10
11 // Collection of test-only convenience functions.
12
13 namespace base {
14 class FilePath;
15 }
16
17 namespace sql {
18 class Connection;
19 }
20
21 namespace sql {
22 namespace test {
23
24 // Return the number of tables in sqlite_master.
25 size_t CountSQLTables(sql::Connection* db) WARN_UNUSED_RESULT;
26
27 // Return the number of indices in sqlite_master.
28 size_t CountSQLIndices(sql::Connection* db) WARN_UNUSED_RESULT;
29
30 // Returns the number of columns in the named table.  0 indicates an
31 // error (probably no such table).
32 size_t CountTableColumns(sql::Connection* db, const char* table)
33     WARN_UNUSED_RESULT;
34
35 // Sets |*count| to the number of rows in |table|.  Returns false in
36 // case of error, such as the table not existing.
37 bool CountTableRows(sql::Connection* db, const char* table, size_t* count);
38
39 // Creates a SQLite database at |db_path| from the sqlite .dump output
40 // at |sql_path|.  Returns false if |db_path| already exists, or if
41 // sql_path does not exist or cannot be read, or if there is an error
42 // executing the statements.
43 bool CreateDatabaseFromSQL(const base::FilePath& db_path,
44                            const base::FilePath& sql_path) WARN_UNUSED_RESULT;
45
46 }  // namespace test
47 }  // namespace sql
48
49 #endif  // SQL_TEST_TEST_HELPERS_H_