| 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 "base/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 class URLDatabaseTest : public testing::Test, | 36 class URLDatabaseTest : public testing::Test, |
| 37 public URLDatabase { | 37 public URLDatabase { |
| 38 public: | 38 public: |
| 39 URLDatabaseTest() { | 39 URLDatabaseTest() { |
| 40 } | 40 } |
| 41 | 41 |
| 42 protected: | 42 protected: |
| 43 // Provided for URL/VisitDatabase. | 43 // Provided for URL/VisitDatabase. |
| 44 virtual sql::Connection& GetDB() { | 44 virtual sql::Connection& GetDB() OVERRIDE { |
| 45 return db_; | 45 return db_; |
| 46 } | 46 } |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 // Test setup. | 49 // Test setup. |
| 50 void SetUp() { | 50 virtual void SetUp() { |
| 51 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 51 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 52 FilePath db_file = temp_dir_.path().AppendASCII("URLTest.db"); | 52 FilePath db_file = temp_dir_.path().AppendASCII("URLTest.db"); |
| 53 | 53 |
| 54 EXPECT_TRUE(db_.Open(db_file)); | 54 EXPECT_TRUE(db_.Open(db_file)); |
| 55 | 55 |
| 56 // Initialize the tables for this test. | 56 // Initialize the tables for this test. |
| 57 CreateURLTable(false); | 57 CreateURLTable(false); |
| 58 CreateMainURLIndex(); | 58 CreateMainURLIndex(); |
| 59 InitKeywordSearchTermsTable(); | 59 InitKeywordSearchTermsTable(); |
| 60 CreateKeywordSearchTermsIndices(); | 60 CreateKeywordSearchTermsIndices(); |
| 61 } | 61 } |
| 62 void TearDown() { | 62 virtual void TearDown() { |
| 63 db_.Close(); | 63 db_.Close(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 base::ScopedTempDir temp_dir_; | 66 base::ScopedTempDir temp_dir_; |
| 67 sql::Connection db_; | 67 sql::Connection db_; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 // Test add and query for the URL table in the HistoryDatabase. | 70 // Test add and query for the URL table in the HistoryDatabase. |
| 71 TEST_F(URLDatabaseTest, AddURL) { | 71 TEST_F(URLDatabaseTest, AddURL) { |
| 72 // First, add two URLs. | 72 // First, add two URLs. |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 ASSERT_EQ(1u, rows.size()); | 337 ASSERT_EQ(1u, rows.size()); |
| 338 EXPECT_EQ(keyword2, rows[0].term); | 338 EXPECT_EQ(keyword2, rows[0].term); |
| 339 EXPECT_EQ(url_id3, rows[0].url_id); | 339 EXPECT_EQ(url_id3, rows[0].url_id); |
| 340 rows.clear(); | 340 rows.clear(); |
| 341 // No row for keyword. | 341 // No row for keyword. |
| 342 ASSERT_TRUE(GetKeywordSearchTermRows(keyword, &rows)); | 342 ASSERT_TRUE(GetKeywordSearchTermRows(keyword, &rows)); |
| 343 EXPECT_TRUE(rows.empty()); | 343 EXPECT_TRUE(rows.empty()); |
| 344 } | 344 } |
| 345 | 345 |
| 346 } // namespace history | 346 } // namespace history |
| OLD | NEW |