| 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 <set> | 5 #include <set> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 class VisitDatabaseTest : public PlatformTest, | 39 class VisitDatabaseTest : public PlatformTest, |
| 40 public URLDatabase, | 40 public URLDatabase, |
| 41 public VisitDatabase { | 41 public VisitDatabase { |
| 42 public: | 42 public: |
| 43 VisitDatabaseTest() { | 43 VisitDatabaseTest() { |
| 44 } | 44 } |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 // Test setup. | 47 // Test setup. |
| 48 void SetUp() { | 48 virtual void SetUp() { |
| 49 PlatformTest::SetUp(); | 49 PlatformTest::SetUp(); |
| 50 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 50 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 51 FilePath db_file = temp_dir_.path().AppendASCII("VisitTest.db"); | 51 FilePath db_file = temp_dir_.path().AppendASCII("VisitTest.db"); |
| 52 | 52 |
| 53 EXPECT_TRUE(db_.Open(db_file)); | 53 EXPECT_TRUE(db_.Open(db_file)); |
| 54 | 54 |
| 55 // Initialize the tables for this test. | 55 // Initialize the tables for this test. |
| 56 CreateURLTable(false); | 56 CreateURLTable(false); |
| 57 CreateMainURLIndex(); | 57 CreateMainURLIndex(); |
| 58 InitVisitTable(); | 58 InitVisitTable(); |
| 59 } | 59 } |
| 60 void TearDown() { | 60 virtual void TearDown() { |
| 61 db_.Close(); | 61 db_.Close(); |
| 62 PlatformTest::TearDown(); | 62 PlatformTest::TearDown(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 // Provided for URL/VisitDatabase. | 65 // Provided for URL/VisitDatabase. |
| 66 virtual sql::Connection& GetDB() { | 66 virtual sql::Connection& GetDB() OVERRIDE { |
| 67 return db_; | 67 return db_; |
| 68 } | 68 } |
| 69 | 69 |
| 70 base::ScopedTempDir temp_dir_; | 70 base::ScopedTempDir temp_dir_; |
| 71 sql::Connection db_; | 71 sql::Connection db_; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 TEST_F(VisitDatabaseTest, Add) { | 74 TEST_F(VisitDatabaseTest, Add) { |
| 75 // Add one visit. | 75 // Add one visit. |
| 76 VisitRow visit_info1(1, Time::Now(), 0, content::PAGE_TRANSITION_LINK, 0); | 76 VisitRow visit_info1(1, Time::Now(), 0, content::PAGE_TRANSITION_LINK, 0); |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 url_id, Time::Now(), 2, content::PAGE_TRANSITION_TYPED, 0); | 400 url_id, Time::Now(), 2, content::PAGE_TRANSITION_TYPED, 0); |
| 401 visit_info3.is_indexed = true; | 401 visit_info3.is_indexed = true; |
| 402 ASSERT_TRUE(AddVisit(&visit_info3, SOURCE_SYNCED)); | 402 ASSERT_TRUE(AddVisit(&visit_info3, SOURCE_SYNCED)); |
| 403 EXPECT_TRUE(GetVisitsForURL(url_id, &visits)); | 403 EXPECT_TRUE(GetVisitsForURL(url_id, &visits)); |
| 404 EXPECT_EQ(static_cast<size_t>(3), visits.size()); | 404 EXPECT_EQ(static_cast<size_t>(3), visits.size()); |
| 405 EXPECT_TRUE(GetIndexedVisitsForURL(url_id, &visits)); | 405 EXPECT_TRUE(GetIndexedVisitsForURL(url_id, &visits)); |
| 406 EXPECT_EQ(static_cast<size_t>(1), visits.size()); | 406 EXPECT_EQ(static_cast<size_t>(1), visits.size()); |
| 407 } | 407 } |
| 408 | 408 |
| 409 } // namespace history | 409 } // namespace history |
| OLD | NEW |