Chromium Code Reviews| Index: chrome/browser/sync/test/integration/bookmarks_helper.cc |
| diff --git a/chrome/browser/sync/test/integration/bookmarks_helper.cc b/chrome/browser/sync/test/integration/bookmarks_helper.cc |
| index 64f69291bc605d5563b0fb9adf0faea83ca56961..0e4a236dfd783cb14286400fde3b9dd586292a82 100644 |
| --- a/chrome/browser/sync/test/integration/bookmarks_helper.cc |
| +++ b/chrome/browser/sync/test/integration/bookmarks_helper.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/files/file_util.h" |
| #include "base/path_service.h" |
| #include "base/rand_util.h" |
| +#include "base/run_loop.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/stringprintf.h" |
| @@ -268,6 +269,21 @@ void SetFaviconImpl(Profile* profile, |
| GetFaviconData(model, node); |
| } |
| +void ExpireFaviconImpl(Profile* profile, const BookmarkNode* node) { |
|
Nicolas Zea
2015/05/14 04:08:23
nit: comment for these two methods and what they'r
pkotwicz
2015/05/14 14:54:36
Done.
|
| + favicon::FaviconService* favicon_service = |
| + FaviconServiceFactory::GetForProfile(profile, |
| + ServiceAccessType::EXPLICIT_ACCESS); |
| + favicon_service->SetFaviconOutOfDateForPage(node->url()); |
| +} |
| + |
| +void OnGotFaviconForExpiryCheck( |
| + const base::Closure& callback, |
| + const favicon_base::FaviconRawBitmapResult& bitmap_result) { |
| + ASSERT_TRUE(bitmap_result.is_valid()); |
| + ASSERT_TRUE(bitmap_result.expired); |
| + callback.Run(); |
| +} |
| + |
| // Wait for all currently scheduled tasks on the history thread for all |
| // profiles to complete and any notifications sent to the UI thread to have |
| // finished processing. |
| @@ -584,6 +600,41 @@ void SetFavicon(int profile, |
| favicon_source); |
| } |
| +void ExpireFavicon(int profile, const BookmarkNode* node) { |
| + BookmarkModel* model = GetBookmarkModel(profile); |
| + ASSERT_EQ(bookmarks::GetBookmarkNodeByID(model, node->id()), node) |
| + << "Node " << node->GetTitle() << " does not belong to " |
| + << "Profile " << profile; |
| + ASSERT_EQ(BookmarkNode::URL, node->type()) << "Node " << node->GetTitle() |
| + << " must be a url."; |
| + ASSERT_EQ(1u, urls_with_favicons_->count(node->url())); |
| + |
| + if (sync_datatype_helper::test()->use_verifier()) { |
| + const BookmarkNode* v_node = nullptr; |
| + FindNodeInVerifier(model, node, &v_node); |
| + ExpireFaviconImpl(sync_datatype_helper::test()->verifier(), node); |
| + } |
| + ExpireFaviconImpl(sync_datatype_helper::test()->GetProfile(profile), node); |
| + |
| + WaitForHistoryToProcessPendingTasks(); |
| +} |
| + |
| +void CheckFaviconExpired(int profile, const GURL& icon_url) { |
| + base::RunLoop run_loop; |
| + |
| + favicon::FaviconService* favicon_service = |
| + FaviconServiceFactory::GetForProfile( |
| + sync_datatype_helper::test()->GetProfile(profile), |
| + ServiceAccessType::EXPLICIT_ACCESS); |
| + base::CancelableTaskTracker task_tracker; |
| + favicon_service->GetRawFavicon( |
| + icon_url, favicon_base::FAVICON, 0, |
| + base::Bind(&OnGotFaviconForExpiryCheck, run_loop.QuitClosure()), |
| + &task_tracker); |
| + |
| + run_loop.Run(); |
| +} |
| + |
| const BookmarkNode* SetURL(int profile, |
| const BookmarkNode* node, |
| const GURL& new_url) { |