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

Unified Diff: chrome/browser/sync/test/integration/bookmarks_helper.cc

Issue 772513004: Add new E2E sync multi profiles tests. This should not affect any existing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 6 years 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 side-by-side diff with in-line comments
Download patch
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 1e665d6cde93e3f0bbf553d85002afc50994c56e..3e2745a72f01256d38f2a035a8c92c99a2007af7 100644
--- a/chrome/browser/sync/test/integration/bookmarks_helper.cc
+++ b/chrome/browser/sync/test/integration/bookmarks_helper.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/bookmarks/chrome_bookmark_client.h"
#include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
+#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/favicon/favicon_service.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/history/history_db_task.h"
@@ -36,6 +37,7 @@
#include "components/bookmarks/browser/bookmark_utils.h"
#include "components/favicon_base/favicon_util.h"
#include "components/history/core/browser/history_types.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -150,6 +152,20 @@ int CountNodesWithTitlesMatching(BookmarkModel* model,
return count;
}
+// Returns the number of nodes of node type |node_type| in |model|.
+int CountNodes(BookmarkModel* model, BookmarkNode::Type node_type) {
+ ui::TreeNodeIterator<const BookmarkNode> iterator(model->root_node());
+ // Walk through the model tree looking for bookmark nodes of node type
+ // |node_type|.
+ int count = 0;
+ while (iterator.has_next()) {
+ const BookmarkNode* node = iterator.Next();
+ if (node->type() == node_type)
+ ++count;
+ }
+ return count;
+}
+
// Checks if the favicon data in |bitmap_a| and |bitmap_b| are equivalent.
// Returns true if they match.
bool FaviconRawBitmapsMatch(const SkBitmap& bitmap_a,
@@ -654,6 +670,21 @@ void ReverseChildOrder(int profile, const BookmarkNode* parent) {
}
}
+void NotifyBookmarksSync(int profile) {
+ const syncer::ModelTypeSet types(syncer::BOOKMARKS);
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_SYNC_REFRESH_LOCAL,
+ content::Source<Profile>(
+ sync_datatype_helper::test()->GetProfile(profile)),
+ content::Details<const syncer::ModelTypeSet>(&types));
+}
+
+void NotifyBookmarksSyncToAllProfiles() {
+ for (int i = 0; i < sync_datatype_helper::test()->num_clients(); ++i) {
+ NotifyBookmarksSync(i);
+ }
+}
+
bool ModelMatchesVerifier(int profile) {
if (!sync_datatype_helper::test()->use_verifier()) {
LOG(ERROR) << "Illegal to call ModelMatchesVerifier() after "
@@ -771,6 +802,10 @@ const BookmarkNode* GetUniqueNodeByURL(int profile, const GURL& url) {
return nodes[0];
}
+int CountAllBookmarks(int profile) {
+ return CountNodes(GetBookmarkModel(profile), BookmarkNode::URL);
+}
+
int CountBookmarksWithTitlesMatching(int profile, const std::string& title) {
return CountNodesWithTitlesMatching(GetBookmarkModel(profile),
BookmarkNode::URL,

Powered by Google App Engine
This is Rietveld 408576698