| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/sql/connection.h" | 5 #include "app/sql/connection.h" |
| 6 #include "app/sql/statement.h" | 6 #include "app/sql/statement.h" |
| 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 "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "third_party/sqlite/preprocessed/sqlite3.h" | 11 #include "third_party/sqlite/sqlite3.h" |
| 12 | 12 |
| 13 class SQLConnectionTest : public testing::Test { | 13 class SQLConnectionTest : public testing::Test { |
| 14 public: | 14 public: |
| 15 SQLConnectionTest() {} | 15 SQLConnectionTest() {} |
| 16 | 16 |
| 17 void SetUp() { | 17 void SetUp() { |
| 18 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &path_)); | 18 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &path_)); |
| 19 path_ = path_.AppendASCII("SQLConnectionTest.db"); | 19 path_ = path_.AppendASCII("SQLConnectionTest.db"); |
| 20 file_util::Delete(path_, false); | 20 file_util::Delete(path_, false); |
| 21 ASSERT_TRUE(db_.Open(path_)); | 21 ASSERT_TRUE(db_.Open(path_)); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 int64 row = db().GetLastInsertRowId(); | 104 int64 row = db().GetLastInsertRowId(); |
| 105 EXPECT_LT(0, row); | 105 EXPECT_LT(0, row); |
| 106 | 106 |
| 107 // It should be the primary key of the row we just inserted. | 107 // It should be the primary key of the row we just inserted. |
| 108 sql::Statement s(db().GetUniqueStatement("SELECT value FROM foo WHERE id=?")); | 108 sql::Statement s(db().GetUniqueStatement("SELECT value FROM foo WHERE id=?")); |
| 109 s.BindInt64(0, row); | 109 s.BindInt64(0, row); |
| 110 ASSERT_TRUE(s.Step()); | 110 ASSERT_TRUE(s.Step()); |
| 111 EXPECT_EQ(12, s.ColumnInt(0)); | 111 EXPECT_EQ(12, s.ColumnInt(0)); |
| 112 } | 112 } |
| 113 | 113 |
| OLD | NEW |