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 4a5a6c6773f8ed681773f07512b91a4fbc90863c..53767d0df3cb24735c84bfdcf99d728803dbe3d6 100644 |
--- a/chrome/browser/sync/test/integration/bookmarks_helper.cc |
+++ b/chrome/browser/sync/test/integration/bookmarks_helper.cc |
@@ -27,6 +27,7 @@ |
#include "chrome/browser/sync/glue/bookmark_change_processor.h" |
#include "chrome/browser/sync/test/integration/multi_client_status_change_checker.h" |
#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
+#include "chrome/browser/sync/test/integration/single_client_status_change_checker.h" |
#include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
#include "chrome/browser/sync/test/integration/sync_test.h" |
#include "chrome/common/chrome_paths.h" |
@@ -755,6 +756,51 @@ bool AwaitAllModelsMatch() { |
return !checker.TimedOut(); |
} |
+namespace { |
+ |
+class CountBookmarksWithTitlesMatchingChecker |
+ : public SingleClientStatusChangeChecker { |
+ public: |
+ CountBookmarksWithTitlesMatchingChecker(ProfileSyncService* service, |
+ int profile_index, |
+ const std::string& title, |
+ int expected_count) |
+ : SingleClientStatusChangeChecker(service), |
+ profile_index_(profile_index), |
+ title_(title), |
+ expected_count_(expected_count) { |
+ DCHECK_GE(0, expected_count) << "expected_count must be non-negative."; |
+ } |
+ |
+ bool IsExitConditionSatisfied() override { |
+ int actual_count = CountBookmarksWithTitlesMatching(profile_index_, title_); |
+ return expected_count_ == actual_count; |
+ } |
+ |
+ std::string GetDebugMessage() const override { |
+ return "Waiting for bookmark count to match"; |
+ } |
+ |
+ private: |
+ const int profile_index_; |
+ const std::string title_; |
+ const int expected_count_; |
+}; |
+ |
+} // namespace |
+ |
+bool AwaitCountBookmarksWithTitlesMatching(int profile, |
+ const std::string& title, |
+ int expected_count) { |
+ ProfileSyncService* service = |
+ sync_datatype_helper::test()->GetSyncService(profile); |
+ CountBookmarksWithTitlesMatchingChecker checker(service, |
+ profile, |
+ title, |
+ expected_count); |
+ checker.Wait(); |
+ return !checker.TimedOut(); |
+} |
bool ContainsDuplicateBookmarks(int profile) { |
ui::TreeNodeIterator<const BookmarkNode> iterator( |