OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "sql/connection.h" | 9 #include "sql/connection.h" |
10 #include "sql/statement.h" | 10 #include "sql/statement.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 int* error_; | 35 int* error_; |
36 std::string* sql_text_; | 36 std::string* sql_text_; |
37 | 37 |
38 DISALLOW_COPY_AND_ASSIGN(StatementErrorHandler); | 38 DISALLOW_COPY_AND_ASSIGN(StatementErrorHandler); |
39 }; | 39 }; |
40 | 40 |
41 class SQLiteFeaturesTest : public testing::Test { | 41 class SQLiteFeaturesTest : public testing::Test { |
42 public: | 42 public: |
43 SQLiteFeaturesTest() : error_(SQLITE_OK) {} | 43 SQLiteFeaturesTest() : error_(SQLITE_OK) {} |
44 | 44 |
45 void SetUp() { | 45 virtual void SetUp() { |
46 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 46 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
47 ASSERT_TRUE(db_.Open(temp_dir_.path().AppendASCII("SQLStatementTest.db"))); | 47 ASSERT_TRUE(db_.Open(temp_dir_.path().AppendASCII("SQLStatementTest.db"))); |
48 | 48 |
49 // The error delegate will set |error_| and |sql_text_| when any sqlite | 49 // The error delegate will set |error_| and |sql_text_| when any sqlite |
50 // statement operation returns an error code. | 50 // statement operation returns an error code. |
51 db_.set_error_delegate(new StatementErrorHandler(&error_, &sql_text_)); | 51 db_.set_error_delegate(new StatementErrorHandler(&error_, &sql_text_)); |
52 } | 52 } |
53 | 53 |
54 void TearDown() { | 54 virtual void TearDown() { |
55 // If any error happened the original sql statement can be found in | 55 // If any error happened the original sql statement can be found in |
56 // |sql_text_|. | 56 // |sql_text_|. |
57 EXPECT_EQ(SQLITE_OK, error_); | 57 EXPECT_EQ(SQLITE_OK, error_); |
58 db_.Close(); | 58 db_.Close(); |
59 } | 59 } |
60 | 60 |
61 sql::Connection& db() { return db_; } | 61 sql::Connection& db() { return db_; } |
62 | 62 |
63 int sqlite_error() const { | 63 int sqlite_error() const { |
64 return error_; | 64 return error_; |
(...skipping 26 matching lines...) Expand all Loading... |
91 ASSERT_TRUE(db().Execute("CREATE VIRTUAL TABLE foo USING fts2(x)")); | 91 ASSERT_TRUE(db().Execute("CREATE VIRTUAL TABLE foo USING fts2(x)")); |
92 } | 92 } |
93 #endif | 93 #endif |
94 | 94 |
95 // fts3 is used for current history files, and also for WebDatabase. | 95 // fts3 is used for current history files, and also for WebDatabase. |
96 TEST_F(SQLiteFeaturesTest, FTS3) { | 96 TEST_F(SQLiteFeaturesTest, FTS3) { |
97 ASSERT_TRUE(db().Execute("CREATE VIRTUAL TABLE foo USING fts3(x)")); | 97 ASSERT_TRUE(db().Execute("CREATE VIRTUAL TABLE foo USING fts3(x)")); |
98 } | 98 } |
99 | 99 |
100 } // namespace | 100 } // namespace |
OLD | NEW |