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 "chrome/browser/history/url_database.h" | 10 #include "chrome/browser/history/url_database.h" |
11 #include "chrome/browser/history/visit_database.h" | 11 #include "chrome/browser/history/visit_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 #include "testing/platform_test.h" | 14 #include "testing/platform_test.h" |
15 | 15 |
16 using base::Time; | 16 using base::Time; |
17 using base::TimeDelta; | 17 using base::TimeDelta; |
18 | 18 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 void TearDown() { | 56 void TearDown() { |
57 db_.Close(); | 57 db_.Close(); |
58 PlatformTest::TearDown(); | 58 PlatformTest::TearDown(); |
59 } | 59 } |
60 | 60 |
61 // Provided for URL/VisitDatabase. | 61 // Provided for URL/VisitDatabase. |
62 virtual sql::Connection& GetDB() { | 62 virtual sql::Connection& GetDB() { |
63 return db_; | 63 return db_; |
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_F(VisitDatabaseTest, Add) { | 70 TEST_F(VisitDatabaseTest, Add) { |
71 // Add one visit. | 71 // Add one visit. |
72 VisitRow visit_info1(1, Time::Now(), 0, content::PAGE_TRANSITION_LINK, 0); | 72 VisitRow visit_info1(1, Time::Now(), 0, content::PAGE_TRANSITION_LINK, 0); |
73 EXPECT_TRUE(AddVisit(&visit_info1, SOURCE_BROWSED)); | 73 EXPECT_TRUE(AddVisit(&visit_info1, SOURCE_BROWSED)); |
74 | 74 |
75 // Add second visit for the same page. | 75 // Add second visit for the same page. |
76 VisitRow visit_info2(visit_info1.url_id, | 76 VisitRow visit_info2(visit_info1.url_id, |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 url_id, Time::Now(), 2, content::PAGE_TRANSITION_TYPED, 0); | 283 url_id, Time::Now(), 2, content::PAGE_TRANSITION_TYPED, 0); |
284 visit_info3.is_indexed = true; | 284 visit_info3.is_indexed = true; |
285 ASSERT_TRUE(AddVisit(&visit_info3, SOURCE_SYNCED)); | 285 ASSERT_TRUE(AddVisit(&visit_info3, SOURCE_SYNCED)); |
286 EXPECT_TRUE(GetVisitsForURL(url_id, &visits)); | 286 EXPECT_TRUE(GetVisitsForURL(url_id, &visits)); |
287 EXPECT_EQ(static_cast<size_t>(3), visits.size()); | 287 EXPECT_EQ(static_cast<size_t>(3), visits.size()); |
288 EXPECT_TRUE(GetIndexedVisitsForURL(url_id, &visits)); | 288 EXPECT_TRUE(GetIndexedVisitsForURL(url_id, &visits)); |
289 EXPECT_EQ(static_cast<size_t>(1), visits.size()); | 289 EXPECT_EQ(static_cast<size_t>(1), visits.size()); |
290 } | 290 } |
291 | 291 |
292 } // namespace history | 292 } // namespace history |
OLD | NEW |