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 b46698b4c5815361ef48fcae8acf30c073cfaba1..c61bffbd335da2c41d051c546d871513d6d681f2 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" |
@@ -269,6 +270,25 @@ void SetFaviconImpl(Profile* profile, |
GetFaviconData(model, node); |
} |
+// Expires the favicon for |profile| and |node|. |profile| may be |
+// |test()->verifier()|. |
+void ExpireFaviconImpl(Profile* profile, const BookmarkNode* node) { |
+ favicon::FaviconService* favicon_service = |
+ FaviconServiceFactory::GetForProfile(profile, |
+ ServiceAccessType::EXPLICIT_ACCESS); |
+ favicon_service->SetFaviconOutOfDateForPage(node->url()); |
+} |
+ |
+// Called asynchronously from CheckFaviconExpired() with the favicon data from |
+// the database. |
+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. |
@@ -585,6 +605,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) { |