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 "components/history/core/browser/history_backend.h" | 5 #include "components/history/core/browser/history_backend.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 | 1195 |
1196 // Fetch the row information about stripped url from history db. | 1196 // Fetch the row information about stripped url from history db. |
1197 VisitVector visits; | 1197 VisitVector visits; |
1198 URLID row_id = backend_->db_->GetRowForURL(stripped_url, NULL); | 1198 URLID row_id = backend_->db_->GetRowForURL(stripped_url, NULL); |
1199 backend_->db_->GetVisitsForURL(row_id, &visits); | 1199 backend_->db_->GetVisitsForURL(row_id, &visits); |
1200 | 1200 |
1201 // Check if stripped url is stored in database. | 1201 // Check if stripped url is stored in database. |
1202 ASSERT_EQ(1U, visits.size()); | 1202 ASSERT_EQ(1U, visits.size()); |
1203 } | 1203 } |
1204 | 1204 |
| 1205 TEST_F(HistoryBackendTest, AddPageVisitBackForward) { |
| 1206 ASSERT_TRUE(backend_.get()); |
| 1207 |
| 1208 GURL url("http://www.google.com"); |
| 1209 |
| 1210 // Clear all history. |
| 1211 backend_->DeleteAllHistory(); |
| 1212 |
| 1213 // Visit the url after typing it. |
| 1214 backend_->AddPageVisit(url, base::Time::Now(), 0, |
| 1215 ui::PAGE_TRANSITION_TYPED, |
| 1216 history::SOURCE_BROWSED); |
| 1217 |
| 1218 // Visit the url again via back/forward. |
| 1219 backend_->AddPageVisit(url, base::Time::Now(), 0, |
| 1220 ui::PageTransitionFromInt( |
| 1221 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FORWARD_BACK), |
| 1222 history::SOURCE_BROWSED); |
| 1223 |
| 1224 // Ensure the typed count is only 1 but the visit count is 2. |
| 1225 VisitVector visits; |
| 1226 URLRow row; |
| 1227 URLID id = backend_->db()->GetRowForURL(url, &row); |
| 1228 ASSERT_TRUE(backend_->db()->GetVisitsForURL(id, &visits)); |
| 1229 EXPECT_EQ(1, row.typed_count()); |
| 1230 EXPECT_EQ(2, row.visit_count()); |
| 1231 } |
| 1232 |
1205 TEST_F(HistoryBackendTest, AddPageVisitSource) { | 1233 TEST_F(HistoryBackendTest, AddPageVisitSource) { |
1206 ASSERT_TRUE(backend_.get()); | 1234 ASSERT_TRUE(backend_.get()); |
1207 | 1235 |
1208 GURL url("http://www.google.com"); | 1236 GURL url("http://www.google.com"); |
1209 | 1237 |
1210 // Clear all history. | 1238 // Clear all history. |
1211 backend_->DeleteAllHistory(); | 1239 backend_->DeleteAllHistory(); |
1212 | 1240 |
1213 // Assume visiting the url from an externsion. | 1241 // Assume visiting the url from an externsion. |
1214 backend_->AddPageVisit( | 1242 backend_->AddPageVisit( |
(...skipping 2075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3290 // Verify that the second term is no longer returned as result, and also check | 3318 // Verify that the second term is no longer returned as result, and also check |
3291 // at the low level that it is gone for good. The term corresponding to the | 3319 // at the low level that it is gone for good. The term corresponding to the |
3292 // first URLRow should not be affected. | 3320 // first URLRow should not be affected. |
3293 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); | 3321 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); |
3294 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); | 3322 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); |
3295 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); | 3323 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); |
3296 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); | 3324 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); |
3297 } | 3325 } |
3298 | 3326 |
3299 } // namespace history | 3327 } // namespace history |
OLD | NEW |