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 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
863 ui::PAGE_TRANSITION_KEYWORD_GENERATED, | 863 ui::PAGE_TRANSITION_KEYWORD_GENERATED, |
864 history::SOURCE_BROWSED, false); | 864 history::SOURCE_BROWSED, false); |
865 backend_->AddPage(request); | 865 backend_->AddPage(request); |
866 | 866 |
867 // A row should have been added for the url. | 867 // A row should have been added for the url. |
868 URLRow row; | 868 URLRow row; |
869 URLID url_id = backend_->db()->GetRowForURL(url, &row); | 869 URLID url_id = backend_->db()->GetRowForURL(url, &row); |
870 ASSERT_NE(0, url_id); | 870 ASSERT_NE(0, url_id); |
871 | 871 |
872 // The typed count should be 1. | 872 // The typed count should be 1. |
873 ASSERT_EQ(1, row.typed_count()); | 873 ASSERT_EQ(1, row.typed_count()); |
Peter Kasting
2015/03/24 22:09:59
Can you extend this test somewhere to verify that
Charlie Reis
2015/03/27 17:03:14
Done.
| |
874 | 874 |
875 // KEYWORD_GENERATED urls should not be added to the segment db. | 875 // KEYWORD_GENERATED urls should not be added to the segment db. |
876 std::string segment_name = VisitSegmentDatabase::ComputeSegmentName(url); | 876 std::string segment_name = VisitSegmentDatabase::ComputeSegmentName(url); |
877 EXPECT_EQ(0, backend_->db()->GetSegmentNamed(segment_name)); | 877 EXPECT_EQ(0, backend_->db()->GetSegmentNamed(segment_name)); |
878 | 878 |
879 // One visit should be added. | 879 // One visit should be added. |
880 VisitVector visits; | 880 VisitVector visits; |
881 EXPECT_TRUE(backend_->db()->GetVisitsForURL(url_id, &visits)); | 881 EXPECT_TRUE(backend_->db()->GetVisitsForURL(url_id, &visits)); |
882 EXPECT_EQ(1U, visits.size()); | 882 EXPECT_EQ(1U, visits.size()); |
883 | 883 |
(...skipping 311 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, | |
Peter Kasting
2015/03/24 22:09:59
I would explicitly check that typed and visit coun
Charlie Reis
2015/03/27 17:03:14
Done.
| |
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 |