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

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

Issue 242693003: Introduce BookmarkClient interface to abstract embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing reviewer comments Created 6 years, 8 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
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 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 767
768 URLRows rows; 768 URLRows rows;
769 rows.push_back(row2); // Reversed order for the same reason as favicons. 769 rows.push_back(row2); // Reversed order for the same reason as favicons.
770 rows.push_back(row1); 770 rows.push_back(row1);
771 backend_->AddPagesWithDetails(rows, history::SOURCE_BROWSED); 771 backend_->AddPagesWithDetails(rows, history::SOURCE_BROWSED);
772 772
773 URLID row1_id = backend_->db_->GetRowForURL(row1.url(), NULL); 773 URLID row1_id = backend_->db_->GetRowForURL(row1.url(), NULL);
774 URLID row2_id = backend_->db_->GetRowForURL(row2.url(), NULL); 774 URLID row2_id = backend_->db_->GetRowForURL(row2.url(), NULL);
775 775
776 // Star the two URLs. 776 // Star the two URLs.
777 bookmark_utils::AddIfNotBookmarked(&bookmark_model_, row1.url(), 777 bookmark_utils::AddIfNotBookmarked(
778 base::string16()); 778 &bookmark_model_, &bookmark_model_, row1.url(), base::string16());
779 bookmark_utils::AddIfNotBookmarked(&bookmark_model_, row2.url(), 779 bookmark_utils::AddIfNotBookmarked(
780 base::string16()); 780 &bookmark_model_, &bookmark_model_, row2.url(), base::string16());
781 781
782 // Delete url 2. Because url 2 is starred this won't delete the URL, only 782 // Delete url 2. Because url 2 is starred this won't delete the URL, only
783 // the visits. 783 // the visits.
784 backend_->expirer_.DeleteURL(row2.url()); 784 backend_->expirer_.DeleteURL(row2.url());
785 785
786 // Make sure url 2 is still valid, but has no visits. 786 // Make sure url 2 is still valid, but has no visits.
787 URLRow tmp_url_row; 787 URLRow tmp_url_row;
788 EXPECT_EQ(row2_id, backend_->db_->GetRowForURL(row2.url(), NULL)); 788 EXPECT_EQ(row2_id, backend_->db_->GetRowForURL(row2.url(), NULL));
789 VisitVector visits; 789 VisitVector visits;
790 backend_->db_->GetVisitsForURL(row2_id, &visits); 790 backend_->db_->GetVisitsForURL(row2_id, &visits);
(...skipping 2334 matching lines...) Expand 10 before | Expand all | Expand 10 after
3125 TEST_F(HistoryBackendTest, RemoveNotification) { 3125 TEST_F(HistoryBackendTest, RemoveNotification) {
3126 scoped_ptr<TestingProfile> profile(new TestingProfile()); 3126 scoped_ptr<TestingProfile> profile(new TestingProfile());
3127 3127
3128 ASSERT_TRUE(profile->CreateHistoryService(false, false)); 3128 ASSERT_TRUE(profile->CreateHistoryService(false, false));
3129 profile->CreateBookmarkModel(true); 3129 profile->CreateBookmarkModel(true);
3130 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile.get()); 3130 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile.get());
3131 test::WaitForBookmarkModelToLoad(model); 3131 test::WaitForBookmarkModelToLoad(model);
3132 3132
3133 // Add a URL. 3133 // Add a URL.
3134 GURL url("http://www.google.com"); 3134 GURL url("http://www.google.com");
3135 bookmark_utils::AddIfNotBookmarked(model, url, base::string16()); 3135 bookmark_utils::AddIfNotBookmarked(model, model, url, base::string16());
3136 3136
3137 HistoryService* service = HistoryServiceFactory::GetForProfile( 3137 HistoryService* service = HistoryServiceFactory::GetForProfile(
3138 profile.get(), Profile::EXPLICIT_ACCESS); 3138 profile.get(), Profile::EXPLICIT_ACCESS);
3139 3139
3140 service->AddPage( 3140 service->AddPage(
3141 url, base::Time::Now(), NULL, 1, GURL(), RedirectList(), 3141 url, base::Time::Now(), NULL, 1, GURL(), RedirectList(),
3142 content::PAGE_TRANSITION_TYPED, SOURCE_BROWSED, false); 3142 content::PAGE_TRANSITION_TYPED, SOURCE_BROWSED, false);
3143 3143
3144 // This won't actually delete the URL, rather it'll empty out the visits. 3144 // This won't actually delete the URL, rather it'll empty out the visits.
3145 // This triggers blocking on the BookmarkModel. 3145 // This triggers blocking on the BookmarkModel.
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
3384 // Verify that the second term is no longer returned as result, and also check 3384 // Verify that the second term is no longer returned as result, and also check
3385 // at the low level that it is gone for good. The term corresponding to the 3385 // at the low level that it is gone for good. The term corresponding to the
3386 // first URLRow should not be affected. 3386 // first URLRow should not be affected.
3387 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); 3387 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1));
3388 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); 3388 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2));
3389 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); 3389 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL));
3390 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); 3390 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL));
3391 } 3391 }
3392 3392
3393 } // namespace history 3393 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698