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

Side by Side Diff: components/history/core/browser/thumbnail_database_unittest.cc

Issue 2828173002: [Refactor] Simplify HistoryBackend::UpdateFaviconMappingsAndFetchImpl() signature (Closed)
Patch Set: Merge branch 'master' into icon_type0 Created 3 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
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 kBlob1)); 362 kBlob1));
363 EXPECT_TRUE(CheckPageHasIcon(&db, 363 EXPECT_TRUE(CheckPageHasIcon(&db,
364 kPageUrl5, 364 kPageUrl5,
365 favicon_base::FAVICON, 365 favicon_base::FAVICON,
366 kIconUrl5, 366 kIconUrl5,
367 kLargeSize, 367 kLargeSize,
368 sizeof(kBlob2), 368 sizeof(kBlob2),
369 kBlob2)); 369 kBlob2));
370 370
371 // The ones not retained should be missing. 371 // The ones not retained should be missing.
372 EXPECT_FALSE(db.GetFaviconIDForFaviconURL(kPageUrl2, false, NULL)); 372 EXPECT_FALSE(db.GetIconMappingsForPageURL(kPageUrl2, nullptr));
373 EXPECT_FALSE(db.GetFaviconIDForFaviconURL(kPageUrl4, false, NULL)); 373 EXPECT_FALSE(db.GetIconMappingsForPageURL(kPageUrl4, nullptr));
374 374
375 // Schema should be the same. 375 // Schema should be the same.
376 EXPECT_EQ(original_schema, db.db_.GetSchema()); 376 EXPECT_EQ(original_schema, db.db_.GetSchema());
377 } 377 }
378 378
379 // Test that RetainDataForPageUrls() expires retained favicons. 379 // Test that RetainDataForPageUrls() expires retained favicons.
380 TEST_F(ThumbnailDatabaseTest, RetainDataForPageUrlsExpiresRetainedFavicons) { 380 TEST_F(ThumbnailDatabaseTest, RetainDataForPageUrlsExpiresRetainedFavicons) {
381 ThumbnailDatabase db(NULL); 381 ThumbnailDatabase db(NULL);
382 ASSERT_EQ(sql::INIT_OK, db.Init(file_name_)); 382 ASSERT_EQ(sql::INIT_OK, db.Init(file_name_));
383 db.BeginTransaction(); 383 db.BeginTransaction();
384 384
385 scoped_refptr<base::RefCountedStaticMemory> favicon1( 385 scoped_refptr<base::RefCountedStaticMemory> favicon1(
386 new base::RefCountedStaticMemory(kBlob1, sizeof(kBlob1))); 386 new base::RefCountedStaticMemory(kBlob1, sizeof(kBlob1)));
387 favicon_base::FaviconID kept_id = db.AddFavicon( 387 favicon_base::FaviconID kept_id = db.AddFavicon(
388 kIconUrl1, favicon_base::FAVICON, favicon1, base::Time::Now(), 388 kIconUrl1, favicon_base::FAVICON, favicon1, base::Time::Now(),
389 gfx::Size()); 389 gfx::Size());
390 db.AddIconMapping(kPageUrl1, kept_id); 390 db.AddIconMapping(kPageUrl1, kept_id);
391 391
392 EXPECT_TRUE(db.RetainDataForPageUrls(std::vector<GURL>(1u, kPageUrl1))); 392 EXPECT_TRUE(db.RetainDataForPageUrls(std::vector<GURL>(1u, kPageUrl1)));
393 393
394 favicon_base::FaviconID new_favicon_id = db.GetFaviconIDForFaviconURL( 394 favicon_base::FaviconID new_favicon_id =
395 kIconUrl1, favicon_base::FAVICON, nullptr); 395 db.GetFaviconIDForFaviconURL(kIconUrl1, favicon_base::FAVICON);
396 ASSERT_NE(0, new_favicon_id); 396 ASSERT_NE(0, new_favicon_id);
397 std::vector<FaviconBitmap> new_favicon_bitmaps; 397 std::vector<FaviconBitmap> new_favicon_bitmaps;
398 db.GetFaviconBitmaps(new_favicon_id, &new_favicon_bitmaps); 398 db.GetFaviconBitmaps(new_favicon_id, &new_favicon_bitmaps);
399 399
400 ASSERT_EQ(1u, new_favicon_bitmaps.size()); 400 ASSERT_EQ(1u, new_favicon_bitmaps.size());
401 EXPECT_EQ(0, new_favicon_bitmaps[0].last_updated.ToInternalValue()); 401 EXPECT_EQ(0, new_favicon_bitmaps[0].last_updated.ToInternalValue());
402 } 402 }
403 403
404 // Tests that deleting a favicon deletes the favicon row and favicon bitmap 404 // Tests that deleting a favicon deletes the favicon row and favicon bitmap
405 // rows from the database. 405 // rows from the database.
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 ThumbnailDatabase db(NULL); 1080 ThumbnailDatabase db(NULL);
1081 ASSERT_EQ(sql::INIT_OK, db.Init(db_path)); 1081 ASSERT_EQ(sql::INIT_OK, db.Init(db_path));
1082 1082
1083 // Verify that the resulting schema is correct, whether it 1083 // Verify that the resulting schema is correct, whether it
1084 // involved razing the file or fixing things in place. 1084 // involved razing the file or fixing things in place.
1085 VerifyTablesAndColumns(&db.db_); 1085 VerifyTablesAndColumns(&db.db_);
1086 } 1086 }
1087 } 1087 }
1088 1088
1089 } // namespace history 1089 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698