Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: chrome/browser/history/history_backend_unittest.cc

Issue 323043004: Make NOTIFICATION_HISTORY_URLS_MODIFIED fired consistently for both typed and non-typed URLs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/history/history_backend.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/history/history_backend.h" 5 #include "chrome/browser/history/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 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 backend_->AddPagesWithDetails(rows, history::SOURCE_BROWSED); 937 backend_->AddPagesWithDetails(rows, history::SOURCE_BROWSED);
938 938
939 // Verify that recent URLs have ended up in the main |db_|, while the already 939 // Verify that recent URLs have ended up in the main |db_|, while the already
940 // expired URL has been ignored. 940 // expired URL has been ignored.
941 URLRow stored_row1, stored_row2, stored_row3, stored_row4; 941 URLRow stored_row1, stored_row2, stored_row3, stored_row4;
942 EXPECT_NE(0, backend_->db_->GetRowForURL(row1.url(), &stored_row1)); 942 EXPECT_NE(0, backend_->db_->GetRowForURL(row1.url(), &stored_row1));
943 EXPECT_NE(0, backend_->db_->GetRowForURL(row2.url(), &stored_row2)); 943 EXPECT_NE(0, backend_->db_->GetRowForURL(row2.url(), &stored_row2));
944 EXPECT_NE(0, backend_->db_->GetRowForURL(row3.url(), &stored_row3)); 944 EXPECT_NE(0, backend_->db_->GetRowForURL(row3.url(), &stored_row3));
945 EXPECT_EQ(0, backend_->db_->GetRowForURL(row4.url(), &stored_row4)); 945 EXPECT_EQ(0, backend_->db_->GetRowForURL(row4.url(), &stored_row4));
946 946
947 // Ensure that a notification was fired, and further verify that the IDs in 947 // Ensure that a notification was fired for both typed and non-typed URLs.
948 // the notification are set to those that are in effect in the main database. 948 // Further verify that the IDs in the notification are set to those that are
949 // The InMemoryHistoryBackend relies on this for caching. 949 // in effect in the main database. The InMemoryHistoryBackend relies on this
950 // for caching.
950 ASSERT_EQ(1u, broadcasted_notifications().size()); 951 ASSERT_EQ(1u, broadcasted_notifications().size());
951 ASSERT_EQ(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, 952 ASSERT_EQ(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED,
952 broadcasted_notifications()[0].first); 953 broadcasted_notifications()[0].first);
953 const URLsModifiedDetails* details = static_cast<const URLsModifiedDetails*>( 954 const URLsModifiedDetails* details = static_cast<const URLsModifiedDetails*>(
954 broadcasted_notifications()[0].second); 955 broadcasted_notifications()[0].second);
955 EXPECT_EQ(2u, details->changed_urls.size()); 956 EXPECT_EQ(3u, details->changed_urls.size());
957
958 URLRows::const_iterator it_row1 = std::find_if(
959 details->changed_urls.begin(),
960 details->changed_urls.end(),
961 history::URLRow::URLRowHasURL(row1.url()));
962 ASSERT_NE(details->changed_urls.end(), it_row1);
963 EXPECT_EQ(stored_row1.id(), it_row1->id());
956 964
957 URLRows::const_iterator it_row2 = std::find_if( 965 URLRows::const_iterator it_row2 = std::find_if(
958 details->changed_urls.begin(), 966 details->changed_urls.begin(),
959 details->changed_urls.end(), 967 details->changed_urls.end(),
960 history::URLRow::URLRowHasURL(row2.url())); 968 history::URLRow::URLRowHasURL(row2.url()));
961 ASSERT_NE(details->changed_urls.end(), it_row2); 969 ASSERT_NE(details->changed_urls.end(), it_row2);
962 EXPECT_EQ(stored_row2.id(), it_row2->id()); 970 EXPECT_EQ(stored_row2.id(), it_row2->id());
963 971
964 URLRows::const_iterator it_row3 = std::find_if( 972 URLRows::const_iterator it_row3 = std::find_if(
965 details->changed_urls.begin(), 973 details->changed_urls.begin(),
966 details->changed_urls.end(), 974 details->changed_urls.end(),
967 history::URLRow::URLRowHasURL(row3.url())); 975 history::URLRow::URLRowHasURL(row3.url()));
968 ASSERT_NE(details->changed_urls.end(), it_row3); 976 ASSERT_NE(details->changed_urls.end(), it_row3);
969 EXPECT_EQ(stored_row3.id(), it_row3->id()); 977 EXPECT_EQ(stored_row3.id(), it_row3->id());
970 } 978 }
(...skipping 2380 matching lines...) Expand 10 before | Expand all | Expand 10 after
3351 // Verify that the second term is no longer returned as result, and also check 3359 // Verify that the second term is no longer returned as result, and also check
3352 // at the low level that it is gone for good. The term corresponding to the 3360 // at the low level that it is gone for good. The term corresponding to the
3353 // first URLRow should not be affected. 3361 // first URLRow should not be affected.
3354 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); 3362 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1));
3355 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); 3363 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2));
3356 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); 3364 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL));
3357 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); 3365 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL));
3358 } 3366 }
3359 3367
3360 } // namespace history 3368 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_backend.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698