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

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

Issue 1100763002: Inject CanAddURLToHistory into TopSitesImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@prefs
Patch Set: Fix error introduced during rebase Created 5 years, 7 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
« no previous file with comments | « chrome/browser/history/history_unittest.cc ('k') | chrome/browser/history/top_sites_factory.cc » ('j') | 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 <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/files/file_enumerator.h" 9 #include "base/files/file_enumerator.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 kBlob2)); 380 kBlob2));
381 381
382 // The ones not retained should be missing. 382 // The ones not retained should be missing.
383 EXPECT_FALSE(db.GetFaviconIDForFaviconURL(kPageUrl2, false, NULL)); 383 EXPECT_FALSE(db.GetFaviconIDForFaviconURL(kPageUrl2, false, NULL));
384 EXPECT_FALSE(db.GetFaviconIDForFaviconURL(kPageUrl4, false, NULL)); 384 EXPECT_FALSE(db.GetFaviconIDForFaviconURL(kPageUrl4, false, NULL));
385 385
386 // Schema should be the same. 386 // Schema should be the same.
387 EXPECT_EQ(original_schema, db.db_.GetSchema()); 387 EXPECT_EQ(original_schema, db.db_.GetSchema());
388 } 388 }
389 389
390 // Test that RetainDataForPageUrls() expires retained favicons.
391 TEST_F(ThumbnailDatabaseTest, RetainDataForPageUrlsExpiresRetainedFavicons) {
392 ThumbnailDatabase db(NULL);
393 ASSERT_EQ(sql::INIT_OK, db.Init(file_name_));
394 db.BeginTransaction();
395
396 scoped_refptr<base::RefCountedStaticMemory> favicon1(
397 new base::RefCountedStaticMemory(kBlob1, sizeof(kBlob1)));
398 favicon_base::FaviconID kept_id = db.AddFavicon(
399 kIconUrl1, favicon_base::FAVICON, favicon1, base::Time::Now(),
400 gfx::Size());
401 db.AddIconMapping(kPageUrl1, kept_id);
402
403 EXPECT_TRUE(db.RetainDataForPageUrls(std::vector<GURL>(1u, kPageUrl1)));
404
405 favicon_base::FaviconID new_favicon_id = db.GetFaviconIDForFaviconURL(
406 kIconUrl1, favicon_base::FAVICON, nullptr);
407 ASSERT_NE(0, new_favicon_id);
408 std::vector<FaviconBitmap> new_favicon_bitmaps;
409 db.GetFaviconBitmaps(new_favicon_id, &new_favicon_bitmaps);
410
411 ASSERT_EQ(1u, new_favicon_bitmaps.size());
412 EXPECT_EQ(0, new_favicon_bitmaps[0].last_updated.ToInternalValue());
413 }
414
390 // Tests that deleting a favicon deletes the favicon row and favicon bitmap 415 // Tests that deleting a favicon deletes the favicon row and favicon bitmap
391 // rows from the database. 416 // rows from the database.
392 TEST_F(ThumbnailDatabaseTest, DeleteFavicon) { 417 TEST_F(ThumbnailDatabaseTest, DeleteFavicon) {
393 ThumbnailDatabase db(NULL); 418 ThumbnailDatabase db(NULL);
394 ASSERT_EQ(sql::INIT_OK, db.Init(file_name_)); 419 ASSERT_EQ(sql::INIT_OK, db.Init(file_name_));
395 db.BeginTransaction(); 420 db.BeginTransaction();
396 421
397 std::vector<unsigned char> data1(kBlob1, kBlob1 + sizeof(kBlob1)); 422 std::vector<unsigned char> data1(kBlob1, kBlob1 + sizeof(kBlob1));
398 scoped_refptr<base::RefCountedBytes> favicon1( 423 scoped_refptr<base::RefCountedBytes> favicon1(
399 new base::RefCountedBytes(data1)); 424 new base::RefCountedBytes(data1));
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 ThumbnailDatabase db(NULL); 1117 ThumbnailDatabase db(NULL);
1093 ASSERT_EQ(sql::INIT_OK, db.Init(db_path)); 1118 ASSERT_EQ(sql::INIT_OK, db.Init(db_path));
1094 1119
1095 // Verify that the resulting schema is correct, whether it 1120 // Verify that the resulting schema is correct, whether it
1096 // involved razing the file or fixing things in place. 1121 // involved razing the file or fixing things in place.
1097 VerifyTablesAndColumns(&db.db_); 1122 VerifyTablesAndColumns(&db.db_);
1098 } 1123 }
1099 } 1124 }
1100 1125
1101 } // namespace history 1126 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_unittest.cc ('k') | chrome/browser/history/top_sites_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698