OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "components/history/core/browser/keyword_search_term.h" | 10 #include "components/history/core/browser/keyword_search_term.h" |
(...skipping 27 matching lines...) Expand all Loading... |
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 sql::Connection& GetDB() override { return db_; } | 44 sql::Connection& GetDB() override { return db_; } |
45 | 45 |
46 private: | 46 private: |
47 // Test setup. | 47 // Test setup. |
48 virtual void SetUp() { | 48 void SetUp() override { |
49 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 49 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
50 base::FilePath db_file = temp_dir_.path().AppendASCII("URLTest.db"); | 50 base::FilePath db_file = temp_dir_.path().AppendASCII("URLTest.db"); |
51 | 51 |
52 EXPECT_TRUE(db_.Open(db_file)); | 52 EXPECT_TRUE(db_.Open(db_file)); |
53 | 53 |
54 // Initialize the tables for this test. | 54 // Initialize the tables for this test. |
55 CreateURLTable(false); | 55 CreateURLTable(false); |
56 CreateMainURLIndex(); | 56 CreateMainURLIndex(); |
57 InitKeywordSearchTermsTable(); | 57 InitKeywordSearchTermsTable(); |
58 CreateKeywordSearchTermsIndices(); | 58 CreateKeywordSearchTermsIndices(); |
59 } | 59 } |
60 virtual void TearDown() { | 60 void TearDown() override { db_.Close(); } |
61 db_.Close(); | |
62 } | |
63 | 61 |
64 base::ScopedTempDir temp_dir_; | 62 base::ScopedTempDir temp_dir_; |
65 sql::Connection db_; | 63 sql::Connection db_; |
66 }; | 64 }; |
67 | 65 |
68 // Test add, update, upsert, and query for the URL table in the HistoryDatabase. | 66 // Test add, update, upsert, and query for the URL table in the HistoryDatabase. |
69 TEST_F(URLDatabaseTest, AddAndUpdateURL) { | 67 TEST_F(URLDatabaseTest, AddAndUpdateURL) { |
70 // First, add two URLs. | 68 // First, add two URLs. |
71 const GURL url1("http://www.google.com/"); | 69 const GURL url1("http://www.google.com/"); |
72 URLRow url_info1(url1); | 70 URLRow url_info1(url1); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 ASSERT_EQ(1u, rows.size()); | 323 ASSERT_EQ(1u, rows.size()); |
326 EXPECT_EQ(keyword2, rows[0].term); | 324 EXPECT_EQ(keyword2, rows[0].term); |
327 EXPECT_EQ(url_id3, rows[0].url_id); | 325 EXPECT_EQ(url_id3, rows[0].url_id); |
328 rows.clear(); | 326 rows.clear(); |
329 // No row for keyword. | 327 // No row for keyword. |
330 ASSERT_TRUE(GetKeywordSearchTermRows(keyword, &rows)); | 328 ASSERT_TRUE(GetKeywordSearchTermRows(keyword, &rows)); |
331 EXPECT_TRUE(rows.empty()); | 329 EXPECT_TRUE(rows.empty()); |
332 } | 330 } |
333 | 331 |
334 } // namespace history | 332 } // namespace history |
OLD | NEW |