| 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/path_service.h" | 8 #include "base/path_service.h" |
| 8 #include "base/scoped_temp_dir.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" |
| 11 #include "chrome/browser/history/url_database.h" | 11 #include "chrome/browser/history/url_database.h" |
| 12 #include "sql/connection.h" | 12 #include "sql/connection.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 using base::Time; | 15 using base::Time; |
| 16 using base::TimeDelta; | 16 using base::TimeDelta; |
| 17 | 17 |
| 18 namespace history { | 18 namespace history { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 void TearDown() { |
| 63 db_.Close(); | 63 db_.Close(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 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. |
| 73 const GURL url1("http://www.google.com/"); | 73 const GURL url1("http://www.google.com/"); |
| 74 URLRow url_info1(url1); | 74 URLRow url_info1(url1); |
| 75 url_info1.set_title(UTF8ToUTF16("Google")); | 75 url_info1.set_title(UTF8ToUTF16("Google")); |
| 76 url_info1.set_visit_count(4); | 76 url_info1.set_visit_count(4); |
| (...skipping 260 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 |