| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "sql/connection.h" | 10 #include "sql/connection.h" |
| 11 #include "sql/statement.h" | 11 #include "sql/statement.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "third_party/sqlite/sqlite3.h" | 13 #include "third_party/sqlite/sqlite3.h" |
| 14 | 14 |
| 15 // Test that certain features are/are-not enabled in our SQLite. | 15 // Test that certain features are/are-not enabled in our SQLite. |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 | 19 |
| 20 class StatementErrorHandler : public sql::ErrorDelegate { | 20 class StatementErrorHandler : public sql::ErrorDelegate { |
| 21 public: | 21 public: |
| 22 StatementErrorHandler() : error_(SQLITE_OK) {} | 22 StatementErrorHandler() : error_(SQLITE_OK) {} |
| 23 | 23 |
| 24 virtual int OnError(int error, sql::Connection* connection, | 24 virtual int OnError(int error, sql::Connection* connection, |
| 25 sql::Statement* stmt) { | 25 sql::Statement* stmt) OVERRIDE { |
| 26 error_ = error; | 26 error_ = error; |
| 27 const char* sql_txt = stmt ? stmt->GetSQLStatement() : NULL; | 27 const char* sql_txt = stmt ? stmt->GetSQLStatement() : NULL; |
| 28 sql_text_ = sql_txt ? sql_txt : "no statement available"; | 28 sql_text_ = sql_txt ? sql_txt : "no statement available"; |
| 29 return error; | 29 return error; |
| 30 } | 30 } |
| 31 | 31 |
| 32 int error() const { return error_; } | 32 int error() const { return error_; } |
| 33 | 33 |
| 34 void reset_error() { | 34 void reset_error() { |
| 35 sql_text_.clear(); | 35 sql_text_.clear(); |
| 36 error_ = SQLITE_OK; | 36 error_ = SQLITE_OK; |
| 37 } | 37 } |
| 38 | 38 |
| 39 const char* sql_statement() const { return sql_text_.c_str(); } | 39 const char* sql_statement() const { return sql_text_.c_str(); } |
| 40 | 40 |
| 41 protected: |
| 42 virtual ~StatementErrorHandler() {} |
| 43 |
| 41 private: | 44 private: |
| 42 int error_; | 45 int error_; |
| 43 std::string sql_text_; | 46 std::string sql_text_; |
| 44 }; | 47 }; |
| 45 | 48 |
| 46 class SQLiteFeaturesTest : public testing::Test { | 49 class SQLiteFeaturesTest : public testing::Test { |
| 47 public: | 50 public: |
| 48 SQLiteFeaturesTest() : error_handler_(new StatementErrorHandler) {} | 51 SQLiteFeaturesTest() : error_handler_(new StatementErrorHandler) {} |
| 49 | 52 |
| 50 void SetUp() { | 53 void SetUp() { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 TEST_F(SQLiteFeaturesTest, FTS2) { | 95 TEST_F(SQLiteFeaturesTest, FTS2) { |
| 93 ASSERT_TRUE(db().Execute("CREATE VIRTUAL TABLE foo USING fts2(x)")); | 96 ASSERT_TRUE(db().Execute("CREATE VIRTUAL TABLE foo USING fts2(x)")); |
| 94 } | 97 } |
| 95 | 98 |
| 96 // fts3 is used for current history files, and also for WebDatabase. | 99 // fts3 is used for current history files, and also for WebDatabase. |
| 97 TEST_F(SQLiteFeaturesTest, FTS3) { | 100 TEST_F(SQLiteFeaturesTest, FTS3) { |
| 98 ASSERT_TRUE(db().Execute("CREATE VIRTUAL TABLE foo USING fts3(x)")); | 101 ASSERT_TRUE(db().Execute("CREATE VIRTUAL TABLE foo USING fts3(x)")); |
| 99 } | 102 } |
| 100 | 103 |
| 101 } // namespace | 104 } // namespace |
| OLD | NEW |