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

Side by Side Diff: chrome/browser/visitedlink/visitedlink_unittest.cc

Issue 10096015: Single URL Expires Were Not Being Deleted. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/visitedlink/visitedlink_master.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 <cstdio> 5 #include <cstdio>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 ASSERT_TRUE(InitHistory()); 256 ASSERT_TRUE(InitHistory());
257 ASSERT_TRUE(InitVisited(16381, true)); 257 ASSERT_TRUE(InitVisited(16381, true));
258 258
259 // Add the base set of URLs that won't be deleted. 259 // Add the base set of URLs that won't be deleted.
260 // Reload() will test for these. 260 // Reload() will test for these.
261 for (int32 i = 0; i < g_test_count; i++) 261 for (int32 i = 0; i < g_test_count; i++)
262 master_->AddURL(TestURL(i)); 262 master_->AddURL(TestURL(i));
263 263
264 // Add more URLs than necessary to trigger this case. 264 // Add more URLs than necessary to trigger this case.
265 const int kTestDeleteCount = VisitedLinkMaster::kBigDeleteThreshold + 2; 265 const int kTestDeleteCount = VisitedLinkMaster::kBigDeleteThreshold + 2;
266 std::set<GURL> urls_to_delete; 266 history::URLRows urls_to_delete;
267 for (int32 i = g_test_count; i < g_test_count + kTestDeleteCount; i++) { 267 for (int32 i = g_test_count; i < g_test_count + kTestDeleteCount; i++) {
268 GURL url(TestURL(i)); 268 GURL url(TestURL(i));
269 master_->AddURL(url); 269 master_->AddURL(url);
270 urls_to_delete.insert(url); 270 urls_to_delete.push_back(history::URLRow(url));
271 } 271 }
272 272
273 master_->DeleteURLs(urls_to_delete); 273 master_->DeleteURLs(urls_to_delete);
274 master_->DebugValidate(); 274 master_->DebugValidate();
275 275
276 Reload(); 276 Reload();
277 } 277 }
278 278
279 TEST_F(VisitedLinkTest, DeleteAll) { 279 TEST_F(VisitedLinkTest, DeleteAll) {
280 ASSERT_TRUE(InitHistory()); 280 ASSERT_TRUE(InitHistory());
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 // can't be 100% sure we're testing the right thing, but in practice is. 392 // can't be 100% sure we're testing the right thing, but in practice is.
393 // All the adds above will generally take some time queuing up on the 393 // All the adds above will generally take some time queuing up on the
394 // history thread, and it will take a while to catch up to actually 394 // history thread, and it will take a while to catch up to actually
395 // processing the rebuild that has queued behind it. We will generally 395 // processing the rebuild that has queued behind it. We will generally
396 // finish adding all of the URLs before it has even found the first URL. 396 // finish adding all of the URLs before it has even found the first URL.
397 for (int i = history_count; i < g_test_count; i++) 397 for (int i = history_count; i < g_test_count; i++)
398 master_->AddURL(TestURL(i)); 398 master_->AddURL(TestURL(i));
399 399
400 // Add one more and then delete it. 400 // Add one more and then delete it.
401 master_->AddURL(TestURL(g_test_count)); 401 master_->AddURL(TestURL(g_test_count));
402 std::set<GURL> deleted_urls; 402 history::URLRows deleted_urls;
403 deleted_urls.insert(TestURL(g_test_count)); 403 deleted_urls.push_back(history::URLRow(TestURL(g_test_count)));
404 master_->DeleteURLs(deleted_urls); 404 master_->DeleteURLs(deleted_urls);
405 405
406 // Wait for the rebuild to complete. The task will terminate the message 406 // Wait for the rebuild to complete. The task will terminate the message
407 // loop when the rebuild is done. There's no chance that the rebuild will 407 // loop when the rebuild is done. There's no chance that the rebuild will
408 // complete before we set the task because the rebuild completion message 408 // complete before we set the task because the rebuild completion message
409 // is posted to the message loop; until we Run() it, rebuild can not 409 // is posted to the message loop; until we Run() it, rebuild can not
410 // complete. 410 // complete.
411 master_->set_rebuild_complete_task(MessageLoop::QuitClosure()); 411 master_->set_rebuild_complete_task(MessageLoop::QuitClosure());
412 MessageLoop::current()->Run(); 412 MessageLoop::current()->Run();
413 413
(...skipping 26 matching lines...) Expand all
440 TEST_F(VisitedLinkTest, Listener) { 440 TEST_F(VisitedLinkTest, Listener) {
441 ASSERT_TRUE(InitHistory()); 441 ASSERT_TRUE(InitHistory());
442 ASSERT_TRUE(InitVisited(0, true)); 442 ASSERT_TRUE(InitVisited(0, true));
443 443
444 // Add test URLs. 444 // Add test URLs.
445 for (int i = 0; i < g_test_count; i++) { 445 for (int i = 0; i < g_test_count; i++) {
446 master_->AddURL(TestURL(i)); 446 master_->AddURL(TestURL(i));
447 ASSERT_EQ(i + 1, master_->GetUsedCount()); 447 ASSERT_EQ(i + 1, master_->GetUsedCount());
448 } 448 }
449 449
450 std::set<GURL> deleted_urls; 450 history::URLRows deleted_urls;
451 deleted_urls.insert(TestURL(0)); 451 deleted_urls.push_back(history::URLRow(TestURL(0)));
452 // Delete an URL. 452 // Delete an URL.
453 master_->DeleteURLs(deleted_urls); 453 master_->DeleteURLs(deleted_urls);
454 // ... and all of the remaining ones. 454 // ... and all of the remaining ones.
455 master_->DeleteAllURLs(); 455 master_->DeleteAllURLs();
456 456
457 // Verify that VisitedLinkMaster::Listener::Add was called for each added URL. 457 // Verify that VisitedLinkMaster::Listener::Add was called for each added URL.
458 EXPECT_EQ(g_test_count, listener_.add_count()); 458 EXPECT_EQ(g_test_count, listener_.add_count());
459 // Verify that VisitedLinkMaster::Listener::Reset was called both when one and 459 // Verify that VisitedLinkMaster::Listener::Reset was called both when one and
460 // all URLs are deleted. 460 // all URLs are deleted.
461 EXPECT_EQ(2, listener_.reset_count()); 461 EXPECT_EQ(2, listener_.reset_count());
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 EXPECT_EQ(1, profile()->add_event_count()); 712 EXPECT_EQ(1, profile()->add_event_count());
713 EXPECT_EQ(0, profile()->reset_event_count()); 713 EXPECT_EQ(0, profile()->reset_event_count());
714 714
715 // Activate the tab. 715 // Activate the tab.
716 rvh_tester()->SimulateWasRestored(); 716 rvh_tester()->SimulateWasRestored();
717 717
718 // We should have only one more reset event. 718 // We should have only one more reset event.
719 EXPECT_EQ(1, profile()->add_event_count()); 719 EXPECT_EQ(1, profile()->add_event_count());
720 EXPECT_EQ(1, profile()->reset_event_count()); 720 EXPECT_EQ(1, profile()->reset_event_count());
721 } 721 }
OLDNEW
« no previous file with comments | « chrome/browser/visitedlink/visitedlink_master.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698