diff options
author | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-17 02:42:14 +0000 |
---|---|---|
committer | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-17 02:42:14 +0000 |
commit | 0f9aaafa8e60e7534f8bcfc818ab3acea335a682 (patch) | |
tree | c9ec691f6e1a4b312fc581088415b05f5f7ce9b2 /chrome | |
parent | 6f899a390868a2fad43cd34ad71027d693615577 (diff) | |
download | chromium_src-0f9aaafa8e60e7534f8bcfc818ab3acea335a682.zip chromium_src-0f9aaafa8e60e7534f8bcfc818ab3acea335a682.tar.gz chromium_src-0f9aaafa8e60e7534f8bcfc818ab3acea335a682.tar.bz2 |
Merge 63606 - Full refactor / rewrite of bookmark sync integration tests
Note: This is required to fix the sync tests on chrome OS.
See http://code.google.com/p/chromium-os/issues/detail?id=9262
The LiveBookmarksSyncTest and BookmarkModelVerifier classes were designed over a year ago and are badly in need of a refactor. Bookmark sync integration test cases are extremely cumbersome to write, review and read, with individual tests requiring a lot of repeated code.
This patch contains the following:
- A refactor of the BookmarkModelVerifier class.
- A major update to the LiveBookmarksSyncTest class, providing test cases with a bunch of new easy-to-use methods to perform various bookmark operations.
- A complete rewrite of every single bookmark sync integration test case using the new methods. (phew!)
In addition, this patch does the following:
- Replaces all instances of EXPECT_* in test cases with ASSERT_*, thereby avoiding several pages of irrelevant logs in case of failures, and making logs a lot easier to read.
- Annotates a few methods with WARN_UNUSED_RESULT so that test cases are forced to verify their results before proceeding.
BUG=59301,56043,19769
TEST=sync_integration_tests
Review URL: http://codereview.chromium.org/3971003
TBR=rsimha@chromium.org
Review URL: http://codereview.chromium.org/5143001
git-svn-id: svn://svn.chromium.org/chrome/branches/552d/src@66372 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
18 files changed, 1624 insertions, 2582 deletions
diff --git a/chrome/test/live_sync/bookmark_model_verifier.cc b/chrome/test/live_sync/bookmark_model_verifier.cc index e2edd8b..7f900ae 100644 --- a/chrome/test/live_sync/bookmark_model_verifier.cc +++ b/chrome/test/live_sync/bookmark_model_verifier.cc @@ -10,96 +10,83 @@ #include "app/tree_node_iterator.h" #include "base/rand_util.h" #include "base/string_number_conversions.h" -#include "base/utf_string_conversions.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_utils.h" -#include "chrome/test/live_sync/live_bookmarks_sync_test.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/skia/include/core/SkBitmap.h" - -using std::string; -using std::wstring; // static -void BookmarkModelVerifier::ExpectBookmarkInfoMatch( - const BookmarkNode* expected, const BookmarkNode* actual) { - EXPECT_EQ(expected->GetTitle(), actual->GetTitle()); - EXPECT_EQ(expected->is_folder(), actual->is_folder()); - EXPECT_EQ(expected->GetURL(), actual->GetURL()); - EXPECT_EQ(expected->GetParent()->IndexOfChild(expected), - actual->GetParent()->IndexOfChild(actual)); -} - -BookmarkModelVerifier::BookmarkModelVerifier(BookmarkModel* model) - : model_(model) {} - -BookmarkModelVerifier* BookmarkModelVerifier::Create(BookmarkModel* model) { - BookmarkModelVerifier* v = new BookmarkModelVerifier(model); - ui_test_utils::WaitForBookmarkModelToLoad(v->model_); - return v; -} - -void BookmarkModelVerifier::ExpectMatch(BookmarkModel* actual) { - ExpectModelsMatch(model_, actual); +bool BookmarkModelVerifier::NodesMatch(const BookmarkNode* node_a, + const BookmarkNode* node_b) { + if (node_a == NULL || node_b == NULL) + return node_a == node_b; + bool ret_val = true; + ret_val = ret_val && (node_a->GetTitle() == node_b->GetTitle()); + ret_val = ret_val && (node_a->is_folder() == node_b->is_folder()); + ret_val = ret_val && (node_a->GetURL() == node_b->GetURL()); + ret_val = ret_val && (node_a->GetParent()->IndexOfChild(node_a) == + node_b->GetParent()->IndexOfChild(node_b)); + return ret_val; } // static -void BookmarkModelVerifier::ExpectModelsMatchIncludingFavicon( - BookmarkModel* expected, BookmarkModel* actual, bool compare_favicon) { - TreeNodeIterator<const BookmarkNode> e_iterator(expected->root_node()); - TreeNodeIterator<const BookmarkNode> a_iterator(actual->root_node()); - - // Pre-order traversal of each model, comparing at each step. - while (e_iterator.has_next()) { - const BookmarkNode* e_node = e_iterator.Next(); - ASSERT_TRUE(a_iterator.has_next()); - const BookmarkNode* a_node = a_iterator.Next(); - ExpectBookmarkInfoMatch(e_node, a_node); - // Get Favicon and compare if compare_favicon flag is true. - if (compare_favicon) { - const SkBitmap& e_node_favicon = expected->GetFavIcon(e_node); - const SkBitmap& a_node_favicon = actual->GetFavIcon(a_node); - EXPECT_GT(e_node_favicon.getSize(), (size_t) 0); - EXPECT_EQ(e_node_favicon.getSize(), a_node_favicon.getSize()); - EXPECT_EQ(e_node_favicon.width(), a_node_favicon.width()); - EXPECT_EQ(e_node_favicon.height(), a_node_favicon.height()); - SkAutoLockPixels bitmap_lock_e(e_node_favicon); - SkAutoLockPixels bitmap_lock_a(a_node_favicon); - void* e_node_pixel_addr = e_node_favicon.getPixels(); - ASSERT_TRUE(e_node_pixel_addr); - void* a_node_pixel_addr = a_node_favicon.getPixels(); - ASSERT_TRUE(a_node_pixel_addr); - EXPECT_EQ(memcmp(e_node_pixel_addr, a_node_pixel_addr, - e_node_favicon.getSize()), 0); +bool BookmarkModelVerifier::ModelsMatch(BookmarkModel* model_a, + BookmarkModel* model_b, + bool compare_favicons) { + bool ret_val = true; + TreeNodeIterator<const BookmarkNode> iterator_a(model_a->root_node()); + TreeNodeIterator<const BookmarkNode> iterator_b(model_b->root_node()); + while (iterator_a.has_next()) { + const BookmarkNode* node_a = iterator_a.Next(); + EXPECT_TRUE(iterator_b.has_next()); + const BookmarkNode* node_b = iterator_b.Next(); + ret_val = ret_val && NodesMatch(node_a, node_b); + if (compare_favicons) { + const SkBitmap& bitmap_a = model_a->GetFavIcon(node_a); + const SkBitmap& bitmap_b = model_b->GetFavIcon(node_b); + ret_val = ret_val && FaviconsMatch(bitmap_a, bitmap_b); } } - ASSERT_FALSE(a_iterator.has_next()); + ret_val = ret_val && (!iterator_b.has_next()); + return ret_val; } -void BookmarkModelVerifier::VerifyNoDuplicates(BookmarkModel* model) { +bool BookmarkModelVerifier::FaviconsMatch(const SkBitmap& bitmap_a, + const SkBitmap& bitmap_b) { + if ((bitmap_a.getSize() == (size_t) 0) || + (bitmap_a.getSize() != bitmap_b.getSize()) || + (bitmap_a.width() != bitmap_b.width()) || + (bitmap_a.height() != bitmap_b.height())) + return false; + SkAutoLockPixels bitmap_lock_a(bitmap_a); + SkAutoLockPixels bitmap_lock_b(bitmap_b); + void* node_pixel_addr_a = bitmap_a.getPixels(); + EXPECT_TRUE(node_pixel_addr_a); + void* node_pixel_addr_b = bitmap_b.getPixels(); + EXPECT_TRUE(node_pixel_addr_b); + return (memcmp(node_pixel_addr_a, + node_pixel_addr_b, + bitmap_a.getSize()) == 0); +} + +bool BookmarkModelVerifier::ContainsDuplicateBookmarks(BookmarkModel* model) { TreeNodeIterator<const BookmarkNode> iterator(model->root_node()); - // Pre-order traversal of model tree, looking for duplicate node at - // each step. while (iterator.has_next()) { const BookmarkNode* node = iterator.Next(); - std::vector<const BookmarkNode*> nodes; if (node->type() != BookmarkNode::URL) continue; - // Get nodes with same URL. + std::vector<const BookmarkNode*> nodes; model->GetNodesByURL(node->GetURL(), &nodes); EXPECT_TRUE(nodes.size() >= 1); - for (std::vector<const BookmarkNode*>::const_iterator i = nodes.begin(), - e = nodes.end(); i != e; i++) { - // Skip if it's same node. - int64 id = node->id(); - if (id == (*i)->id()) { - continue; - } else { - // Make sure title are not same. - EXPECT_NE(node->GetTitle(), (*i)->GetTitle()); + for (std::vector<const BookmarkNode*>::const_iterator it = nodes.begin(); + it != nodes.end(); ++it) { + if (node->id() != (*it)->id() && + node->GetParent() == (*it)->GetParent() && + node->GetTitle() == (*it)->GetTitle()){ + return true; } } - } // end of while + } + return false; } void BookmarkModelVerifier::FindNodeInVerifier(BookmarkModel* foreign_model, @@ -114,7 +101,7 @@ void BookmarkModelVerifier::FindNodeInVerifier(BookmarkModel* foreign_model, } // Swing over to the other tree. - walker = model_->root_node(); + walker = verifier_model_->root_node(); // Climb down. while (!path.empty()) { @@ -124,119 +111,100 @@ void BookmarkModelVerifier::FindNodeInVerifier(BookmarkModel* foreign_model, path.pop(); } - ExpectBookmarkInfoMatch(foreign_node, walker); + ASSERT_TRUE(NodesMatch(foreign_node, walker)); *result = walker; } const BookmarkNode* BookmarkModelVerifier::AddGroup(BookmarkModel* model, - const BookmarkNode* parent, int index, const wstring& title) { - const BookmarkNode* v_parent = NULL; - FindNodeInVerifier(model, parent, &v_parent); - const BookmarkNode* result = model->AddGroup(parent, index, - WideToUTF16Hack(title)); + const BookmarkNode* parent, int index, const string16& title) { + const BookmarkNode* result = model->AddGroup(parent, index, title); EXPECT_TRUE(result); if (!result) return NULL; - const BookmarkNode* v_node = model_->AddGroup(v_parent, index, - WideToUTF16Hack(title)); - EXPECT_TRUE(v_node); - if (!v_node) - return NULL; - ExpectBookmarkInfoMatch(v_node, result); - return result; -} - -const BookmarkNode* BookmarkModelVerifier::AddNonEmptyGroup( - BookmarkModel* model, const BookmarkNode* parent, int index, - const wstring& title, int children_count) { - const BookmarkNode* bm_folder = AddGroup(model, parent, index, title); - EXPECT_TRUE(bm_folder); - if (!bm_folder) - return NULL; - for (int child_index = 0; child_index < children_count; child_index++) { - int random_int = base::RandInt(1, 100); - // To create randomness in order, 60% of time add bookmarks - if (random_int > 40) { - wstring child_bm_title(UTF16ToWideHack(bm_folder->GetTitle())); - child_bm_title.append(L"-ChildBM"); - child_bm_title.append(UTF8ToWide(base::IntToString(index))); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* child_nofavicon_bm = - AddURL(model, bm_folder, child_index, child_bm_title, GURL(url)); - EXPECT_TRUE(child_nofavicon_bm != NULL); - } else { - // Remaining % of time - Add Bookmark folders - wstring child_bmfolder_title(UTF16ToWideHack(bm_folder->GetTitle())); - child_bmfolder_title.append(L"-ChildBMFolder"); - child_bmfolder_title.append(UTF8ToWide(base::IntToString(index))); - const BookmarkNode* child_bm_folder = - AddGroup(model, bm_folder, child_index, child_bmfolder_title); - EXPECT_TRUE(child_bm_folder != NULL); - } + if (use_verifier_model_) { + const BookmarkNode* v_parent = NULL; + FindNodeInVerifier(model, parent, &v_parent); + const BookmarkNode* v_node = verifier_model_->AddGroup( + v_parent, index, title); + EXPECT_TRUE(v_node); + if (!v_node) + return NULL; + EXPECT_TRUE(NodesMatch(v_node, result)); } - return bm_folder; + return result; } const BookmarkNode* BookmarkModelVerifier::AddURL(BookmarkModel* model, - const BookmarkNode* parent, int index, const wstring& title, - const GURL& url) { - const BookmarkNode* v_parent = NULL; - FindNodeInVerifier(model, parent, &v_parent); - const BookmarkNode* result = model->AddURL(parent, index, - WideToUTF16Hack(title), url); + const BookmarkNode* parent, + int index, + const string16& title, + const GURL& url) { + const BookmarkNode* result = model->AddURL(parent, index, title, url); EXPECT_TRUE(result); if (!result) return NULL; - const BookmarkNode* v_node = model_->AddURL(v_parent, index, - WideToUTF16Hack(title), url); - EXPECT_TRUE(v_node); - if (!v_node) - return NULL; - ExpectBookmarkInfoMatch(v_node, result); + if (use_verifier_model_) { + const BookmarkNode* v_parent = NULL; + FindNodeInVerifier(model, parent, &v_parent); + const BookmarkNode* v_node = + verifier_model_->AddURL(v_parent, index, title, url); + EXPECT_TRUE(v_node); + if (!v_node) + return NULL; + EXPECT_TRUE(NodesMatch(v_node, result)); + } return result; } void BookmarkModelVerifier::SetTitle(BookmarkModel* model, const BookmarkNode* node, - const wstring& title) { - const BookmarkNode* v_node = NULL; - FindNodeInVerifier(model, node, &v_node); - model->SetTitle(node, WideToUTF16Hack(title)); - model_->SetTitle(v_node, WideToUTF16Hack(title)); + const string16& title) { + if (use_verifier_model_) { + const BookmarkNode* v_node = NULL; + FindNodeInVerifier(model, node, &v_node); + verifier_model_->SetTitle(v_node, title); + } + model->SetTitle(node, title); } -void BookmarkModelVerifier::Move(BookmarkModel* model, const BookmarkNode* node, - const BookmarkNode* new_parent, int index) { - const BookmarkNode* v_new_parent = NULL; - const BookmarkNode* v_node = NULL; - FindNodeInVerifier(model, new_parent, &v_new_parent); - FindNodeInVerifier(model, node, &v_node); +void BookmarkModelVerifier::Move(BookmarkModel* model, + const BookmarkNode* node, + const BookmarkNode* new_parent, + int index) { + if (use_verifier_model_) { + const BookmarkNode* v_new_parent = NULL; + const BookmarkNode* v_node = NULL; + FindNodeInVerifier(model, new_parent, &v_new_parent); + FindNodeInVerifier(model, node, &v_node); + verifier_model_->Move(v_node, v_new_parent, index); + } model->Move(node, new_parent, index); - model_->Move(v_node, v_new_parent, index); } void BookmarkModelVerifier::Remove(BookmarkModel* model, const BookmarkNode* parent, int index) { - const BookmarkNode* v_parent = NULL; - FindNodeInVerifier(model, parent, &v_parent); - ExpectBookmarkInfoMatch(parent->GetChild(index), v_parent->GetChild(index)); + if (use_verifier_model_) { + const BookmarkNode* v_parent = NULL; + FindNodeInVerifier(model, parent, &v_parent); + ASSERT_TRUE(NodesMatch(parent->GetChild(index), v_parent->GetChild(index))); + verifier_model_->Remove(v_parent, index); + } model->Remove(parent, index); - model_->Remove(v_parent, index); } void BookmarkModelVerifier::SortChildren(BookmarkModel* model, const BookmarkNode* parent) { - const BookmarkNode* v_parent = NULL; - FindNodeInVerifier(model, parent, &v_parent); + if (use_verifier_model_) { + const BookmarkNode* v_parent = NULL; + FindNodeInVerifier(model, parent, &v_parent); + verifier_model_->SortChildren(v_parent); + } model->SortChildren(parent); - model_->SortChildren(v_parent); } void BookmarkModelVerifier::ReverseChildOrder(BookmarkModel* model, - const BookmarkNode* parent) { + const BookmarkNode* parent) { int child_count = parent->GetChildCount(); if (child_count <= 0) return; @@ -245,14 +213,16 @@ void BookmarkModelVerifier::ReverseChildOrder(BookmarkModel* model, } const BookmarkNode* BookmarkModelVerifier::SetURL(BookmarkModel* model, - const BookmarkNode* node, - const GURL& new_url) { - const BookmarkNode* v_node = NULL; - FindNodeInVerifier(model, node, &v_node); - const BookmarkNode* result = bookmark_utils::ApplyEditsWithNoGroupChange( + const BookmarkNode* node, + const GURL& new_url) { + if (use_verifier_model_) { + const BookmarkNode* v_node = NULL; + FindNodeInVerifier(model, node, &v_node); + bookmark_utils::ApplyEditsWithNoGroupChange( + verifier_model_, v_node->GetParent(), + BookmarkEditor::EditDetails(v_node), v_node->GetTitle(), new_url); + } + return bookmark_utils::ApplyEditsWithNoGroupChange( model, node->GetParent(), BookmarkEditor::EditDetails(node), node->GetTitle(), new_url); - bookmark_utils::ApplyEditsWithNoGroupChange(model_, v_node->GetParent(), - BookmarkEditor::EditDetails(v_node), v_node->GetTitle(), new_url); - return result; } diff --git a/chrome/test/live_sync/bookmark_model_verifier.h b/chrome/test/live_sync/bookmark_model_verifier.h index 7d7ce5a..a500e16 100644 --- a/chrome/test/live_sync/bookmark_model_verifier.h +++ b/chrome/test/live_sync/bookmark_model_verifier.h @@ -7,107 +7,119 @@ #pragma once #include <string> + +#include "base/compiler_specific.h" #include "chrome/browser/profile.h" #include "googleurl/src/gurl.h" +#include "third_party/skia/include/core/SkBitmap.h" class BookmarkModel; class BookmarkNode; -// A tool to perform bookmark model operations on a model and have -// the changes echoed in a "verifier" model that can be used as an expected -// hierarchy to compare against. -// Note when we refer to the "same" nodes in |model| and |model_| parameters, -// we mean same the canonical bookmark entity, because |model_| is expected -// to be a replica of |model|. +// Helper class that performs operations on a bookmark model and echoes the +// changes in a verifier model that can be used as an expected hierarchy to +// compare against. +// Note: When we refer to the "same" node in |model| and |verifier_model_|, +// we mean the same canonical bookmark entity, because |verifier_model_| is +// expected to be a replica of |model|. class BookmarkModelVerifier { public: + explicit BookmarkModelVerifier(BookmarkModel* model) + : verifier_model_(model), + use_verifier_model_(true) {} + ~BookmarkModelVerifier() {} - // Creates a BookmarkModelVerifier using a BookmarkModel and waits until the - // model has loaded. Caller takes ownership. - static BookmarkModelVerifier* Create(BookmarkModel* model); + // Checks if the hierarchies in |model_a| and |model_b| are equivalent in + // terms of the data model. Compares favicons if |compare_favicons| is true. + // Returns true if they match. + // Note: Some peripheral fields like creation times are allowed to mismatch. + static bool ModelsMatch(BookmarkModel* model_a, + BookmarkModel* model_b, + bool compare_favicons) WARN_UNUSED_RESULT; + + // Same as the above method, but does not check if the favicons match. + static bool ModelsMatch(BookmarkModel* model_a, + BookmarkModel* model_b) WARN_UNUSED_RESULT { + return ModelsMatch(model_a, model_b, false); + } - // Adds the same folder to |model| and |model_|. - // See BookmarkModel::AddGroup for details. - const BookmarkNode* AddGroup(BookmarkModel* model, - const BookmarkNode* parent, - int index, - const std::wstring& title); + // Checks if |model| contains any instances of two bookmarks with the same URL + // under the same parent folder. Returns true if even one instance is found. + static bool ContainsDuplicateBookmarks(BookmarkModel* model); - // Adds the same non-empty folder to |model| and |model_|. - // It also adds specified number of childern (mix of bm and folder). - const BookmarkNode* AddNonEmptyGroup(BookmarkModel* model, - const BookmarkNode* parent, - int index, - const std::wstring& title, - int children_count); + // Checks if the favicon data in |bitmap_a| and |bitmap_b| are equivalent. + // Returns true if they match. + static bool FaviconsMatch(const SkBitmap& bitmap_a, const SkBitmap& bitmap_b); - // Adds the same bookmark to |model| and |model_|. - // See BookmarkModel::AddURL for details. + // Adds the same bookmark to |model| and |verifier_model_|. See + // BookmarkModel::AddURL for details. const BookmarkNode* AddURL(BookmarkModel* model, const BookmarkNode* parent, int index, - const std::wstring& title, + const string16& title, const GURL& url); - // Sets the title of the same node in |model| and |model_|. - // See BookmarkModel::SetTitle for details. - void SetTitle(BookmarkModel* model, const BookmarkNode* node, - const std::wstring& title); + // Adds the same folder to |model| and |verifier_model_|. See + // BookmarkModel::AddGroup for details. + const BookmarkNode* AddGroup(BookmarkModel* model, + const BookmarkNode* parent, + int index, + const string16& title); + + // Sets the title of the same node in |model| and |verifier_model_|. See + // BookmarkModel::SetTitle for details. + void SetTitle(BookmarkModel* model, + const BookmarkNode* node, + const string16& title); - // Moves the same node to the same position in both |model| and |model_|. - // See BookmarkModel::Move for details. + // Moves the same node to the same position in both |model| and + // |verifier_model_|. See BookmarkModel::Move for details. void Move(BookmarkModel* model, const BookmarkNode* node, const BookmarkNode* new_parent, int index); - // Removes the same node in |model| and |model_|. - // See BookmarkModel::Remove for details. + // Removes the same node from |model| and |verifier_model_|. See + // BookmarkModel::Remove for details. void Remove(BookmarkModel* model, const BookmarkNode* parent, int index); - // Sorts children of the same parent node in |model| and |model_|. + // Sorts children of the same parent node in |model| and |verifier_model_|. // See BookmarkModel::SortChildren for details. void SortChildren(BookmarkModel* model, const BookmarkNode* parent); // Reverses the order of children of the same parent node in |model| - // and |model_|. + // and |verifier_model_|. void ReverseChildOrder(BookmarkModel* model, const BookmarkNode* parent); + // Modifies the url contained in |node| to |new_url|. const BookmarkNode* SetURL(BookmarkModel* model, - const BookmarkNode* node, - const GURL& new_url); + const BookmarkNode* node, + const GURL& new_url); - // Asserts that the verifier model and |actual| are equivalent. - void ExpectMatch(BookmarkModel* actual); - - // Asserts that the two hierarchies are equivalent in terms of the data model. - // (e.g some peripheral fields like creation times are allowed to mismatch). - static void ExpectModelsMatch(BookmarkModel* expected, - BookmarkModel* actual) { - ExpectModelsMatchIncludingFavicon(expected, actual, false); - } - - static void ExpectModelsMatchIncludingFavicon(BookmarkModel* expected, - BookmarkModel* actual, - bool compare_favicon); - - static void VerifyNoDuplicates(BookmarkModel* model); - - private: - explicit BookmarkModelVerifier(BookmarkModel* model); void FindNodeInVerifier(BookmarkModel* foreign_model, const BookmarkNode* foreign_node, const BookmarkNode** result); - // Does a deep comparison of BookmarkNode fields between the two parameters, - // and asserts equality. - static void ExpectBookmarkInfoMatch(const BookmarkNode* expected, - const BookmarkNode* actual); + // Does a deep comparison of BookmarkNode fields in |model_a| and |model_b|. + // Returns true if they are all equal. + static bool NodesMatch( + const BookmarkNode* model_a, const BookmarkNode* model_b); + bool use_verifier_model() const { return use_verifier_model_; } + + void set_use_verifier_model(bool use_verifier_model) { + use_verifier_model_ = use_verifier_model; + } + + private: // A pointer to the BookmarkModel object within the verifier_profile_ object // in class LiveSyncTest. All verifications are done against this object. - BookmarkModel* model_; + BookmarkModel* verifier_model_; + + // A flag that indicates whether bookmark operations should also update the + // verifier model or not. + bool use_verifier_model_; DISALLOW_COPY_AND_ASSIGN(BookmarkModelVerifier); }; diff --git a/chrome/test/live_sync/live_bookmarks_sync_test.h b/chrome/test/live_sync/live_bookmarks_sync_test.h index 89c79fd..9e8bfa0 100644 --- a/chrome/test/live_sync/live_bookmarks_sync_test.h +++ b/chrome/test/live_sync/live_bookmarks_sync_test.h @@ -6,12 +6,11 @@ #define CHROME_TEST_LIVE_SYNC_LIVE_BOOKMARKS_SYNC_TEST_H_ #pragma once +#include <string> #include <vector> -#include "chrome/browser/browser.h" -#include "chrome/browser/profile.h" -#include "chrome/browser/sync/profile_sync_service.h" -#include "chrome/test/bookmark_load_observer.h" +#include "base/compiler_specific.h" +#include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/test/live_sync/bookmark_model_verifier.h" #include "chrome/test/live_sync/live_sync_test.h" #include "chrome/test/ui_test_utils.h" @@ -22,52 +21,241 @@ class LiveBookmarksSyncTest : public LiveSyncTest { public: explicit LiveBookmarksSyncTest(TestType test_type) : LiveSyncTest(test_type) {} + virtual ~LiveBookmarksSyncTest() {} - // Sets up sync profiles and clients and initializes the verifier bookmark - // model. - virtual bool SetupClients() { + // Sets up sync profiles and clients and initializes the bookmark verifier. + virtual bool SetupClients() WARN_UNUSED_RESULT { if (!LiveSyncTest::SetupClients()) return false; for (int i = 0; i < num_clients(); ++i) { ui_test_utils::WaitForBookmarkModelToLoad( GetProfile(i)->GetBookmarkModel()); } - verifier_helper_.reset(BookmarkModelVerifier::Create( - GetVerifierBookmarkModel())); - return (verifier_helper_.get() != NULL); + verifier_helper_.reset( + new BookmarkModelVerifier(GetVerifierBookmarkModel())); + ui_test_utils::WaitForBookmarkModelToLoad(verifier()->GetBookmarkModel()); + return true; } - // Used to access the bookmarks within a particular sync profile. - BookmarkModel* GetBookmarkModel(int index) { + // Used to access the bookmark model within a particular sync profile. + BookmarkModel* GetBookmarkModel(int index) WARN_UNUSED_RESULT { return GetProfile(index)->GetBookmarkModel(); } // Used to access the bookmark bar within a particular sync profile. - const BookmarkNode* GetBookmarkBarNode(int index) { + const BookmarkNode* GetBookmarkBarNode(int index) WARN_UNUSED_RESULT { return GetBookmarkModel(index)->GetBookmarkBarNode(); } + // Used to access the "other bookmarks" node within a particular sync profile. + const BookmarkNode* GetOtherNode(int index) WARN_UNUSED_RESULT { + return GetBookmarkModel(index)->other_node(); + } + // Used to access the bookmarks within the verifier sync profile. - BookmarkModel* GetVerifierBookmarkModel() { + BookmarkModel* GetVerifierBookmarkModel() WARN_UNUSED_RESULT { return verifier()->GetBookmarkModel(); } - // Used to access the service object within a particular sync client. - ProfileSyncService* GetService(int index) { - return GetClient(index)->service(); + // After calling this method, changes made to a bookmark model will no longer + // be reflected in the verifier model. + void DisableVerifier() { verifier_helper_->set_use_verifier_model(false); } + + // Adds a URL with address |url| and title |title| to the bookmark bar of + // profile |profile|. Returns a pointer to the node that was added. + const BookmarkNode* AddURL(int profile, + const std::wstring& title, + const GURL& url) WARN_UNUSED_RESULT { + return verifier_helper_->AddURL(GetBookmarkModel(profile), + GetBookmarkBarNode(profile), 0, WideToUTF16(title), url); + } + + // Adds a URL with address |url| and title |title| to the bookmark bar of + // profile |profile| at position |index|. Returns a pointer to the node that + // was added. + const BookmarkNode* AddURL(int profile, + int index, + const std::wstring& title, + const GURL& url) WARN_UNUSED_RESULT { + return verifier_helper_->AddURL(GetBookmarkModel(profile), + GetBookmarkBarNode(profile), index, WideToUTF16(title), url); + } + + // Adds a URL with address |url| and title |title| under the node |parent| of + // profile |profile| at position |index|. Returns a pointer to the node that + // was added. + const BookmarkNode* AddURL(int profile, + const BookmarkNode* parent, + int index, + const std::wstring& title, + const GURL& url) WARN_UNUSED_RESULT { + EXPECT_EQ(GetBookmarkModel(profile)->GetNodeByID(parent->id()), parent); + return verifier_helper_->AddURL(GetBookmarkModel(profile), parent, index, + WideToUTF16(title), url); + } + + // Adds a group named |title| to the bookmark bar of profile |profile|. + // Returns a pointer to the group that was added. + const BookmarkNode* AddGroup(int profile, + const std::wstring& title) WARN_UNUSED_RESULT { + return verifier_helper_->AddGroup(GetBookmarkModel(profile), + GetBookmarkBarNode(profile), 0, WideToUTF16(title)); + } + + // Adds a group named |title| to the bookmark bar of profile |profile| at + // position |index|. Returns a pointer to the group that was added. + const BookmarkNode* AddGroup(int profile, + int index, + const std::wstring& title) WARN_UNUSED_RESULT { + return verifier_helper_->AddGroup(GetBookmarkModel(profile), + GetBookmarkBarNode(profile), index, WideToUTF16(title)); + } + + // Adds a group named |title| to the node |parent| in the bookmark model of + // profile |profile| at position |index|. Returns a pointer to the node that + // was added. + const BookmarkNode* AddGroup(int profile, + const BookmarkNode* parent, + int index, + const std::wstring& title) WARN_UNUSED_RESULT { + if (GetBookmarkModel(profile)->GetNodeByID(parent->id()) != parent) { + LOG(ERROR) << "Node " << parent->GetTitle() << " does not belong to " + << "Profile " << profile; + return NULL; + } + return verifier_helper_->AddGroup( + GetBookmarkModel(profile), parent, index, WideToUTF16(title)); + } + + // Changes the title of the node |node| in the bookmark model of profile + // |profile| to |new_title|. + void SetTitle(int profile, + const BookmarkNode* node, + const std::wstring& new_title) { + ASSERT_EQ(GetBookmarkModel(profile)->GetNodeByID(node->id()), node) + << "Node " << node->GetTitle() << " does not belong to " + << "Profile " << profile; + verifier_helper_->SetTitle( + GetBookmarkModel(profile), node, WideToUTF16(new_title)); + } + + // Changes the url of the node |node| in the bookmark model of profile + // |profile| to |new_url|. Returns a pointer to the node with the changed url. + const BookmarkNode* SetURL(int profile, + const BookmarkNode* node, + const GURL& new_url) WARN_UNUSED_RESULT { + if (GetBookmarkModel(profile)->GetNodeByID(node->id()) != node) { + LOG(ERROR) << "Node " << node->GetTitle() << " does not belong to " + << "Profile " << profile; + return NULL; + } + return verifier_helper_->SetURL(GetBookmarkModel(profile), node, new_url); + } + + // Moves the node |node| in the bookmark model of profile |profile| so it ends + // up under the node |new_parent| at position |index|. + void Move(int profile, + const BookmarkNode* node, + const BookmarkNode* new_parent, + int index) { + ASSERT_EQ(GetBookmarkModel(profile)->GetNodeByID(node->id()), node) + << "Node " << node->GetTitle() << " does not belong to " + << "Profile " << profile;; + verifier_helper_->Move( + GetBookmarkModel(profile), node, new_parent, index); + } + + // Removes the node in the bookmark model of profile |profile| under the node + // |parent| at position |index|. + void Remove(int profile, const BookmarkNode* parent, int index) { + ASSERT_EQ(GetBookmarkModel(profile)->GetNodeByID(parent->id()), parent) + << "Node " << parent->GetTitle() << " does not belong to " + << "Profile " << profile;; + verifier_helper_->Remove(GetBookmarkModel(profile), parent, index); + } + + // Sorts the children of the node |parent| in the bookmark model of profile + // |profile|. + void SortChildren(int profile, const BookmarkNode* parent) { + ASSERT_EQ(GetBookmarkModel(profile)->GetNodeByID(parent->id()), parent) + << "Node " << parent->GetTitle() << " does not belong to " + << "Profile " << profile;; + verifier_helper_->SortChildren(GetBookmarkModel(profile), parent); + } + + // Reverses the order of the children of the node |parent| in the bookmark + // model of profile |profile|. + void ReverseChildOrder(int profile, const BookmarkNode* parent) { + ASSERT_EQ(GetBookmarkModel(profile)->GetNodeByID(parent->id()), parent) + << "Node " << parent->GetTitle() << " does not belong to " + << "Profile " << profile;; + verifier_helper_->ReverseChildOrder(GetBookmarkModel(profile), parent); + } + + // Checks if the bookmark model of profile |profile| matches the verifier + // bookmark model. Returns true if they match. + bool ModelMatchesVerifier(int profile) WARN_UNUSED_RESULT { + if (verifier_helper_->use_verifier_model() == false) { + LOG(ERROR) << "Illegal to call ModelMatchesVerifier() after " + << "DisableVerifier(). Use ModelsMatch() instead."; + return false; + } + return BookmarkModelVerifier::ModelsMatch( + GetVerifierBookmarkModel(), GetBookmarkModel(profile)); + } + + // Checks if the bookmark models of all sync profiles match the verifier + // bookmark model. Returns true if they match. + bool AllModelsMatchVerifier() WARN_UNUSED_RESULT { + if (verifier_helper_->use_verifier_model() == false) { + LOG(ERROR) << "Illegal to call AllModelsMatchVerifier() after " + << "DisableVerifier(). Use AllModelsMatch() instead."; + return false; + } + for (int i = 0; i < num_clients(); ++i) { + if (!ModelMatchesVerifier(i)) { + LOG(ERROR) << "Model " << i << " does not match the verifier."; + return false; + } + } + return true; + } + + // Checks if the bookmark models of |profile_a| and |profile_b| match each + // other. Returns true if they match. + bool ModelsMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT { + return BookmarkModelVerifier::ModelsMatch( + GetBookmarkModel(profile_a), GetBookmarkModel(profile_b)); + } + + // Checks if the bookmark models of all sync profiles match each other. Does + // not compare them with the verifier bookmark model. Returns true if they + // match. + bool AllModelsMatch() WARN_UNUSED_RESULT { + for (int i = 1; i < num_clients(); ++i) { + if (!ModelsMatch(0, i)) { + LOG(ERROR) << "Model " << i << " does not match Model 0."; + return false; + } + } + return true; } - // Used to access the BookmarkModelVerifier helper object. - BookmarkModelVerifier* verifier_helper() { - return verifier_helper_.get(); + // Checks if the bookmark model of profile |profile| contains any instances of + // two bookmarks with the same URL under the same parent folder. Returns true + // if even one instance is found. + bool ContainsDuplicateBookmarks(int profile) { + return BookmarkModelVerifier::ContainsDuplicateBookmarks( + GetBookmarkModel(profile)); } - // Helper to get a handle on a bookmark in |m| when the url is known to be - // unique. - static const BookmarkNode* GetByUniqueURL(BookmarkModel* m, const GURL& url) { + // Gets the node in the bookmark model of profile |profile| that has the url + // |url|. Note: Only one instance of |url| is assumed to be present. + const BookmarkNode* GetUniqueNodeByURL(int profile, + const GURL& url) WARN_UNUSED_RESULT { std::vector<const BookmarkNode*> nodes; - m->GetNodesByURL(url, &nodes); + GetBookmarkModel(profile)->GetNodesByURL(url, &nodes); EXPECT_EQ(1U, nodes.size()); if (nodes.empty()) return NULL; diff --git a/chrome/test/live_sync/live_sync_test.cc b/chrome/test/live_sync/live_sync_test.cc index 0122061..b8420c2 100644 --- a/chrome/test/live_sync/live_sync_test.cc +++ b/chrome/test/live_sync/live_sync_test.cc @@ -387,6 +387,10 @@ void LiveSyncTest::DisableNetwork(Profile* profile) { net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); } +bool LiveSyncTest::AwaitQuiescence() { + return ProfileSyncServiceTestHarness::AwaitQuiescence(clients()); +} + void LiveSyncTest::SetProxyConfig(URLRequestContextGetter* context_getter, const net::ProxyConfig& proxy_config) { base::WaitableEvent done(false, false); diff --git a/chrome/test/live_sync/live_sync_test.h b/chrome/test/live_sync/live_sync_test.h index 3a1ccbc..a7ebe79 100644 --- a/chrome/test/live_sync/live_sync_test.h +++ b/chrome/test/live_sync/live_sync_test.h @@ -93,37 +93,41 @@ class LiveSyncTest : public InProcessBrowserTest { virtual void SetUpCommandLine(CommandLine* command_line) {} // Used to get the number of sync clients used by a test. - int num_clients() { return num_clients_; } + int num_clients() WARN_UNUSED_RESULT { return num_clients_; } // Returns a pointer to a particular sync profile. Callee owns the object // and manages its lifetime. - Profile* GetProfile(int index); + Profile* GetProfile(int index) WARN_UNUSED_RESULT; // Returns a pointer to a particular sync client. Callee owns the object // and manages its lifetime. - ProfileSyncServiceTestHarness* GetClient(int index); + ProfileSyncServiceTestHarness* GetClient(int index) WARN_UNUSED_RESULT; // Returns a reference to the collection of sync clients. Callee owns the // object and manages its lifetime. - std::vector<ProfileSyncServiceTestHarness*>& clients() { + std::vector<ProfileSyncServiceTestHarness*>& clients() WARN_UNUSED_RESULT { return clients_.get(); } // Returns a pointer to the sync profile that is used to verify changes to // individual sync profiles. Callee owns the object and manages its lifetime. - Profile* verifier(); + Profile* verifier() WARN_UNUSED_RESULT; // Initializes sync clients and profiles but does not sync any of them. - virtual bool SetupClients(); + virtual bool SetupClients() WARN_UNUSED_RESULT; // Initializes sync clients and profiles if required and syncs each of them. - virtual bool SetupSync(); + virtual bool SetupSync() WARN_UNUSED_RESULT; + + // Enable outgoing network connections for the given profile. + virtual void EnableNetwork(Profile* profile); // Disable outgoing network connections for the given profile. virtual void DisableNetwork(Profile* profile); - // Enable outgoing network connections for the given profile. - virtual void EnableNetwork(Profile* profile); + // Blocks until all sync clients have completed their mutual sync cycles. + // Returns true if a quiescent state was successfully reached. + bool AwaitQuiescence(); protected: // InProcessBrowserTest override. Destroys all the sync clients and sync diff --git a/chrome/test/live_sync/many_client_live_bookmarks_sync_test.cc b/chrome/test/live_sync/many_client_live_bookmarks_sync_test.cc index 2736537..94b5b16 100644 --- a/chrome/test/live_sync/many_client_live_bookmarks_sync_test.cc +++ b/chrome/test/live_sync/many_client_live_bookmarks_sync_test.cc @@ -2,17 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/test/live_sync/live_bookmarks_sync_test.h" IN_PROC_BROWSER_TEST_F(ManyClientLiveBookmarksSyncTest, Sanity) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - v->AddURL(GetBookmarkModel(0), GetBookmarkBarNode(0), 0, L"Google URL", - GURL("http://www.google.com/")); - GetClient(0)->AwaitGroupSyncCycleCompletion(clients()); - - for (int i = 0; i < num_clients(); ++i) { - v->ExpectMatch(GetBookmarkModel(i)); - } + ASSERT_TRUE(AddURL(0, L"Google URL", GURL("http://www.google.com/")) != NULL); + ASSERT_TRUE(GetClient(0)->AwaitGroupSyncCycleCompletion(clients())); + ASSERT_TRUE(AllModelsMatch()); } diff --git a/chrome/test/live_sync/many_client_live_passwords_sync_test.cc b/chrome/test/live_sync/many_client_live_passwords_sync_test.cc index b279883..d17cd77 100644 --- a/chrome/test/live_sync/many_client_live_passwords_sync_test.cc +++ b/chrome/test/live_sync/many_client_live_passwords_sync_test.cc @@ -18,16 +18,16 @@ IN_PROC_BROWSER_TEST_F(ManyClientLivePasswordsSyncTest, Sanity) { AddLogin(GetVerififerPasswordStore(), form); AddLogin(GetPasswordStore(0), form); - EXPECT_TRUE(GetClient(0)->AwaitGroupSyncCycleCompletion(clients())); + ASSERT_TRUE(GetClient(0)->AwaitGroupSyncCycleCompletion(clients())); std::vector<PasswordForm> expected; GetLogins(GetVerififerPasswordStore(), form, expected); - EXPECT_EQ(1U, expected.size()); + ASSERT_EQ(1U, expected.size()); for (int i = 0; i < num_clients(); ++i) { std::vector<PasswordForm> actual; GetLogins(GetPasswordStore(i), form, actual); - EXPECT_TRUE(ContainsSamePasswordForms(expected, actual)); + ASSERT_TRUE(ContainsSamePasswordForms(expected, actual)); } } diff --git a/chrome/test/live_sync/many_client_live_preferences_sync_test.cc b/chrome/test/live_sync/many_client_live_preferences_sync_test.cc index 1b28f39..83880b8d 100644 --- a/chrome/test/live_sync/many_client_live_preferences_sync_test.cc +++ b/chrome/test/live_sync/many_client_live_preferences_sync_test.cc @@ -15,7 +15,7 @@ IN_PROC_BROWSER_TEST_F(ManyClientLivePreferencesSyncTest, Sanity) { GetClient(0)->AwaitGroupSyncCycleCompletion(clients()); for (int i = 0; i < num_clients(); ++i) { - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage), GetPrefs(i)->GetBoolean(prefs::kHomePageIsNewTabPage)); } } diff --git a/chrome/test/live_sync/multiple_client_live_bookmarks_sync_test.cc b/chrome/test/live_sync/multiple_client_live_bookmarks_sync_test.cc index 5a570dd..a65e7ec 100644 --- a/chrome/test/live_sync/multiple_client_live_bookmarks_sync_test.cc +++ b/chrome/test/live_sync/multiple_client_live_bookmarks_sync_test.cc @@ -3,20 +3,15 @@ // found in the LICENSE file. #include "base/string_util.h" -#include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/test/live_sync/live_bookmarks_sync_test.h" IN_PROC_BROWSER_TEST_F(MultipleClientLiveBookmarksSyncTest, Sanity) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); + DisableVerifier(); for (int i = 0; i < num_clients(); ++i) { - v->AddURL(GetBookmarkModel(i), GetBookmarkBarNode(i), 0, - StringPrintf(L"Google URL %d", i), - GURL(StringPrintf("http://www.google.com/%d", i))); - } - ProfileSyncServiceTestHarness::AwaitQuiescence(clients()); - for (int i = 1; i < num_clients(); ++i) { - BookmarkModelVerifier::ExpectModelsMatch(GetBookmarkModel(0), - GetBookmarkModel(i)); + ASSERT_TRUE(AddURL(i, StringPrintf(L"Google URL %d", i), + GURL(StringPrintf("http://www.google.com/%d", i))) != NULL); } + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllModelsMatch()); } diff --git a/chrome/test/live_sync/multiple_client_live_passwords_sync_test.cc b/chrome/test/live_sync/multiple_client_live_passwords_sync_test.cc index c277446..8c08249 100644 --- a/chrome/test/live_sync/multiple_client_live_passwords_sync_test.cc +++ b/chrome/test/live_sync/multiple_client_live_passwords_sync_test.cc @@ -20,17 +20,17 @@ IN_PROC_BROWSER_TEST_F(MultipleClientLivePasswordsSyncTest, Sanity) { AddLogin(GetPasswordStore(i), form); } - EXPECT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); + ASSERT_TRUE(AwaitQuiescence()); PasswordForm form; // Don't set any fields, so that all logins match. std::vector<PasswordForm> expected; GetLogins(GetPasswordStore(0), form, expected); - EXPECT_EQ((size_t) num_clients(), expected.size()); + ASSERT_EQ((size_t) num_clients(), expected.size()); for (int i = 1; i < num_clients(); ++i) { std::vector<PasswordForm> actual; GetLogins(GetPasswordStore(i), form, actual); - EXPECT_TRUE(ContainsSamePasswordForms(expected, actual)); + ASSERT_TRUE(ContainsSamePasswordForms(expected, actual)); } } diff --git a/chrome/test/live_sync/multiple_client_live_preferences_sync_test.cc b/chrome/test/live_sync/multiple_client_live_preferences_sync_test.cc index c7a0ad9..2fafae2 100644 --- a/chrome/test/live_sync/multiple_client_live_preferences_sync_test.cc +++ b/chrome/test/live_sync/multiple_client_live_preferences_sync_test.cc @@ -23,7 +23,7 @@ IN_PROC_BROWSER_TEST_F(MultipleClientLivePreferencesSyncTest, Sanity) { GetClient(i)->AwaitGroupSyncCycleCompletion(clients()); } for (int i = 1; i < num_clients(); ++i) { - EXPECT_TRUE(GetPrefs(0)->GetMutableList(prefs::kURLsToRestoreOnStartup)-> + ASSERT_TRUE(GetPrefs(0)->GetMutableList(prefs::kURLsToRestoreOnStartup)-> Equals(GetPrefs(i)->GetMutableList(prefs::kURLsToRestoreOnStartup))); } } diff --git a/chrome/test/live_sync/single_client_live_bookmarks_sync_test.cc b/chrome/test/live_sync/single_client_live_bookmarks_sync_test.cc index 702d56b..416719a 100644 --- a/chrome/test/live_sync/single_client_live_bookmarks_sync_test.cc +++ b/chrome/test/live_sync/single_client_live_bookmarks_sync_test.cc @@ -6,29 +6,23 @@ IN_PROC_BROWSER_TEST_F(SingleClientLiveBookmarksSyncTest, OfflineToOnline) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - DisableNetwork(GetProfile(0)); - - BookmarkModel* bm = GetBookmarkModel(0); - BookmarkModelVerifier* v = verifier_helper(); - const BookmarkNode* top = v->AddGroup(bm, bm->other_node(), 0, L"top"); - v->SetTitle(bm, top, L"title"); - EXPECT_FALSE(GetClient(0)->AwaitSyncCycleCompletion("Offline state change.")); - EXPECT_EQ(ProfileSyncService::Status::OFFLINE_UNSYNCED, + DisableNetwork(GetProfile(0)); + const BookmarkNode* node = AddGroup(0, L"title"); + SetTitle(0, node, L"new_title"); + ASSERT_FALSE(GetClient(0)->AwaitSyncCycleCompletion("Offline state change.")); + ASSERT_EQ(ProfileSyncService::Status::OFFLINE_UNSYNCED, GetClient(0)->GetStatus().summary); EnableNetwork(GetProfile(0)); - EXPECT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Commit changes.")); - EXPECT_EQ(ProfileSyncService::Status::READY, + ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Commit changes.")); + ASSERT_EQ(ProfileSyncService::Status::READY, GetClient(0)->GetStatus().summary); - - v->ExpectMatch(bm); + ASSERT_TRUE(ModelMatchesVerifier(0)); } IN_PROC_BROWSER_TEST_F(SingleClientLiveBookmarksSyncTest, Sanity) { ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; - BookmarkModel* bm = GetBookmarkModel(0); - BookmarkModelVerifier* v = verifier_helper(); // Starting state: // other_node @@ -39,22 +33,22 @@ IN_PROC_BROWSER_TEST_F(SingleClientLiveBookmarksSyncTest, Sanity) { // -> http://www.facebook.com "tier1_a_url2" // -> tier1_b // -> http://www.nhl.com "tier1_b_url0" - const BookmarkNode* top = v->AddGroup(bm, bm->other_node(), 0, L"top"); - const BookmarkNode* tier1_a = v->AddGroup(bm, top, 0, L"tier1_a"); - const BookmarkNode* tier1_b = v->AddGroup(bm, top, 1, L"tier1_b"); - const BookmarkNode* t1au0 = v->AddURL(bm, tier1_a, 0, L"tier1_a_url0", + const BookmarkNode* top = AddGroup(0, GetOtherNode(0), 0, L"top"); + const BookmarkNode* tier1_a = AddGroup(0, top, 0, L"tier1_a"); + const BookmarkNode* tier1_b = AddGroup(0, top, 1, L"tier1_b"); + const BookmarkNode* tier1_a_url0 = AddURL(0, tier1_a, 0, L"tier1_a_url0", GURL("http://mail.google.com")); - const BookmarkNode* t1au1 = v->AddURL(bm, tier1_a, 1, L"tier1_a_url1", + const BookmarkNode* tier1_a_url1 = AddURL(0, tier1_a, 1, L"tier1_a_url1", GURL("http://www.pandora.com")); - const BookmarkNode* t1au2 = v->AddURL( - bm, tier1_a, 2, L"tier1_a_url2", GURL("http://www.facebook.com")); - const BookmarkNode* t1bu0 = v->AddURL(bm, tier1_b, 0, L"tier1_b_url0", + const BookmarkNode* tier1_a_url2 = AddURL(0, tier1_a, 2, L"tier1_a_url2", + GURL("http://www.facebook.com")); + const BookmarkNode* tier1_b_url0 = AddURL(0, tier1_b, 0, L"tier1_b_url0", GURL("http://www.nhl.com")); ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( "Waiting for initial sync completed.")); - v->ExpectMatch(bm); + ASSERT_TRUE(ModelMatchesVerifier(0)); // Ultimately we want to end up with the following model; but this test is // more about the journey than the destination. @@ -78,57 +72,56 @@ IN_PROC_BROWSER_TEST_F(SingleClientLiveBookmarksSyncTest, Sanity) { // -> Wynn (www.wynnlasvegas.com) // -> tier1_a_url0 const BookmarkNode* bar = GetBookmarkBarNode(0); - const BookmarkNode* cnn = - v->AddURL(bm, bar, 0, L"CNN", GURL("http://www.cnn.com")); + const BookmarkNode* cnn = AddURL(0, bar, 0, L"CNN", + GURL("http://www.cnn.com")); ASSERT_TRUE(cnn != NULL); - v->Move(bm, tier1_a, bar, 1); // 1 should be the end at this point. + Move(0, tier1_a, bar, 1); // 1 should be the end at this point. ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Bookmark moved.")); - v->ExpectMatch(bm); + ASSERT_TRUE(ModelMatchesVerifier(0)); - const BookmarkNode* porsche = v->AddURL( - bm, bar, 2, L"Porsche", GURL("http://www.porsche.com")); + const BookmarkNode* porsche = AddURL(0, bar, 2, L"Porsche", + GURL("http://www.porsche.com")); // Rearrange stuff in tier1_a. - EXPECT_EQ(tier1_a, t1au2->GetParent()); - EXPECT_EQ(tier1_a, t1au1->GetParent()); - v->Move(bm, t1au2, tier1_a, 0); - v->Move(bm, t1au1, tier1_a, 2); + ASSERT_EQ(tier1_a, tier1_a_url2->GetParent()); + ASSERT_EQ(tier1_a, tier1_a_url1->GetParent()); + Move(0, tier1_a_url2, tier1_a, 0); + Move(0, tier1_a_url1, tier1_a, 2); ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( "Rearrange stuff in tier1_a")); - v->ExpectMatch(bm); + ASSERT_TRUE(ModelMatchesVerifier(0)); - EXPECT_EQ(1, t1au0->GetParent()->IndexOfChild(t1au0)); - v->Move(bm, t1au0, bar, bar->GetChildCount()); - const BookmarkNode* boa = v->AddURL(bm, bar, bar->GetChildCount(), + ASSERT_EQ(1, tier1_a_url0->GetParent()->IndexOfChild(tier1_a_url0)); + Move(0, tier1_a_url0, bar, bar->GetChildCount()); + const BookmarkNode* boa = AddURL(0, bar, bar->GetChildCount(), L"Bank of America", GURL("https://www.bankofamerica.com")); ASSERT_TRUE(boa != NULL); - v->Move(bm, t1au0, top, top->GetChildCount()); - const BookmarkNode* bubble = v->AddURL(bm, bar, bar->GetChildCount(), + Move(0, tier1_a_url0, top, top->GetChildCount()); + const BookmarkNode* bubble = AddURL(0, bar, bar->GetChildCount(), L"Seattle Bubble", GURL("http://seattlebubble.com")); ASSERT_TRUE(bubble != NULL); - const BookmarkNode* wired = v->AddURL(bm, bar, 2, L"Wired News", - GURL("http://www.wired.com")); - const BookmarkNode* tier2_b = v->AddGroup(bm, tier1_b, 0, L"tier2_b"); - v->Move(bm, t1bu0, tier2_b, 0); - v->Move(bm, porsche, bar, 0); - v->SetTitle(bm, wired, L"News Wired"); - v->SetTitle(bm, porsche, L"ICanHazPorsche?"); + const BookmarkNode* wired = AddURL(0, bar, 2, L"Wired News", + GURL("http://www.wired.com")); + const BookmarkNode* tier2_b = AddGroup(0, tier1_b, 0, L"tier2_b"); + Move(0, tier1_b_url0, tier2_b, 0); + Move(0, porsche, bar, 0); + SetTitle(0, wired, L"News Wired"); + SetTitle(0, porsche, L"ICanHazPorsche?"); ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Change title.")); - v->ExpectMatch(bm); + ASSERT_TRUE(ModelMatchesVerifier(0)); - EXPECT_EQ(t1au0->id(), top->GetChild(top->GetChildCount() - 1)->id()); - v->Remove(bm, top, top->GetChildCount() - 1); - v->Move(bm, wired, tier1_b, 0); - v->Move(bm, porsche, bar, 3); - const BookmarkNode* tier3_b = v->AddGroup(bm, tier2_b, 1, L"tier3_b"); - const BookmarkNode* leafs = v->AddURL( - bm, tier1_a, 0, L"Toronto Maple Leafs", + ASSERT_EQ(tier1_a_url0->id(), top->GetChild(top->GetChildCount() - 1)->id()); + Remove(0, top, top->GetChildCount() - 1); + Move(0, wired, tier1_b, 0); + Move(0, porsche, bar, 3); + const BookmarkNode* tier3_b = AddGroup(0, tier2_b, 1, L"tier3_b"); + const BookmarkNode* leafs = AddURL(0, tier1_a, 0, L"Toronto Maple Leafs", GURL("http://mapleleafs.nhl.com")); - const BookmarkNode* wynn = v->AddURL( - bm, bar, 1, L"Wynn", GURL("http://www.wynnlasvegas.com")); + const BookmarkNode* wynn = AddURL(0, bar, 1, L"Wynn", + GURL("http://www.wynnlasvegas.com")); - v->Move(bm, wynn, tier3_b, 0); - v->Move(bm, leafs, tier3_b, 0); + Move(0, wynn, tier3_b, 0); + Move(0, leafs, tier3_b, 0); ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( "Move after addition of bookmarks.")); - v->ExpectMatch(bm); + ASSERT_TRUE(ModelMatchesVerifier(0)); } diff --git a/chrome/test/live_sync/single_client_live_passwords_sync_test.cc b/chrome/test/live_sync/single_client_live_passwords_sync_test.cc index ea5b183..741fbf8 100644 --- a/chrome/test/live_sync/single_client_live_passwords_sync_test.cc +++ b/chrome/test/live_sync/single_client_live_passwords_sync_test.cc @@ -18,14 +18,14 @@ IN_PROC_BROWSER_TEST_F(SingleClientLivePasswordsSyncTest, Sanity) { AddLogin(GetVerififerPasswordStore(), form); AddLogin(GetPasswordStore(0), form); - EXPECT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( + ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( "Waiting for passwords change.")); std::vector<PasswordForm> expected; GetLogins(GetVerififerPasswordStore(), form, expected); - EXPECT_EQ(1U, expected.size()); + ASSERT_EQ(1U, expected.size()); std::vector<PasswordForm> actual; GetLogins(GetPasswordStore(0), form, actual); - EXPECT_TRUE(ContainsSamePasswordForms(expected, actual)); + ASSERT_TRUE(ContainsSamePasswordForms(expected, actual)); } diff --git a/chrome/test/live_sync/single_client_live_preferences_sync_test.cc b/chrome/test/live_sync/single_client_live_preferences_sync_test.cc index 5756d53..52c9f56 100644 --- a/chrome/test/live_sync/single_client_live_preferences_sync_test.cc +++ b/chrome/test/live_sync/single_client_live_preferences_sync_test.cc @@ -11,9 +11,9 @@ IN_PROC_BROWSER_TEST_F(SingleClientLivePreferencesSyncTest, Sanity) { prefs::kHomePageIsNewTabPage); GetVerifierPrefs()->SetBoolean(prefs::kHomePageIsNewTabPage, new_value); GetPrefs(0)->SetBoolean(prefs::kHomePageIsNewTabPage, new_value); - EXPECT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( + ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( "Waiting for prefs change.")); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage), GetPrefs(0)->GetBoolean(prefs::kHomePageIsNewTabPage)); } diff --git a/chrome/test/live_sync/two_client_live_autofill_sync_test.cc b/chrome/test/live_sync/two_client_live_autofill_sync_test.cc index edda6a4..df81075 100644 --- a/chrome/test/live_sync/two_client_live_autofill_sync_test.cc +++ b/chrome/test/live_sync/two_client_live_autofill_sync_test.cc @@ -17,7 +17,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, Client1HasData) { AddFormFieldsToWebData(GetWebDataService(0), keys); ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); + ASSERT_TRUE(AwaitQuiescence()); AutofillKeys wd1_keys; GetAllAutofillKeys(GetWebDataService(1), &wd1_keys); @@ -30,7 +30,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, Client1HasData) { expected_keys.insert(AutofillKey("name1", "value2")); expected_keys.insert(AutofillKey(WideToUTF16(L"Sigur R\u00F3s"), WideToUTF16(L"\u00C1g\u00E6tis byrjun"))); - EXPECT_EQ(expected_keys, wd1_keys); + ASSERT_EQ(expected_keys, wd1_keys); } IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, BothHaveData) { @@ -48,7 +48,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, BothHaveData) { AddFormFieldsToWebData(GetWebDataService(1), keys2); ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); + ASSERT_TRUE(AwaitQuiescence()); // Note: In this test, name0-value0 and name0-value1 were added in separate // transactions -- one on Client0 and the other on Client1. Therefore, we @@ -62,11 +62,11 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, BothHaveData) { AutofillKeys wd0_keys; GetAllAutofillKeys(GetWebDataService(0), &wd0_keys); - EXPECT_EQ(expected_keys, wd0_keys); + ASSERT_EQ(expected_keys, wd0_keys); AutofillKeys wd1_keys; GetAllAutofillKeys(GetWebDataService(1), &wd1_keys); - EXPECT_EQ(expected_keys, wd1_keys); + ASSERT_EQ(expected_keys, wd1_keys); } IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, Steady) { @@ -76,69 +76,69 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, Steady) { AutofillKeys add_one_key; add_one_key.insert(AutofillKey("name0", "value0")); AddFormFieldsToWebData(GetWebDataService(0), add_one_key); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); AutofillKeys expected_keys; expected_keys.insert(AutofillKey("name0", "value0")); AutofillKeys keys; GetAllAutofillKeys(GetWebDataService(0), &keys); - EXPECT_EQ(expected_keys, keys); + ASSERT_EQ(expected_keys, keys); keys.clear(); GetAllAutofillKeys(GetWebDataService(1), &keys); - EXPECT_EQ(expected_keys, keys); + ASSERT_EQ(expected_keys, keys); // Client1 adds a key. add_one_key.clear(); add_one_key.insert(AutofillKey("name1", "value1")); AddFormFieldsToWebData(GetWebDataService(1), add_one_key); - EXPECT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); + ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); expected_keys.insert(AutofillKey("name1", "value1")); keys.clear(); GetAllAutofillKeys(GetWebDataService(0), &keys); - EXPECT_EQ(expected_keys, keys); + ASSERT_EQ(expected_keys, keys); keys.clear(); GetAllAutofillKeys(GetWebDataService(1), &keys); - EXPECT_EQ(expected_keys, keys); + ASSERT_EQ(expected_keys, keys); // Client0 adds a key with the same name. add_one_key.clear(); add_one_key.insert(AutofillKey("name1", "value2")); AddFormFieldsToWebData(GetWebDataService(0), add_one_key); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); expected_keys.insert(AutofillKey("name1", "value2")); keys.clear(); GetAllAutofillKeys(GetWebDataService(0), &keys); - EXPECT_EQ(expected_keys, keys); + ASSERT_EQ(expected_keys, keys); keys.clear(); GetAllAutofillKeys(GetWebDataService(1), &keys); - EXPECT_EQ(expected_keys, keys); + ASSERT_EQ(expected_keys, keys); // Client1 removes a key. RemoveKeyFromWebData(GetWebDataService(1), AutofillKey("name1", "value1")); - EXPECT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); + ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); expected_keys.erase(AutofillKey("name1", "value1")); keys.clear(); GetAllAutofillKeys(GetWebDataService(0), &keys); - EXPECT_EQ(expected_keys, keys); + ASSERT_EQ(expected_keys, keys); keys.clear(); GetAllAutofillKeys(GetWebDataService(1), &keys); - EXPECT_EQ(expected_keys, keys); + ASSERT_EQ(expected_keys, keys); // Client0 removes the rest. RemoveKeyFromWebData(GetWebDataService(0), AutofillKey("name0", "value0")); RemoveKeyFromWebData(GetWebDataService(0), AutofillKey("name1", "value2")); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); keys.clear(); GetAllAutofillKeys(GetWebDataService(0), &keys); - EXPECT_EQ(0U, keys.size()); + ASSERT_EQ(0U, keys.size()); keys.clear(); GetAllAutofillKeys(GetWebDataService(1), &keys); - EXPECT_EQ(0U, keys.size()); + ASSERT_EQ(0U, keys.size()); } IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, ProfileClient1HasData) { @@ -153,12 +153,12 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, ProfileClient1HasData) { AddProfile(GetPersonalDataManager(0), *expected_profiles[1]); ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); + ASSERT_TRUE(AwaitQuiescence()); AutoFillProfile::AdjustInferredLabels(&expected_profiles); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(0)))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(1)))); STLDeleteElements(&expected_profiles); } @@ -181,14 +181,14 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, ConflictLabels) { AddProfile(GetPersonalDataManager(1), *profiles2[0]); ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); + ASSERT_TRUE(AwaitQuiescence()); // Since client1 associates first, client2's profile will // be overwritten by the one stored in the cloud by profile1. AutoFillProfile::AdjustInferredLabels(&profiles1); - EXPECT_TRUE(CompareAutoFillProfiles(profiles1, + ASSERT_TRUE(CompareAutoFillProfiles(profiles1, GetAllAutoFillProfiles(GetPersonalDataManager(0)))); - EXPECT_TRUE(CompareAutoFillProfiles(profiles1, + ASSERT_TRUE(CompareAutoFillProfiles(profiles1, GetAllAutoFillProfiles(GetPersonalDataManager(1)))); STLDeleteElements(&profiles1); STLDeleteElements(&profiles2); @@ -208,7 +208,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, AddProfile(GetPersonalDataManager(0), *expected_profiles[1]); ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); + ASSERT_TRUE(AwaitQuiescence()); // One of the duplicate profiles will have its label renamed to // the first label with "2" appended. @@ -216,9 +216,9 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, expected_profiles[0]->set_label(expected_profiles[1]->Label() + ASCIIToUTF16("2")); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(0)))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(1)))); STLDeleteElements(&expected_profiles); } @@ -231,39 +231,39 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, ProfileSteady) { expected_profiles.push_back(new AutoFillProfile(string16(), 0)); FillProfile(PROFILE_HOMER, expected_profiles[0]); AddProfile(GetPersonalDataManager(0), *expected_profiles[0]); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); AutoFillProfile::AdjustInferredLabels(&expected_profiles); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(0)))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(1)))); // Client1 adds a profile. expected_profiles.push_back(new AutoFillProfile(string16(), 0)); FillProfile(PROFILE_MARION, expected_profiles[1]); AddProfile(GetPersonalDataManager(1), *expected_profiles[1]); - EXPECT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); + ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); AutoFillProfile::AdjustInferredLabels(&expected_profiles); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(0)))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(1)))); // Client0 adds a conflicting profile. expected_profiles.push_back(new AutoFillProfile(string16(), 0)); FillProfile(PROFILE_MARION, expected_profiles[2]); AddProfile(GetPersonalDataManager(0), *expected_profiles[2]); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); // The conflicting profile's label will be made unique. AutoFillProfile::AdjustInferredLabels(&expected_profiles); expected_profiles[2]->set_label(expected_profiles[1]->Label() + ASCIIToUTF16("2")); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(0)))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(1)))); // Client1 removes a profile. @@ -271,11 +271,11 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, ProfileSteady) { delete expected_profiles.front(); expected_profiles.erase(expected_profiles.begin()); RemoveProfile(GetPersonalDataManager(1), label0); - EXPECT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); + ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(0)))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(1)))); // Client0 updates a profile. @@ -285,11 +285,11 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, ProfileSteady) { expected_profiles[0]->Label(), AutoFillType(NAME_FIRST), ASCIIToUTF16("Bart")); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(0)))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(1)))); // Client1 removes everything. @@ -298,11 +298,11 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, ProfileSteady) { STLDeleteElements(&expected_profiles); RemoveProfile(GetPersonalDataManager(1), label1); RemoveProfile(GetPersonalDataManager(1), label2); - EXPECT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); + ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(0)))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(1)))); } @@ -314,12 +314,12 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, AddEmptyProfile) { expected_profiles.push_back(new AutoFillProfile(string16(), 0)); FillProfile(PROFILE_NULL, expected_profiles[0]); AddProfile(GetPersonalDataManager(0), *expected_profiles[0]); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); AutoFillProfile::AdjustInferredLabels(&expected_profiles); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(0)))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(1)))); STLDeleteElements(&expected_profiles); } @@ -332,12 +332,12 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, AddProfile) { expected_profiles.push_back(new AutoFillProfile(string16(), 0)); FillProfile(PROFILE_HOMER, expected_profiles[0]); AddProfile(GetPersonalDataManager(0), *expected_profiles[0]); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); AutoFillProfile::AdjustInferredLabels(&expected_profiles); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(0)))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(1)))); STLDeleteElements(&expected_profiles); } @@ -363,9 +363,9 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, AddMultipleProfiles) { FillProfile(PROFILE_FRASIER, expected_profiles[3]); AddProfile(GetPersonalDataManager(0), *expected_profiles[3]); - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); + ASSERT_TRUE(AwaitQuiescence()); - EXPECT_TRUE(CompareAutoFillProfiles( + ASSERT_TRUE(CompareAutoFillProfiles( GetAllAutoFillProfiles(GetPersonalDataManager(1)), GetAllAutoFillProfiles(GetPersonalDataManager(0)))); STLDeleteElements(&expected_profiles); @@ -381,12 +381,12 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, AddUnicodeProfile) { AddFormFieldsToWebData(GetWebDataService(0), expected_keys); ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); + ASSERT_TRUE(AwaitQuiescence()); AutofillKeys synced_keys; GetAllAutofillKeys(GetWebDataService(1), &synced_keys); - EXPECT_EQ(expected_keys, synced_keys); + ASSERT_EQ(expected_keys, synced_keys); } // TestScribe ID - 425337. @@ -397,23 +397,23 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, DeleteProfile) { expected_profiles.push_back(new AutoFillProfile(string16(), 0)); FillProfile(PROFILE_MARION, expected_profiles[0]); AddProfile(GetPersonalDataManager(0), *expected_profiles[0]); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); AutoFillProfile::AdjustInferredLabels(&expected_profiles); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(0)))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(1)))); string16 label = expected_profiles.front()->Label(); delete expected_profiles.front(); expected_profiles.erase(expected_profiles.begin()); RemoveProfile(GetPersonalDataManager(1), label); - EXPECT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); + ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(0)))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(1)))); } @@ -437,12 +437,12 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, MergeProfiles) { expected_profiles.push_back(new AutoFillProfile(string16(), 0)); FillProfile(PROFILE_FRASIER, expected_profiles[3]); AddProfile(GetPersonalDataManager(1), *expected_profiles[3]); - EXPECT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); + ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); AutoFillProfile::AdjustInferredLabels(&expected_profiles); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(0)))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(1)))); STLDeleteElements(&expected_profiles); } @@ -455,12 +455,12 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, UpdateFields) { expected_profiles.push_back(new AutoFillProfile(string16(), 0)); FillProfile(PROFILE_HOMER, expected_profiles[0]); AddProfile(GetPersonalDataManager(0), *expected_profiles[0]); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); AutoFillProfile::AdjustInferredLabels(&expected_profiles); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(0)))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(1)))); expected_profiles[0]->SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("Lisa")); @@ -470,9 +470,9 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, UpdateFields) { AutoFillType(NAME_FIRST), ASCIIToUTF16("Lisa")); UpdateProfile(GetPersonalDataManager(0), expected_profiles[0]->Label(), AutoFillType(EMAIL_ADDRESS), ASCIIToUTF16("grrrl@TV.com")); - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); + ASSERT_TRUE(AwaitQuiescence()); - EXPECT_TRUE(CompareAutoFillProfiles( + ASSERT_TRUE(CompareAutoFillProfiles( GetAllAutoFillProfiles(GetPersonalDataManager(0)), GetAllAutoFillProfiles(GetPersonalDataManager(1)))); STLDeleteElements(&expected_profiles); @@ -497,12 +497,12 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, UpdateLabel) { AddProfile(GetPersonalDataManager(0), *profiles0[0]); AddProfile(GetPersonalDataManager(1), *profiles1[0]); - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); + ASSERT_TRUE(AwaitQuiescence()); AutoFillProfile::AdjustInferredLabels(&expected_profiles); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(0)))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(1)))); STLDeleteElements(&profiles0); STLDeleteElements(&profiles1); @@ -516,12 +516,12 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, ConflictFields) { expected_profiles.push_back(new AutoFillProfile(string16(), 0)); FillProfile(PROFILE_HOMER, expected_profiles[0]); AddProfile(GetPersonalDataManager(0), *expected_profiles[0]); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); AutoFillProfile::AdjustInferredLabels(&expected_profiles); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(0)))); - EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, + ASSERT_TRUE(CompareAutoFillProfiles(expected_profiles, GetAllAutoFillProfiles(GetPersonalDataManager(1)))); UpdateProfile(GetPersonalDataManager(0), expected_profiles[0]->Label(), @@ -529,9 +529,9 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, ConflictFields) { UpdateProfile(GetPersonalDataManager(1), expected_profiles[0]->Label(), AutoFillType(NAME_FIRST), ASCIIToUTF16("Bart")); - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); + ASSERT_TRUE(AwaitQuiescence()); - EXPECT_TRUE(CompareAutoFillProfiles( + ASSERT_TRUE(CompareAutoFillProfiles( GetAllAutoFillProfiles(GetPersonalDataManager(0)), GetAllAutoFillProfiles(GetPersonalDataManager(1)))); STLDeleteElements(&expected_profiles); diff --git a/chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc b/chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc index e857d25..11e5ed0 100644 --- a/chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc +++ b/chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc @@ -3,2459 +3,1305 @@ // found in the LICENSE file. #include "base/rand_util.h" -#include "base/string16.h" #include "base/stringprintf.h" -#include "base/string_number_conversions.h" -#include "base/utf_string_conversions.h" -#include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/test/live_sync/live_bookmarks_sync_test.h" -using std::string; -using std::wstring; +const std::string kGenericURL = "http://www.host.ext:1234/path/filename"; +const std::wstring kGenericURLTitle = L"URL Title"; +const std::wstring kGenericFolderName = L"Folder Name"; +const std::wstring kGenericSubfolderName = L"Subfolder Name"; +const std::wstring kGenericSubsubfolderName = L"Subsubfolder Name"; -// Some Abbreviations Used: -// F -- BookmarkFolder -// BM -- Bookmark -// L -- Level (Depth of bookmark folder) +static std::string IndexedURL(int i) { + return StringPrintf("http://www.host.ext:1234/path/filename/%d", i); +} + +static std::wstring IndexedURLTitle(int i) { + return StringPrintf(L"URL Title %d", i); +} + +static std::wstring IndexedFolderName(int i) { + return StringPrintf(L"Folder Name %d", i); +} -// Test case Naming Convention: -// SC/MC - SingleClient / MultiClient. -// Suffix Number - Indicates test scribe testcase ID. +static std::wstring IndexedSubfolderName(int i) { + return StringPrintf(L"Subfolder Name %d", i); +} -// TODO(brettw) this file should be converted to string16 and use -// IntToString16 instead. -static std::wstring IntToWStringHack(int val) { - return UTF8ToWide(base::IntToString(val)); +static std::wstring IndexedSubsubfolderName(int i) { + return StringPrintf(L"Subsubfolder Name %d", i); } IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, Sanity) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = GetBookmarkBarNode(0); - const BookmarkNode* bm_bar1 = GetBookmarkBarNode(1); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); GURL google_url("http://www.google.com"); - // Start adding some bookmarks to each model. The scope is to enforce that - // the BookmarkNode*'s are not used after they may be invalidated by sync - // operations that alter the models. - { - const BookmarkNode* google_one = v->AddURL(bm0, bm_bar0, 0, - L"Google", google_url); - ASSERT_TRUE(google_one != NULL); - - // To make this test deterministic, we wait here so there is no race to - // decide which bookmark actually gets position 0. - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - const BookmarkNode* yahoo_two = v->AddURL(bm1, bm_bar1, 0, - L"Yahoo", GURL("http://www.yahoo.com")); - ASSERT_TRUE(yahoo_two != NULL); - } - ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - { - const BookmarkNode* new_folder_one = - v->AddGroup(bm0, bm_bar0, 2, L"New Folder"); - v->Move(bm0, GetByUniqueURL(bm0, google_url), - new_folder_one, 0); - v->SetTitle(bm0, bm_bar0->GetChild(0), L"Yahoo!!"); - const BookmarkNode* cnn_one = v->AddURL(bm0, - bm_bar0, 1, L"CNN", GURL("http://www.cnn.com")); - ASSERT_TRUE(cnn_one != NULL); - } + ASSERT_TRUE(AddURL(0, L"Google", google_url) != NULL); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - { - const BookmarkNode* facebook_two = v->AddURL(bm1, - bm_bar1, 0, L"Facebook", GURL("http://www.facebook.com")); - ASSERT_TRUE(facebook_two != NULL); - } - - // AwaitMutualSyncCycleCompletion blocks the calling object before the - // argument, so because we have made changes from client2 here we need to swap - // the calling order. + ASSERT_TRUE(AddURL(1, L"Yahoo", GURL("http://www.yahoo.com")) != NULL); ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); - v->SortChildren(bm1, bm_bar1); + const BookmarkNode* new_folder = AddGroup(0, 2, L"New Folder"); + Move(0, GetUniqueNodeByURL(0, google_url), new_folder, 0); + SetTitle(0, GetBookmarkBarNode(0)->GetChild(0), L"Yahoo!!"); + ASSERT_TRUE(AddURL(0, GetBookmarkBarNode(0), 1, L"CNN", + GURL("http://www.cnn.com")) != NULL); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); + ASSERT_TRUE(AddURL(1, L"Facebook", GURL("http://www.facebook.com")) != NULL); ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - { - // Do something crazy and modify the same item from both clients!! - const BookmarkNode* google_one = GetByUniqueURL(bm0, google_url); - const BookmarkNode* google_two = GetByUniqueURL(bm1, google_url); - bm0->SetTitle(google_one, ASCIIToUTF16("Google++")); - bm1->SetTitle(google_two, ASCIIToUTF16("Google--")); - } + ASSERT_TRUE(AllModelsMatchVerifier()); - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); + SortChildren(1, GetBookmarkBarNode(1)); + ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); + ASSERT_TRUE(AllModelsMatchVerifier()); - BookmarkModelVerifier::ExpectModelsMatch(bm0, bm1); + DisableVerifier(); + SetTitle(0, GetUniqueNodeByURL(0, google_url), L"Google++"); + SetTitle(1, GetUniqueNodeByURL(1, google_url), L"Google--"); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllModelsMatch()); } -// TODO(timsteele): There are really two tests here, one case where conflict -// resolution causes the URL to be overwritten, and one where we see duplicate -// bookmarks created due to the Remove/Add semantic for "Edit URL" and the race -// between the local edit and server edit. The latter is bug 1956259 and is -// still under investigation, I don't have enough info to write two separate -// tests yet. -IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SimultaneousURLChanges) { +IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, SimultaneousURLChanges) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - const BookmarkNode* bm_bar1 = bm1->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); + GURL initial_url("http://www.google.com"); GURL second_url("http://www.google.com/abc"); GURL third_url("http://www.google.com/def"); - string16 title = ASCIIToUTF16("Google"); - { - const BookmarkNode* google = - v->AddURL(bm0, bm_bar0, 0, UTF16ToWideHack(title), initial_url); - ASSERT_TRUE(google != NULL); - } - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + std::wstring title = L"Google"; - { - const BookmarkNode* google_one = GetByUniqueURL(bm0, initial_url); - const BookmarkNode* google_two = GetByUniqueURL(bm1, initial_url); - bookmark_utils::ApplyEditsWithNoGroupChange(bm0, bm_bar0, - BookmarkEditor::EditDetails(google_one), title, second_url); - bookmark_utils::ApplyEditsWithNoGroupChange(bm1, bm_bar1, - BookmarkEditor::EditDetails(google_two), title, third_url); - } + ASSERT_TRUE(AddURL(0, title, initial_url) != NULL); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); - BookmarkModelVerifier::ExpectModelsMatch(bm0, bm1); + DisableVerifier(); + ASSERT_TRUE( + SetURL(0, GetUniqueNodeByURL(0, initial_url), second_url) != NULL); + ASSERT_TRUE( + SetURL(1, GetUniqueNodeByURL(1, initial_url), third_url) != NULL); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllModelsMatch()); - { - const BookmarkNode* google_one = bm_bar0->GetChild(0); - bm0->SetTitle(google_one, ASCIIToUTF16("Google1")); - } + SetTitle(0, GetBookmarkBarNode(0)->GetChild(0), L"Google1"); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - BookmarkModelVerifier::ExpectModelsMatch(bm0, bm1); + ASSERT_TRUE(AllModelsMatch()); } // Test Scribe ID - 370558. -IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_AddFirstFolder) { +IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, SC_AddFirstFolder) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - { - // Let's add first bookmark folder to client0 - const BookmarkNode* new_folder_one = - v->AddGroup(bm0, bm_bar0, 0, L"TestFolder"); - ASSERT_TRUE(new_folder_one != NULL); - } + ASSERT_TRUE(AllModelsMatchVerifier()); + + ASSERT_TRUE(AddGroup(0, kGenericFolderName) != NULL); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 370559. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_AddFirstBMWithoutFavicon) { + SC_AddFirstBMWithoutFavicon) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's add first bookmark(without favicon) - { - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, bm_bar0, 0, - L"TestBookmark", GURL("http://www.nofaviconurl.com")); - ASSERT_TRUE(nofavicon_bm != NULL); - } + ASSERT_TRUE(AllModelsMatchVerifier()); + + ASSERT_TRUE(AddURL(0, kGenericURLTitle, GURL(kGenericURL)) != NULL); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 370560. -IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_AddNonHTTPBMs) { +IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, SC_AddNonHTTPBMs) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's add few non-http GetBookmarkModel(without favicon) - { - const BookmarkNode* ftp_bm = v->AddURL(bm0, bm_bar0, 0, - L"FTPBookmark", GURL("ftp://ftp.testbookmark.com")); - ASSERT_TRUE(ftp_bm != NULL); - const BookmarkNode* file_bm = v->AddURL(bm0, bm_bar0, 1, - L"FileBookmark", GURL("file:///")); - ASSERT_TRUE(file_bm != NULL); - } + ASSERT_TRUE(AllModelsMatchVerifier()); + + ASSERT_TRUE(AddURL( + 0, L"FTP URL", GURL("ftp://user:password@host:1234/path")) != NULL); + ASSERT_TRUE(AddURL(0, L"File URL", GURL("file://host/path")) != NULL); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 370561. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_AddFirstBMUnderFolder) { + SC_AddFirstBMUnderFolder) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - { - // Let's add first bookmark folder to client1 - const BookmarkNode* new_folder_one = - v->AddGroup(bm0, bm_bar0, 0, L"BM TestFolder"); - // Add first bookmark to newly created folder - const BookmarkNode* test_bm1 = v->AddURL( - bm0, new_folder_one, 0, - L"BM Test", GURL("http://www.bmtest.com")); - ASSERT_TRUE(test_bm1 != NULL); - } + ASSERT_TRUE(AllModelsMatchVerifier()); + const BookmarkNode* folder = AddGroup(0, kGenericFolderName); + ASSERT_TRUE(folder != NULL); + ASSERT_TRUE( + AddURL(0, folder, 0, kGenericURLTitle, GURL(kGenericURL)) != NULL); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 370562. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_AddSeveralBMsUnderBMBarAndOtherBM) { + SC_AddSeveralBMsUnderBMBarAndOtherBM) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - const BookmarkNode* bm_other0 = bm0->other_node(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - // Let's add some GetBookmarkModel(without favicon) - for (int index = 0; index < 20; index++) { - wstring title(L"TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = - v->AddURL(bm0, bm_bar0, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); - } - for (int index = 0; index < 10; index++) { - wstring title(L"TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = - v->AddURL(bm0, bm_other0, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + ASSERT_TRUE(AllModelsMatchVerifier()); + + for (int i = 0; i < 20; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, i, title, url) != NULL); + ASSERT_TRUE(AddURL(0, GetOtherNode(0), i, title, url) != NULL); } ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 370563. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_AddSeveralBMsAndFolders) { + SC_AddSeveralBMsAndFolders) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - const BookmarkNode* bm_other0 = bm0->other_node(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - // Let's add some GetBookmarkModel(without favicon) - for (int index = 0; index < 15; index++) { - int random_int = base::RandInt(1, 100); - // To create randomness in order, 40% of time add bookmarks - if (random_int > 60) { - wstring title(L"BB - TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = - v->AddURL(bm0, bm_bar0, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + ASSERT_TRUE(AllModelsMatchVerifier()); + + for (int i = 0; i < 15; ++i) { + if (base::RandDouble() > 0.6) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, i, title, url) != NULL); } else { - // Remaining % of time - Add Bookmark folders - wstring title(L"BB - TestBMFolder"); - title.append(IntToWStringHack(index)); - const BookmarkNode* bm_folder = v->AddGroup(bm0, bm_bar0, - index, title); - int random_int2 = base::RandInt(1, 100); - // 60% of time we will add bookmarks to added folder - if (random_int2 > 40) { - for (int index = 0; index < 20; index++) { - wstring child_title(title); - child_title.append(L" - ChildTestBM"); - child_title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, - bm_folder, index, child_title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); - } + std::wstring title = IndexedFolderName(i); + const BookmarkNode* folder = AddGroup(0, i, title); + ASSERT_TRUE(folder != NULL); + if (base::RandDouble() > 0.4) { + for (int i = 0; i < 20; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); } + } } } - LOG(INFO) << "Adding several bookmarks under other bookmarks"; - for (int index = 0; index < 10; index++) { - wstring title(L"Other - TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl-other"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = - v->AddURL(bm0, bm_other0, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + for (int i = 0; i < 10; i++) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, GetOtherNode(0), i, title, url) != NULL); } ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 370641. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_DuplicateBMWithDifferentURLSameName) { + SC_DuplicateBMWithDifferentURLSameName) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's add two bookmarks with different URL but same name - { - const BookmarkNode* google_bm = v->AddURL(bm0, bm_bar0, 0, - L"Google", GURL("http://www.google.com")); - ASSERT_TRUE(google_bm != NULL); - const BookmarkNode* google_news_bm = v->AddURL(bm0, bm_bar0, 1, - L"Google", GURL("http://www.google.com/news")); - ASSERT_TRUE(google_news_bm != NULL); - } + ASSERT_TRUE(AllModelsMatchVerifier()); + + GURL url0 = GURL(IndexedURL(0)); + GURL url1 = GURL(IndexedURL(1)); + ASSERT_TRUE(AddURL(0, kGenericURLTitle, url0) != NULL); + ASSERT_TRUE(AddURL(0, kGenericURLTitle, url1) != NULL); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } -// Test Scribe ID - 371817. +// Test Scribe ID - 370639 - Add bookmarks with different name and same URL. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_RenameBMName) { + SC_DuplicateBookmarksWithSameURL) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - // Add first bookmark - const BookmarkNode* test_bm1 = v->AddURL( - bm0, bm_bar0, 0, L"Test BM", GURL("http://www.bmtest.com")); + ASSERT_TRUE(AllModelsMatchVerifier()); + std::wstring title0 = IndexedURLTitle(0); + std::wstring title1 = IndexedURLTitle(1); + ASSERT_TRUE(AddURL(0, title0, GURL(kGenericURL)) != NULL); + ASSERT_TRUE(AddURL(0, title1, GURL(kGenericURL)) != NULL); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); +} - { - // Rename recently added BM - v->SetTitle(bm0, test_bm1, L"New Test BM"); - } +// Test Scribe ID - 371817. +IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, SC_RenameBMName) { + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; + ASSERT_TRUE(AllModelsMatchVerifier()); + + std::wstring title = IndexedURLTitle(1); + const BookmarkNode* bookmark = AddURL(0, title, GURL(kGenericURL)); + ASSERT_TRUE(bookmark != NULL); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); + std::wstring new_title = IndexedURLTitle(2); + SetTitle(0, bookmark, new_title); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 371822. +IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, SC_RenameBMURL) { + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; + ASSERT_TRUE(AllModelsMatchVerifier()); + + GURL url = GURL(IndexedURL(1)); + const BookmarkNode* bookmark = AddURL(0, kGenericURLTitle, url); + ASSERT_TRUE(bookmark != NULL); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); + + GURL new_url = GURL(IndexedURL(2)); + ASSERT_TRUE(SetURL(0, bookmark, new_url) != NULL); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); +} + + +// Test Scribe ID - 371818 - Renaming the same bookmark name twice. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_RenameBMURL) { + SC_TwiceRenamingBookmarkName) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); + ASSERT_TRUE(AllModelsMatchVerifier()); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - // Let's add first bookmark(without favicon) - const BookmarkNode* nofavicon_bm = - v->AddURL(bm0, bm_bar0, 0, L"Google", - GURL("http://www.google.com")); + std::wstring title = IndexedURLTitle(1); + const BookmarkNode* bookmark = AddURL(0, title, GURL(kGenericURL)); + ASSERT_TRUE(bookmark != NULL); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); + std::wstring new_title = IndexedURLTitle(2); + SetTitle(0, bookmark, new_title); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); - // Let's rename/change URL - nofavicon_bm = v->SetURL(bm0, nofavicon_bm, - GURL("http://www.cnn.com")); - // Wait for changes to sync and then verify + SetTitle(0, bookmark, title); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } -// Test Scribe ID - 371824. +// Test Scribe ID - 371823 - Renaming the same bookmark URL twice. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_RenameBMFolder) { + SC_TwiceRenamingBookmarkURL) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's add first bookmark folder to client1 - const BookmarkNode* new_folder_one = v->AddGroup(bm0, bm_bar0, 0, - L"TestBMFolder"); + ASSERT_TRUE(AllModelsMatchVerifier()); + GURL url = GURL(IndexedURL(1)); + const BookmarkNode* bookmark = AddURL(0, kGenericURLTitle, url); + ASSERT_TRUE(bookmark != NULL); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); - // Rename recently added Bookmark folder - v->SetTitle(bm0, new_folder_one, L"New TestBMFolder"); + GURL new_url = GURL(IndexedURL(2)); + ASSERT_TRUE(SetURL(0, bookmark, new_url) != NULL); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); + ASSERT_TRUE(SetURL(0, bookmark, url) != NULL); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } -// Test Scribe ID - 371825. -IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_RenameEmptyBMFolder) { +// Test Scribe ID - 371824. +IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, SC_RenameBMFolder) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); + ASSERT_TRUE(AllModelsMatchVerifier()); + + std::wstring title = IndexedFolderName(1); + const BookmarkNode* folder = AddGroup(0, title); + ASSERT_TRUE( + AddURL(0, folder, 0, kGenericURLTitle, GURL(kGenericURL)) != NULL); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + std::wstring new_title = IndexedFolderName(2); + SetTitle(0, folder, new_title); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); +} - // Let's add first bookmark folder to client1 - const BookmarkNode* bm_folder_one = - v->AddGroup(bm0, bm_bar0, 0, L"TestFolder"); +// Test Scribe ID - 371825. +IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, SC_RenameEmptyBMFolder) { + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; + ASSERT_TRUE(AllModelsMatchVerifier()); + std::wstring title = IndexedFolderName(1); + const BookmarkNode* folder = AddGroup(0, title); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); - // Let's rename newly added bookmark folder - v->SetTitle(bm0, bm_folder_one, L"New TestFolder"); + std::wstring new_title = IndexedFolderName(2); + SetTitle(0, folder, new_title); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 371826. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_RenameBMFolderWithLongHierarchy) { + SC_RenameBMFolderWithLongHierarchy) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's add first bookmark folder to under bookmark_bar. - const BookmarkNode* test_bm_folder = - v->AddGroup(bm0, bm_bar0, 0, L"Test BMFolder"); - - // Let's add lots of bookmarks and folders underneath test_bm_folder. - for (int index = 0; index < 120; index++) { - int random_int = base::RandInt(1, 100); - // To create randomness in order, 85% of time add bookmarks - if (random_int > 15) { - wstring title(L"Test BMFolder - ChildTestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = - v->AddURL(bm0, test_bm_folder, index, - title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + ASSERT_TRUE(AllModelsMatchVerifier()); + + std::wstring title = IndexedFolderName(1); + const BookmarkNode* folder = AddGroup(0, title); + ASSERT_TRUE(folder != NULL); + for (int i = 0; i < 120; ++i) { + if (base::RandDouble() > 0.15) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); } else { - // Remaining % of time - Add Bookmark folders - wstring title(L"Test BMFolder - ChildTestBMFolder"); - title.append(IntToWStringHack(index)); - const BookmarkNode* bm_folder = - v->AddGroup(bm0, test_bm_folder, index, title); - ASSERT_TRUE(bm_folder != NULL); + std::wstring title = IndexedSubfolderName(i); + ASSERT_TRUE(AddGroup(0, folder, i, title) != NULL); } } - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); - // Let's rename test_bm_folder. - v->SetTitle(bm0, test_bm_folder, L"New TestBMFolder"); + std::wstring new_title = IndexedFolderName(2); + SetTitle(0, folder, new_title); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 371827. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_RenameBMFolderThatHasParentAndChildren) { + SC_RenameBMFolderThatHasParentAndChildren) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's add first bookmark folder to under bookmark_bar. - const BookmarkNode* parent_bm_folder = - v->AddGroup(bm0, bm_bar0, 0, L"Parent TestBMFolder"); - - // Let's add few bookmarks under bookmark_bar. - for (int index = 1; index < 15; index++) { - wstring title(L"TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = - v->AddURL(bm0, bm_bar0, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); - } - - // Let's add first bookmark folder under parent_bm_folder. - const BookmarkNode* test_bm_folder = - v->AddGroup(bm0, parent_bm_folder, 0, L"Test BMFolder"); - // Let's add lots of bookmarks and folders underneath test_bm_folder. - for (int index = 0; index < 120; index++) { - int random_int = base::RandInt(1, 100); - // To create randomness in order, 85% of time add bookmarks - if (random_int > 15) { - wstring title(L"Test BMFolder - ChildTestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = - v->AddURL(bm0, test_bm_folder, index, - title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + ASSERT_TRUE(AllModelsMatchVerifier()); + + const BookmarkNode* folder = AddGroup(0, kGenericFolderName); + ASSERT_TRUE(folder != NULL); + for (int i = 1; i < 15; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, i, title, url) != NULL); + } + std::wstring title = IndexedSubfolderName(1); + const BookmarkNode* subfolder = AddGroup(0, folder, 0, title); + for (int i = 0; i < 120; ++i) { + if (base::RandDouble() > 0.15) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, subfolder, i, title, url) != NULL); } else { - // Remaining % of time - Add Bookmark folders - wstring title(L"Test BMFolder - ChildTestBMFolder"); - title.append(IntToWStringHack(index)); - const BookmarkNode* bm_folder = - v->AddGroup(bm0, test_bm_folder, index, title); - ASSERT_TRUE(bm_folder != NULL); + std::wstring title = IndexedSubsubfolderName(i); + ASSERT_TRUE(AddGroup(0, subfolder, i, title) != NULL); } } - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); - // Let's rename test_bm_folder. - v->SetTitle(bm0, test_bm_folder, L"New TestBMFolder"); + std::wstring new_title = IndexedSubfolderName(2); + SetTitle(0, subfolder, new_title); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 371828. -IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_RenameBMNameAndURL) { +IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, SC_RenameBMNameAndURL) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - // Let's add first bookmark(without favicon) - const BookmarkNode* nofavicon_bm = - v->AddURL(bm0, bm_bar0, 0, L"Google", - GURL("http://www.google.com")); - - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's change the URL. - nofavicon_bm = v->SetURL(bm0, nofavicon_bm, - GURL("http://www.cnn.com")); - // Let's change the Name. - v->SetTitle(bm0, nofavicon_bm, L"CNN"); - // Wait for changes to sync and then verify - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); + + GURL url = GURL(IndexedURL(1)); + std::wstring title = IndexedURLTitle(1); + const BookmarkNode* bookmark = AddURL(0, title, url); + ASSERT_TRUE(bookmark != NULL); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); + + GURL new_url = GURL(IndexedURL(2)); + std::wstring new_title = IndexedURLTitle(2); + bookmark = SetURL(0, bookmark, new_url); + ASSERT_TRUE(bookmark != NULL); + SetTitle(0, bookmark, new_title); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 371832. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_DeleteBMEmptyAccountAfterwards) { + SC_DeleteBMEmptyAccountAfterwards) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's add first bookmark(without favicon) - { - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, bm_bar0, 0, - L"TestBookmark", GURL("http://www.nofaviconurl.com")); - ASSERT_TRUE(nofavicon_bm != NULL); - } - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); - { - // Delete this newly created bookmark - v->Remove(bm0, bm_bar0, 0); - } + ASSERT_TRUE(AddURL(0, kGenericURLTitle, GURL(kGenericURL)) != NULL); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); + Remove(0, GetBookmarkBarNode(0), 0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - // Make sure that client2 has pushed all of it's changes as well. - ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 371833. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_DelBMNonEmptyAccountAfterwards) { + SC_DelBMNonEmptyAccountAfterwards) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - // Let's add some GetBookmarkModel(without favicon) - for (int index = 0; index < 20; index++) { - wstring title(L"TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL( - bm0, bm_bar0, index, - title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + ASSERT_TRUE(AllModelsMatchVerifier()); + + for (int i = 0; i < 20; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, i, title, url) != NULL); } ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); - { - // Delete this newly created bookmark - v->Remove(bm0, bm_bar0, 0); - } + Remove(0, GetBookmarkBarNode(0), 0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } - // Test Scribe ID - 371835. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_DelFirstBMUnderBMFoldNonEmptyFoldAfterwards) { + SC_DelFirstBMUnderBMFoldNonEmptyFoldAfterwards) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - // Let's add first bookmark folder to client1 - const BookmarkNode* bm_folder_one = - v->AddGroup(bm0, bm_bar0, 0, L"TestFolder"); - // Let's add some GetBookmarkModel(without favicon) to this folder - for (int index = 0; index < 10; index++) { - wstring title(L"TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = - v->AddURL(bm0, bm_folder_one, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + ASSERT_TRUE(AllModelsMatchVerifier()); + + const BookmarkNode* folder = AddGroup(0, kGenericFolderName); + ASSERT_TRUE(folder != NULL); + for (int i = 0; i < 10; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); } ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); - { - // Delete first bookmark under this folder - v->Remove(bm0, bm_folder_one, 0); - } + Remove(0, folder, 0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } - // Test Scribe ID - 371836. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_DelLastBMUnderBMFoldNonEmptyFoldAfterwards) { + SC_DelLastBMUnderBMFoldNonEmptyFoldAfterwards) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - // Let's add first bookmark folder to client1 - const BookmarkNode* bm_folder_one = v->AddGroup(bm0, bm_bar0, - 0, L"TestFolder"); - // Let's add some GetBookmarkModel(without favicon) to this folder - for (int index = 0; index < 10; index++) { - wstring title(L"TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL( - bm0, bm_folder_one, - index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + ASSERT_TRUE(AllModelsMatchVerifier()); + + const BookmarkNode* folder = AddGroup(0, kGenericFolderName); + ASSERT_TRUE(folder != NULL); + for (int i = 0; i < 10; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); } ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); - { - // Delete last bookmark under this folder - v->Remove(bm0, bm_folder_one, - (bm_folder_one->GetChildCount() - 1)); - } + Remove(0, folder, folder->GetChildCount() - 1); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } - // Test Scribe ID - 371856. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_DelMiddleBMUnderBMFoldNonEmptyFoldAfterwards) { + SC_DelMiddleBMUnderBMFoldNonEmptyFoldAfterwards) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - // Let's add first bookmark folder to client1 - const BookmarkNode* bm_folder_one = - v->AddGroup(bm0, bm_bar0, 0, L"TestFolder"); - // Let's add some GetBookmarkModel(without favicon) to this folder - for (int index = 0; index < 10; index++) { - wstring title(L"TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = - v->AddURL(bm0, bm_folder_one, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + ASSERT_TRUE(AllModelsMatchVerifier()); + + const BookmarkNode* folder = AddGroup(0, kGenericFolderName); + ASSERT_TRUE(folder != NULL); + for (int i = 0; i < 10; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); } ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); - { - // Delete middle bookmark under this folder - v->Remove(bm0, bm_folder_one, 4); - } + Remove(0, folder, 4); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } - // Test Scribe ID - 371857. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_DelBMsUnderBMFoldEmptyFolderAfterwards) { + SC_DelBMsUnderBMFoldEmptyFolderAfterwards) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - // Let's add first bookmark folder to client1 - const BookmarkNode* bm_folder_one = - v->AddGroup(bm0, bm_bar0, 0, L"TestFolder"); - // Let's add some GetBookmarkModel(without favicon) to this folder - for (int index = 0; index < 10; index++) { - wstring title(L"TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = - v->AddURL(bm0, bm_folder_one, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + ASSERT_TRUE(AllModelsMatchVerifier()); + + const BookmarkNode* folder = AddGroup(0, kGenericFolderName); + ASSERT_TRUE(folder != NULL); + for (int i = 0; i < 10; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); } ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - int child_count = bm_folder_one->GetChildCount(); - // Let's delete all the bookmarks added under this new folder - for (int index = 0; index < child_count; index++) { - v->Remove(bm0, bm_folder_one, 0); - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); + + int child_count = folder->GetChildCount(); + for (int i = 0; i < child_count; ++i) { + Remove(0, folder, 0); } + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 371858. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_DelEmptyBMFoldEmptyAccountAfterwards) { + SC_DelEmptyBMFoldEmptyAccountAfterwards) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's add first bookmark folder to client1 - const BookmarkNode* bm_folder_one = - v->AddGroup(bm0, bm_bar0, 0, L"TestFolder"); - ASSERT_TRUE(bm_folder_one != NULL); + ASSERT_TRUE(AllModelsMatchVerifier()); + ASSERT_TRUE(AddGroup(0, kGenericFolderName) != NULL); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's delete this empty bookmark folder - v->Remove(bm0, bm_bar0, 0); + ASSERT_TRUE(AllModelsMatchVerifier()); + Remove(0, GetBookmarkBarNode(0), 0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } - // Test Scribe ID - 371869. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_DelEmptyBMFoldNonEmptyAccountAfterwards) { + SC_DelEmptyBMFoldNonEmptyAccountAfterwards) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - const BookmarkNode* bm_other0 = bm0->other_node(); - ASSERT_TRUE(bm_other0 != NULL); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - // Let's add first bookmark folder to client1 - const BookmarkNode* bm_folder_one = - v->AddGroup(bm0, bm_bar0, 0, L"TestFolder"); - ASSERT_TRUE(bm_folder_one != NULL); - // Let's add some GetBookmarkModel(without favicon) - for (int index = 1; index < 15; index++) { - int random_int = base::RandInt(1, 100); - // To create randomness in order, 40% of time add bookmarks - if (random_int > 60) { - wstring title(L"BB - TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, bm_bar0, - index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + ASSERT_TRUE(AllModelsMatchVerifier()); + + ASSERT_TRUE(AddGroup(0, kGenericFolderName) != NULL); + for (int i = 1; i < 15; ++i) { + if (base::RandDouble() > 0.6) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, i, title, url) != NULL); } else { - // Remaining % of time - Add Bookmark folders - wstring title(L"BB - TestBMFolder"); - title.append(IntToWStringHack(index)); - const BookmarkNode* bm_folder = v->AddGroup(bm0, bm_bar0, - index, title); - ASSERT_TRUE(bm_folder != NULL); - } + std::wstring title = IndexedFolderName(i); + ASSERT_TRUE(AddGroup(0, i, title) != NULL); + } } ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's delete the first empty bookmark folder - v->Remove(bm0, bm_bar0, 0); + ASSERT_TRUE(AllModelsMatchVerifier()); + Remove(0, GetBookmarkBarNode(0), 0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 371879. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_DelBMFoldWithBMsNonEmptyAccountAfterwards) { + SC_DelBMFoldWithBMsNonEmptyAccountAfterwards) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - ASSERT_TRUE(bm_bar0 != NULL); - const BookmarkNode* bm_other0 = bm0->other_node(); - ASSERT_TRUE(bm_other0 != NULL); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - // Let's add bookmark and bookmark folder to client1 - const BookmarkNode* yahoo = v->AddURL(bm0, bm_bar0, 0, - L"Yahoo!", GURL("http://www.yahoo.com")); - ASSERT_TRUE(yahoo != NULL); - const BookmarkNode* bm_folder_one = - v->AddGroup(bm0, bm_bar0, 1, L"TestFolder"); - // Let's add some GetBookmarkModel(without favicon) and folders to - // bookmark bar - for (int index = 2; index < 10; index++) { - int random_int = base::RandInt(1, 100); - // To create randomness in order, 40% of time add bookmarks - if (random_int > 60) { - wstring title(L"BB - TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, bm_bar0, - index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + ASSERT_TRUE(AllModelsMatchVerifier()); + + ASSERT_TRUE(AddURL(0, kGenericURLTitle, GURL(kGenericURL)) != NULL); + const BookmarkNode* folder = AddGroup(0, 1, kGenericFolderName); + ASSERT_TRUE(folder != NULL); + for (int i = 2; i < 10; ++i) { + if (base::RandDouble() > 0.6) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, i, title, url) != NULL); } else { - // Remaining % of time - Add Bookmark folders - wstring title(L"BB - TestBMFolder"); - title.append(IntToWStringHack(index)); - const BookmarkNode* bm_folder = v->AddGroup(bm0, bm_bar0, - index, title); - ASSERT_TRUE(bm_folder != NULL); - } + std::wstring title = IndexedFolderName(i); + ASSERT_TRUE(AddGroup(0, i, title) != NULL); + } } - - // Let's add some bookmarks(without favicon) to bm_folder_one ('TestFolder') - for (int index = 0; index < 15; index++) { - wstring title(L"Level2 - TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, - bm_folder_one, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + for (int i = 0; i < 15; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); } ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - BookmarkModelVerifier::ExpectModelsMatch(bm0, bm1); - - // Let's delete the bookmark folder (bm_folder_one) - v->Remove(bm0, bm_bar0, 1); + ASSERT_TRUE(AllModelsMatchVerifier()); + Remove(0, GetBookmarkBarNode(0), 1); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - BookmarkModelVerifier::ExpectModelsMatch(bm0, bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 371880. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_DelBMFoldWithBMsAndBMFoldsNonEmptyACAfterwards) { + SC_DelBMFoldWithBMsAndBMFoldsNonEmptyACAfterwards) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - const BookmarkNode* bm_other0 = bm0->other_node(); - ASSERT_TRUE(bm_other0 != NULL); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - // Let's add bookmark and bookmark folder to client1 - const BookmarkNode* yahoo = v->AddURL(bm0, bm_bar0, 0, - L"Yahoo", GURL("http://www.yahoo.com")); - ASSERT_TRUE(yahoo != NULL); - const BookmarkNode* bm_folder_one = - v->AddGroup(bm0, bm_bar0, 1, L"TestFolder"); - // Let's add some GetBookmarkModel(without favicon) and folders to - // bookmark bar - for (int index = 2; index < 10; index++) { - int random_int = base::RandInt(1, 100); - // To create randomness in order, 40% of time add bookmarks - if (random_int > 60) { - wstring title(L"BB - TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, bm_bar0, - index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + ASSERT_TRUE(AllModelsMatchVerifier()); + + ASSERT_TRUE(AddURL(0, kGenericURLTitle, GURL(kGenericURL)) != NULL); + const BookmarkNode* folder = AddGroup(0, 1, kGenericFolderName); + ASSERT_TRUE(folder != NULL); + for (int i = 2; i < 10; ++i) { + if (base::RandDouble() > 0.6) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, i, title, url) != NULL); } else { - // Remaining % of time - Add Bookmark folders - wstring title(L"BB - TestBMFolder"); - title.append(IntToWStringHack(index)); - const BookmarkNode* bm_folder = v->AddGroup(bm0, bm_bar0, - index, title); - ASSERT_TRUE(bm_folder != NULL); - } + std::wstring title = IndexedFolderName(i); + ASSERT_TRUE(AddGroup(0, i, title) != NULL); + } } - - // Let's add some GetBookmarkModel(without favicon) and folders to - // bm_folder_one ('TestFolder') - for (int index = 0; index < 10; index++) { - int random_int = base::RandInt(1, 100); - // To create randomness in order, 40% of time add bookmarks - if (random_int > 60) { - wstring title(L"Level2 - TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, - bm_folder_one, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + for (int i = 0; i < 10; ++i) { + if (base::RandDouble() > 0.6) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); } else { - // Remaining % of time - Add Bookmark folders - wstring title(L"Level2 - TestBMFolder"); - title.append(IntToWStringHack(index)); - const BookmarkNode* l2_bm_folder = v->AddGroup(bm0, - bm_folder_one, index, title); - int random_int2 = base::RandInt(1, 100); - // 70% of time - Let's add more levels of bookmarks and folders to - // l2_bm_folder - if (random_int2 > 30) { - for (int index2 = 0; index2 < 10; index2++) { - int random_int3 = base::RandInt(1, 100); - // To create randomness in order, 40% of time add bookmarks - if (random_int3 > 60) { - wstring title(L"Level3 - TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, - l2_bm_folder, index2, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); - } else { - // Remaining % of time - Add Bookmark folders - wstring title(L"Level3 - TestBMFolder"); - title.append(IntToWStringHack(index)); - const BookmarkNode* l3_bm_folder = - v->AddGroup(bm0, l2_bm_folder, index2, title); - ASSERT_TRUE(l3_bm_folder != NULL); - } - } // end inner for loop + std::wstring title = IndexedSubfolderName(i); + const BookmarkNode* subfolder = AddGroup(0, folder, i, title); + ASSERT_TRUE(subfolder != NULL); + if (base::RandDouble() > 0.3) { + for (int j = 0; j < 10; ++j) { + if (base::RandDouble() > 0.6) { + std::wstring title = IndexedURLTitle(j); + GURL url = GURL(IndexedURL(j)); + ASSERT_TRUE(AddURL(0, subfolder, j, title, url) != NULL); + } else { + std::wstring title = IndexedSubsubfolderName(j); + ASSERT_TRUE(AddGroup(0, subfolder, j, title) != NULL); + } } - } + } } + } ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - BookmarkModelVerifier::ExpectModelsMatch(bm0, bm1); - - // Let's delete the bookmark folder (bm_folder_one) - v->Remove(bm0, bm_bar0, 1); + ASSERT_TRUE(AllModelsMatchVerifier()); + Remove(0, GetBookmarkBarNode(0), 1); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - BookmarkModelVerifier::ExpectModelsMatch(bm0, bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 371882. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_DelBMFoldWithParentAndChildrenBMsAndBMFolds) { + SC_DelBMFoldWithParentAndChildrenBMsAndBMFolds) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's add first bookmark folder to under bookmark_bar. - const BookmarkNode* parent_bm_folder = - v->AddGroup(bm0, bm_bar0, 0, L"Parent TestBMFolder"); - - // Let's add few bookmarks under bookmark_bar. - for (int index = 1; index < 11; index++) { - wstring title(L"TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = - v->AddURL(bm0, bm_bar0, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); - } - - // Let's add first bookmark folder under parent_bm_folder. - const BookmarkNode* test_bm_folder = - v->AddGroup(bm0, parent_bm_folder, 0, L"Test BMFolder"); - // Let's add lots of bookmarks and folders underneath test_bm_folder. - for (int index = 0; index < 30; index++) { - int random_int = base::RandInt(1, 100); - // To create randomness in order, 80% of time add bookmarks - if (random_int > 20) { - wstring title(L"Test BMFolder - ChildTestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = - v->AddURL(bm0, test_bm_folder, index, title, - GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + ASSERT_TRUE(AllModelsMatchVerifier()); + + const BookmarkNode* folder = AddGroup(0, kGenericFolderName); + ASSERT_TRUE(folder != NULL); + for (int i = 1; i < 11; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, i, title, url) != NULL); + } + const BookmarkNode* subfolder = AddGroup(0, folder, 0, kGenericSubfolderName); + ASSERT_TRUE(subfolder != NULL); + for (int i = 0; i < 30; ++i) { + if (base::RandDouble() > 0.2) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, subfolder, i, title, url) != NULL); } else { - // Remaining % of time - Add Bookmark folders - wstring title(L"Test BMFolder - ChildTestBMFolder"); - title.append(IntToWStringHack(index)); - const BookmarkNode* bm_folder = - v->AddGroup(bm0, test_bm_folder, index, title); - ASSERT_TRUE(bm_folder != NULL); + std::wstring title = IndexedSubsubfolderName(i); + ASSERT_TRUE(AddGroup(0, subfolder, i, title) != NULL); } } - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - BookmarkModelVerifier::ExpectModelsMatch(bm0, bm1); - - // Let's delete test_bm_folder - v->Remove(bm0, parent_bm_folder, 0); + ASSERT_TRUE(AllModelsMatchVerifier()); + Remove(0, folder, 0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - BookmarkModelVerifier::ExpectModelsMatch(bm0, bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 371931. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_ReverseTheOrderOfTwoBMs) { + SC_ReverseTheOrderOfTwoBMs) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - const BookmarkNode* bm_a = v->AddURL( - bm0, bm_bar0, 0, L"Bookmark A", - GURL("http://www.nofaviconurla.com")); - ASSERT_TRUE(bm_a != NULL); - const BookmarkNode* bm_b = v->AddURL( - bm0, bm_bar0, 1, L"Bookmark B", - GURL("http://www.nofaviconurlb.com")); - ASSERT_TRUE(bm_b != NULL); - - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - { - // Move bm_a to new position - v->Move(bm0, bm_a, bm_bar0, 2); - } + ASSERT_TRUE(AllModelsMatchVerifier()); + + GURL url0 = GURL(IndexedURL(0)); + GURL url1 = GURL(IndexedURL(1)); + std::wstring title0 = IndexedURLTitle(0); + std::wstring title1 = IndexedURLTitle(1); + const BookmarkNode* bookmark0 = AddURL(0, 0, title0, url0); + const BookmarkNode* bookmark1 = AddURL(0, 1, title1, url1); + ASSERT_TRUE(bookmark0 != NULL); + ASSERT_TRUE(bookmark1 != NULL); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); + + Move(0, bookmark0, GetBookmarkBarNode(0), 2); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 371933. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_ReverseTheOrderOf10BMs) { + SC_ReverseTheOrderOf10BMs) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's add 10 bookmarks like 0123456789 - for (int index = 0; index < 10; index++) { - wstring title(L"BM-"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl-"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, - bm_bar0, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); - } + ASSERT_TRUE(AllModelsMatchVerifier()); + for (int i = 0; i < 10; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, i, title, url) != NULL); + } ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Shuffle bookmarks to make it look like 9876543210 - v->ReverseChildOrder(bm0, bm_bar0); + ASSERT_TRUE(AllModelsMatchVerifier()); + ReverseChildOrder(0, GetBookmarkBarNode(0)); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 371954. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_MovingBMsFromBMBarToBMFolder) { + SC_MovingBMsFromBMBarToBMFolder) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - const BookmarkNode* bm_other0 = bm0->other_node(); - ASSERT_TRUE(bm_other0 != NULL); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - // Let's add bookmark and bookmark folder to client1 - const BookmarkNode* yahoo = v->AddURL(bm0, bm_bar0, 0, - L"Yahoo", GURL("http://www.yahoo.com")); - ASSERT_TRUE(yahoo != NULL); - const BookmarkNode* bm_folder_one = - v->AddGroup(bm0, bm_bar0, 1, L"TestFolder"); - // Let's add some GetBookmarkModel(without favicon) to bookmark bar - for (int index = 2; index < 10; index++) { - wstring title(L"BB - TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, bm_bar0, - index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + ASSERT_TRUE(AllModelsMatchVerifier()); + + ASSERT_TRUE(AddURL(0, kGenericURLTitle, GURL(kGenericURL)) != NULL); + const BookmarkNode* folder = AddGroup(0, 1, kGenericFolderName); + ASSERT_TRUE(folder != NULL); + for (int i = 2; i < 10; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, i, title, url) != NULL); } ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); - // Let's move bookmarks from bookmark bar to BMfolder (bm_folder_one) - int child_count_to_move = bm_bar0->GetChildCount() - 2; - for (int index = 0; index < child_count_to_move; index++) { - v->Move(bm0, bm_bar0->GetChild(2), - bm_folder_one, index); + int num_bookmarks_to_move = GetBookmarkBarNode(0)->GetChildCount() - 2; + for (int i = 0; i < num_bookmarks_to_move; ++i) { + Move(0, GetBookmarkBarNode(0)->GetChild(2), folder, i); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } } // Test Scribe ID - 371957. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_MovingBMsFromBMFoldToBMBar) { + SC_MovingBMsFromBMFoldToBMBar) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - const BookmarkNode* bm_other0 = bm0->other_node(); - ASSERT_TRUE(bm_other0 != NULL); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - // Let's add bookmark and bookmark folder to client1 - const BookmarkNode* yahoo = v->AddURL(bm0, bm_bar0, 0, - L"Yahoo", GURL("http://www.yahoo.com")); - ASSERT_TRUE(yahoo != NULL); - const BookmarkNode* bm_folder_one = - v->AddGroup(bm0, bm_bar0, 1, L"TestFolder"); - // Let's add some GetBookmarkModel(without favicon) to bm_folder_one - for (int index = 0; index < 10; index++) { - wstring title(L"BB - TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, - bm_folder_one, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + ASSERT_TRUE(AllModelsMatchVerifier()); + + ASSERT_TRUE(AddURL(0, kGenericURLTitle, GURL(kGenericURL)) != NULL); + const BookmarkNode* folder = AddGroup(0, 1, kGenericFolderName); + ASSERT_TRUE(folder != NULL); + for (int i = 0; i < 10; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); } ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); - // Let's move bookmarks from BMfolder(bm_folder_one) to bookmark bar - int child_count_to_move = bm_folder_one->GetChildCount(); - for (int index = 0; index < child_count_to_move; index++) { - v->Move(bm0, bm_folder_one->GetChild(0), - bm_bar0, bm_bar0->GetChildCount()); + int num_bookmarks_to_move = folder->GetChildCount() - 2; + for (int i = 0; i < num_bookmarks_to_move; ++i) { + Move(0, folder->GetChild(0), GetBookmarkBarNode(0), i); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } } // Test Scribe ID - 371961. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_MovingBMsFromParentBMFoldToChildBMFold) { + SC_MovingBMsFromParentBMFoldToChildBMFold) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - const BookmarkNode* parent_folder = - v->AddGroup(bm0, bm_bar0, 0, L"Test Parent BMFolder"); - - // Let's add bookmarks a,b,c to parent_folder. - const BookmarkNode* bm_a = v->AddURL( - bm0, parent_folder, 0, L"Bookmark A", - GURL("http://www.nofaviconurl-a.com")); - const BookmarkNode* bm_b = v->AddURL( - bm0, parent_folder, 1, L"Bookmark B", - GURL("http://www.nofaviconurl-b.com")); - const BookmarkNode* bm_c = v->AddURL( - bm0, parent_folder, 2, L"Bookmark C", - GURL("http://www.nofaviconurl-c.com")); - const BookmarkNode* child_folder = - v->AddGroup(bm0, parent_folder, 3, L"Test Child BMFolder"); - - // Let's add few bookmarks under child_folder. - for (int index = 0; index < 10; index++) { - wstring title(L"TestBookmark"); - title.append(IntToWStringHack(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = - v->AddURL(bm0, child_folder, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); - } + ASSERT_TRUE(AllModelsMatchVerifier()); + const BookmarkNode* folder = AddGroup(0, kGenericFolderName); + ASSERT_TRUE(folder != NULL); + for (int i = 0; i < 3; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); + } + const BookmarkNode* subfolder = AddGroup(0, folder, 3, kGenericSubfolderName); + ASSERT_TRUE(subfolder != NULL); + for (int i = 0; i < 10; ++i) { + std::wstring title = IndexedURLTitle(i + 3); + GURL url = GURL(IndexedURL(i + 3)); + ASSERT_TRUE(AddURL(0, subfolder, i, title, url) != NULL); + } ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's move bookmark a,b,c to child_folder. - v->Move(bm0, bm_a, child_folder, 10); - v->Move(bm0, bm_b, child_folder, 11); - v->Move(bm0, bm_c, child_folder, 12); + ASSERT_TRUE(AllModelsMatchVerifier()); + for (int i = 0; i < 3; ++i) { + GURL url = GURL(IndexedURL(i)); + Move(0, GetUniqueNodeByURL(0, url), subfolder, i + 10); + } ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } - // Test Scribe ID - 371964. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_MovingBMsFromChildBMFoldToParentBMFold) { + SC_MovingBMsFromChildBMFoldToParentBMFold) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - const BookmarkNode* parent_folder = - v->AddGroup(bm0, bm_bar0, 0, L"Test Parent BMFolder"); - - // Let's add bookmarks a,b,c to parent_folder. - const BookmarkNode* bm_a = v->AddURL( - bm0, parent_folder, 0, L"Bookmark A", - GURL("http://www.nofaviconurl-a.com")); - ASSERT_TRUE(bm_a != NULL); - const BookmarkNode* bm_b = v->AddURL( - bm0, parent_folder, 1, L"Bookmark B", - GURL("http://www.nofaviconurl-b.com")); - ASSERT_TRUE(bm_b != NULL); - const BookmarkNode* bm_c = v->AddURL( - bm0, parent_folder, 2, L"Bookmark C", - GURL("http://www.nofaviconurl-c.com")); - ASSERT_TRUE(bm_c != NULL); - const BookmarkNode* child_folder = - v->AddGroup(bm0, parent_folder, 3, L"Test Child BMFolder"); - - // Let's add bookmarks d,e,f,g,h to child_folder. - const BookmarkNode* bm_d = v->AddURL( - bm0, child_folder, 0, L"Bookmark D", - GURL("http://www.nofaviconurl-d.com")); - ASSERT_TRUE(bm_d != NULL); - const BookmarkNode* bm_e = v->AddURL( - bm0, child_folder, 1, L"Bookmark E", - GURL("http://www.nofaviconurl-e.com")); - ASSERT_TRUE(bm_e != NULL); - const BookmarkNode* bm_f = v->AddURL( - bm0, child_folder, 2, L"Bookmark F", - GURL("http://www.nofaviconurl-f.com")); - ASSERT_TRUE(bm_f != NULL); - const BookmarkNode* bm_g = v->AddURL( - bm0, child_folder, 3, L"Bookmark G", - GURL("http://www.nofaviconurl-g.com")); - ASSERT_TRUE(bm_g != NULL); - const BookmarkNode* bm_h = v->AddURL( - bm0, child_folder, 4, L"Bookmark H", - GURL("http://www.nofaviconurl-h.com")); - ASSERT_TRUE(bm_h != NULL); - - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's move bookmark d,e,h to parent_folder. - v->Move(bm0, bm_d, parent_folder, 4); - v->Move(bm0, bm_e, parent_folder, 3); - v->Move(bm0, bm_h, parent_folder, 0); - - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); -} + ASSERT_TRUE(AllModelsMatchVerifier()); + const BookmarkNode* folder = AddGroup(0, kGenericFolderName); + ASSERT_TRUE(folder != NULL); + for (int i = 0; i < 3; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); + } + const BookmarkNode* subfolder = AddGroup(0, folder, 3, kGenericSubfolderName); + ASSERT_TRUE(subfolder != NULL); + for (int i = 0; i < 5; ++i) { + std::wstring title = IndexedURLTitle(i + 3); + GURL url = GURL(IndexedURL(i + 3)); + ASSERT_TRUE(AddURL(0, subfolder, i, title, url) != NULL); + } + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); + + for (int i = 0; i < 3; ++i) { + GURL url = GURL(IndexedURL(i + 3)); + Move(0, GetUniqueNodeByURL(0, url), folder, i + 4); + } + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); +} // Test Scribe ID - 371967. -IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_HoistBMs10LevelUp) { +IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, SC_HoistBMs10LevelUp) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - const BookmarkNode* bm_folder = bm_bar0; - const BookmarkNode* bm_folder_L10 = NULL; - const BookmarkNode* bm_folder_L0 = NULL; - for (int level = 0; level < 15; level++) { - // Let's add some GetBookmarkModel(without favicon) to bm_folder. - int child_count = base::RandInt(0, 10); - for (int index = 0; index < child_count; index++) { - wstring title(UTF16ToWideHack(bm_folder->GetTitle())); - title.append(L"-BM"); - string url("http://www.nofaviconurl-"); - title.append(IntToWStringHack(index)); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, - bm_folder, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); - } - wstring title(L"Test BMFolder-"); - title.append(IntToWStringHack(level)); - - bm_folder = v->AddGroup(bm0, - bm_folder, bm_folder->GetChildCount(), title); - // Let's remember first bm folder for later use. - if (level == 0) { - bm_folder_L0 = bm_folder; - } - // Let's remember 10th level bm folder for later use. - if (level == 9) { - bm_folder_L10 = bm_folder; + ASSERT_TRUE(AllModelsMatchVerifier()); + + const BookmarkNode* folder = GetBookmarkBarNode(0); + const BookmarkNode* folder_L0 = NULL; + const BookmarkNode* folder_L10 = NULL; + for (int level = 0; level < 15; ++level) { + int num_bookmarks = base::RandInt(0, 9); + for (int i = 0; i < num_bookmarks; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); } + std::wstring title = IndexedFolderName(level); + folder = AddGroup(0, folder, folder->GetChildCount(), title); + ASSERT_TRUE(folder != NULL); + if (level == 0) folder_L0 = folder; + if (level == 10) folder_L10 = folder; + } + for (int i = 0; i < 3; ++i) { + std::wstring title = IndexedURLTitle(i + 10); + GURL url = GURL(IndexedURL(i + 10)); + ASSERT_TRUE(AddURL(0, folder_L10, i, title, url) != NULL); } - const BookmarkNode* bm_a = v->AddURL(bm0, - bm_folder_L10, bm_folder_L10->GetChildCount(), L"BM-A", - GURL("http://www.bm-a.com")); - const BookmarkNode* bm_b = v->AddURL(bm0, - bm_folder_L10, bm_folder_L10->GetChildCount(), L"BM-B", - GURL("http://www.bm-b.com")); - const BookmarkNode* bm_c = v->AddURL(bm0, - bm_folder_L10, bm_folder_L10->GetChildCount(), L"BM-C", - GURL("http://www.bm-c.com")); - // Let's wait till all the changes populate to another client. - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's move bookmark a from bm_folder_L10 to first bookmark folder- at end. - v->Move(bm0, bm_a, bm_folder_L0, bm_folder_L0->GetChildCount()); - // Let's move bookmark b to first bookmark folder- at the beginning. - v->Move(bm0, bm_b, bm_folder_L0, 0); - // Let's move bookmark c to first bookmark folder- in the middle. - v->Move(bm0, bm_c, bm_folder_L0, 1); - - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); + + GURL url10 = GURL(IndexedURL(10)); + Move(0, GetUniqueNodeByURL(0, url10), folder_L0, folder_L0->GetChildCount()); + GURL url11 = GURL(IndexedURL(11)); + Move(0, GetUniqueNodeByURL(0, url11), folder_L0, 0); + GURL url12 = GURL(IndexedURL(12)); + Move(0, GetUniqueNodeByURL(0, url12), folder_L0, 1); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 371968. -IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_SinkBMs10LevelDown) { +IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, SC_SinkBMs10LevelDown) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - const BookmarkNode* bm_folder = bm_bar0; - const BookmarkNode* bm_folder_L10 = NULL; - const BookmarkNode* bm_folder_L0 = NULL; - for (int level = 0; level < 15; level++) { - // Let's add some GetBookmarkModel(without favicon) to bm_folder. - int child_count = base::RandInt(0, 10); - for (int index = 0; index < child_count; index++) { - wstring title(UTF16ToWideHack(bm_folder->GetTitle())); - title.append(L"-BM"); - string url("http://www.nofaviconurl-"); - title.append(IntToWStringHack(index)); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, - bm_folder, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); - } - wstring title(L"Test BMFolder-"); - title.append(IntToWStringHack(level)); - - bm_folder = v->AddGroup(bm0, - bm_folder, bm_folder->GetChildCount(), title); - // Let's remember first bm folder for later use. - if (level == 0) { - bm_folder_L0 = bm_folder; - } - // Let's remember 10th level bm folder for later use. - if (level == 9) { - bm_folder_L10 = bm_folder; + ASSERT_TRUE(AllModelsMatchVerifier()); + + const BookmarkNode* folder = GetBookmarkBarNode(0); + const BookmarkNode* folder_L0 = NULL; + const BookmarkNode* folder_L10 = NULL; + for (int level = 0; level < 15; ++level) { + int num_bookmarks = base::RandInt(0, 9); + for (int i = 0; i < num_bookmarks; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); } + std::wstring title = IndexedFolderName(level); + folder = AddGroup(0, folder, folder->GetChildCount(), title); + ASSERT_TRUE(folder != NULL); + if (level == 0) folder_L0 = folder; + if (level == 10) folder_L10 = folder; } - const BookmarkNode* bm_a = v->AddURL(bm0, - bm_folder_L10, bm_folder_L10->GetChildCount(), L"BM-A", - GURL("http://www.bm-a.com")); - const BookmarkNode* bm_b = v->AddURL(bm0, - bm_folder_L10, bm_folder_L10->GetChildCount(), L"BM-B", - GURL("http://www.bm-b.com")); - const BookmarkNode* bm_c = v->AddURL(bm0, - bm_folder_L10, bm_folder_L10->GetChildCount(), L"BM-C", - GURL("http://www.bm-c.com")); - // Let's wait till all the changes populate to another client. - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's move bookmark a from bm_folder_L10 to first bookmark - // folder- at end. - v->Move(bm0, bm_a, bm_folder_L10, - bm_folder_L10->GetChildCount()); - // Let's move bookmark b to first bookmark folder- at the beginning. - v->Move(bm0, bm_b, bm_folder_L10, 0); - // Let's move bookmark c to first bookmark folder- in the middle. - v->Move(bm0, bm_c, bm_folder_L10, 1); - - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); -} + for (int i = 0; i < 3; ++i) { + std::wstring title = IndexedURLTitle(i + 10); + GURL url = GURL(IndexedURL(i + 10)); + ASSERT_TRUE(AddURL(0, folder_L0, 0, title, url) != NULL); + } + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); + GURL url10 = GURL(IndexedURL(10)); + Move(0, GetUniqueNodeByURL(0, url10), folder_L10, + folder_L10->GetChildCount()); + GURL url11 = GURL(IndexedURL(11)); + Move(0, GetUniqueNodeByURL(0, url11), folder_L10, 0); + GURL url12 = GURL(IndexedURL(12)); + Move(0, GetUniqueNodeByURL(0, url12), folder_L10, 1); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); +} // Test Scribe ID - 371980. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_SinkEmptyBMFold5LevelsDown) { + SC_SinkEmptyBMFold5LevelsDown) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - const BookmarkNode* bm_folder = bm_bar0; - const BookmarkNode* bm_folder_L5 = NULL; - for (int level = 0; level < 6; level++) { - // Let's add some GetBookmarkModel(without favicon) to bm_folder. - int child_count = base::RandInt(0, 10); - for (int index = 0; index < child_count; index++) { - wstring title(UTF16ToWideHack(bm_folder->GetTitle())); - title.append(L"-BM"); - string url("http://www.nofaviconurl-"); - title.append(IntToWStringHack(index)); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, - bm_folder, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); - } - wstring title(L"Test BMFolder-"); - title.append(IntToWStringHack(level)); - - bm_folder = v->AddGroup(bm0, - bm_folder, bm_folder->GetChildCount(), title); - // Let's remember 5th level bm folder for later use. - if (level == 5) { - bm_folder_L5 = bm_folder; + ASSERT_TRUE(AllModelsMatchVerifier()); + + const BookmarkNode* folder = GetBookmarkBarNode(0); + const BookmarkNode* folder_L5 = NULL; + for (int level = 0; level < 15; ++level) { + int num_bookmarks = base::RandInt(0, 9); + for (int i = 0; i < num_bookmarks; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); } + std::wstring title = IndexedFolderName(level); + folder = AddGroup(0, folder, folder->GetChildCount(), title); + ASSERT_TRUE(folder != NULL); + if (level == 5) folder_L5 = folder; } - const BookmarkNode* empty_bm_folder = v->AddGroup(bm0, - bm_bar0, bm_bar0->GetChildCount(), L"EmptyTest BMFolder"); - - // Let's wait until all the changes populate to another client. + folder = + AddGroup(0, GetBookmarkBarNode(0)->GetChildCount(), kGenericFolderName); + ASSERT_TRUE(folder != NULL); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's move empty_bm_folder from bookmark bar to bm_folder_L5 (at the end). - v->Move(bm0, empty_bm_folder, bm_folder_L5, - bm_folder_L5->GetChildCount()); + ASSERT_TRUE(AllModelsMatchVerifier()); + Move(0, folder, folder_L5, folder_L5->GetChildCount()); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 371997. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_SinkNonEmptyBMFold5LevelsDown) { + SC_SinkNonEmptyBMFold5LevelsDown) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - const BookmarkNode* bm_folder = bm_bar0; - const BookmarkNode* bm_folder_L5 = NULL; - for (int level = 0; level < 6; level++) { - // Let's add some bookmarks (without favicon) to bm_folder. - int child_count = base::RandInt(0, 10); - for (int index = 0; index < child_count; index++) { - wstring title(UTF16ToWideHack(bm_folder->GetTitle())); - title.append(L"-BM"); - string url("http://www.nofaviconurl-"); - title.append(IntToWStringHack(index)); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, - bm_folder, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); - } - wstring title(L"Test BMFolder-"); - title.append(IntToWStringHack(level)); - - bm_folder = v->AddGroup(bm0, - bm_folder, bm_folder->GetChildCount(), title); - // Let's remember 5th level bm folder for later use. - if (level == 5) { - bm_folder_L5 = bm_folder; + ASSERT_TRUE(AllModelsMatchVerifier()); + + const BookmarkNode* folder = GetBookmarkBarNode(0); + const BookmarkNode* folder_L5 = NULL; + for (int level = 0; level < 6; ++level) { + int num_bookmarks = base::RandInt(0, 9); + for (int i = 0; i < num_bookmarks; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); } + std::wstring title = IndexedFolderName(level); + folder = AddGroup(0, folder, folder->GetChildCount(), title); + ASSERT_TRUE(folder != NULL); + if (level == 5) folder_L5 = folder; } - const BookmarkNode* my_bm_folder = v->AddGroup(bm0, - bm_bar0, bm_bar0->GetChildCount(), L"MyTest BMFolder"); - // Let's add few bookmarks to my_bm_folder. - for (int index = 0; index < 10; index++) { - wstring title(UTF16ToWideHack(bm_folder->GetTitle())); - title.append(L"-BM"); - string url("http://www.nofaviconurl-"); - title.append(IntToWStringHack(index)); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, - my_bm_folder, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + folder = + AddGroup(0, GetBookmarkBarNode(0)->GetChildCount(), kGenericFolderName); + ASSERT_TRUE(folder != NULL); + for (int i = 0; i < 10; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); } - - // Let's wait until all the changes populate to another client. ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's move my_bm_folder from bookmark bar to bm_folder_L5 (at the end). - v->Move(bm0, my_bm_folder, bm_folder_L5, - bm_folder_L5->GetChildCount()); + ASSERT_TRUE(AllModelsMatchVerifier()); + Move(0, folder, folder_L5, folder_L5->GetChildCount()); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 372006. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_HoistFolder5LevelsUp) { + SC_HoistFolder5LevelsUp) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - const BookmarkNode* bm_folder = bm_bar0; - const BookmarkNode* bm_folder_L5 = NULL; - for (int level = 0; level < 6; level++) { - // Let's add some GetBookmarkModel(without favicon) to bm_folder. - int child_count = base::RandInt(0, 10); - for (int index = 0; index < child_count; index++) { - wstring title(UTF16ToWideHack(bm_folder->GetTitle())); - title.append(L"-BM"); - string url("http://www.nofaviconurl-"); - title.append(IntToWStringHack(index)); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, - bm_folder, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); - } - wstring title(L"Test BMFolder-"); - title.append(IntToWStringHack(level)); - - bm_folder = v->AddGroup(bm0, - bm_folder, bm_folder->GetChildCount(), title); - // Let's remember 5th level bm folder for later use. - if (level == 5) { - bm_folder_L5 = bm_folder; + ASSERT_TRUE(AllModelsMatchVerifier()); + + const BookmarkNode* folder = GetBookmarkBarNode(0); + const BookmarkNode* folder_L5 = NULL; + for (int level = 0; level < 6; ++level) { + int num_bookmarks = base::RandInt(0, 9); + for (int i = 0; i < num_bookmarks; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); } + std::wstring title = IndexedFolderName(level); + folder = AddGroup(0, folder, folder->GetChildCount(), title); + ASSERT_TRUE(folder != NULL); + if (level == 5) folder_L5 = folder; } - const BookmarkNode* my_bm_folder = v->AddGroup(bm0, - bm_folder_L5, bm_folder_L5->GetChildCount(), L"MyTest BMFolder"); - // Let's add few bookmarks to my_bm_folder. - for (int index = 0; index < 10; index++) { - wstring title(UTF16ToWideHack(bm_folder->GetTitle())); - title.append(L"-BM"); - string url("http://www.nofaviconurl-"); - title.append(IntToWStringHack(index)); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm = v->AddURL(bm0, - my_bm_folder, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm != NULL); + folder = + AddGroup(0, folder_L5, folder_L5->GetChildCount(), kGenericFolderName); + ASSERT_TRUE(folder != NULL); + for (int i = 0; i < 10; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); } - - // Let's wait until all the changes populate to another client. ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's move my_bm_folder from bm_folder_L5 to bookmark bar- at end. - v->Move(bm0, my_bm_folder, bm_bar0, bm_bar0->GetChildCount()); + ASSERT_TRUE(AllModelsMatchVerifier()); + Move(0, folder, GetBookmarkBarNode(0), + GetBookmarkBarNode(0)->GetChildCount()); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } - - // Test Scribe ID - 372026. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_ReverseTheOrderOfTwoBMFolders) { + SC_ReverseTheOrderOfTwoBMFolders) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - const BookmarkNode* bm_folder_a = - v->AddNonEmptyGroup(bm0, bm_bar0, 0, L"TestBMFolderA", 10); - ASSERT_TRUE(bm_folder_a != NULL); - const BookmarkNode* bm_folder_b = - v->AddNonEmptyGroup(bm0, bm_bar0, 1, L"TestBMFolderB", 10); - ASSERT_TRUE(bm_folder_b != NULL); - + ASSERT_TRUE(AllModelsMatchVerifier()); + + for (int i = 0; i < 2; ++i) { + std::wstring title = IndexedFolderName(i); + const BookmarkNode* folder = AddGroup(0, i, title); + ASSERT_TRUE(folder != NULL); + for (int j = 0; j < 10; ++j) { + std::wstring title = IndexedURLTitle(j); + GURL url = GURL(IndexedURL(j)); + ASSERT_TRUE(AddURL(0, folder, j, title, url) != NULL); + } + } ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's change positions of bookmark folders so it is more like ba. - v->ReverseChildOrder(bm0, bm_bar0); + ASSERT_TRUE(AllModelsMatchVerifier()); + ReverseChildOrder(0, GetBookmarkBarNode(0)); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 372028. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_ReverseTheOrderOfTenBMFolders) { + SC_ReverseTheOrderOfTenBMFolders) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Let's add 10 non-empty bookmark folders like 0123456789 - for (int index = 0; index < 10; index++) { - wstring title(L"BM Folder"); - title.append(IntToWStringHack(index)); - const BookmarkNode* child_bm_folder = v->AddNonEmptyGroup( - bm0, bm_bar0, index, title, 10); - ASSERT_TRUE(child_bm_folder != NULL); + ASSERT_TRUE(AllModelsMatchVerifier()); + + for (int i = 0; i < 10; ++i) { + std::wstring title = IndexedFolderName(i); + const BookmarkNode* folder = AddGroup(0, i, title); + ASSERT_TRUE(folder != NULL); + for (int j = 0; j < 10; ++j) { + std::wstring title = IndexedURLTitle(j); + GURL url = GURL(IndexedURL(j)); + ASSERT_TRUE(AddURL(0, folder, j, title, url) != NULL); + } } - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); - - // Shuffle bookmark folders to make it look like 9876543210 - v->ReverseChildOrder(bm0, bm_bar0); + ASSERT_TRUE(AllModelsMatchVerifier()); + ReverseChildOrder(0, GetBookmarkBarNode(0)); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 373379. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - MC_BiDirectionalPushAddingBM) { + MC_BiDirectionalPushAddingBM) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - const BookmarkNode* bm_bar1 = bm1->GetBookmarkBarNode(); - - BookmarkModelVerifier::ExpectModelsMatch(bm0, bm1); - - // Let's add 2 bookmarks (without favicon) on each client. - { - const BookmarkNode* bm_foo1 = bm0->AddURL( - bm_bar0, 0, ASCIIToUTF16("Foo1"), GURL("http://www.foo1.com")); - ASSERT_TRUE(bm_foo1 != NULL); - const BookmarkNode* bm_foo3 = bm1->AddURL( - bm_bar1, 0, ASCIIToUTF16("Foo3"), GURL("http://www.foo3.com")); - ASSERT_TRUE(bm_foo3 != NULL); - - const BookmarkNode* bm_foo2 = bm0->AddURL( - bm_bar0, 1, ASCIIToUTF16("Foo2"), GURL("http://www.foo2.com")); - ASSERT_TRUE(bm_foo2 != NULL); - const BookmarkNode* bm_foo4 = bm1->AddURL( - bm_bar1, 1, ASCIIToUTF16("Foo4"), GURL("http://www.foo4.com")); - ASSERT_TRUE(bm_foo4 != NULL); - } - - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); - BookmarkModelVerifier::ExpectModelsMatch(bm0, bm1); - BookmarkModelVerifier::VerifyNoDuplicates(bm0); + ASSERT_TRUE(AllModelsMatchVerifier()); + + DisableVerifier(); + for (int i = 0; i < 2; ++i) { + std::wstring title0 = IndexedURLTitle(2*i); + GURL url0 = GURL(IndexedURL(2*i)); + ASSERT_TRUE(AddURL(0, title0, url0) != NULL); + std::wstring title1 = IndexedURLTitle(2*i+1); + GURL url1 = GURL(IndexedURL(2*i+1)); + ASSERT_TRUE(AddURL(1, title1, url1) != NULL); + } + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllModelsMatch()); + ASSERT_FALSE(ContainsDuplicateBookmarks(0)); } // Test Scribe ID - 373503. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, MC_BiDirectionalPush_AddingSameBMs) { - ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; - - BookmarkModel* profile0_bookmark_model = GetBookmarkModel(0); - BookmarkModel* profile1_bookmark_model = GetBookmarkModel(1); - - const BookmarkNode* profile0_bookmark_bar = - profile0_bookmark_model->GetBookmarkBarNode(); - const BookmarkNode* profile1_bookmark_bar = - profile1_bookmark_model->GetBookmarkBarNode(); - - { - const BookmarkNode* profile0_bookmark1 = profile0_bookmark_model->AddURL( - profile0_bookmark_bar, 0, ASCIIToUTF16("Bookmark1_name"), - GURL("http://www.bookmark1name.com")); - ASSERT_TRUE(profile0_bookmark1 != NULL); - const BookmarkNode* profile0_bookmark2 = profile0_bookmark_model->AddURL( - profile0_bookmark_bar, 1, ASCIIToUTF16("Bookmark2_name"), - GURL("http://www.bookmark2name.com")); - ASSERT_TRUE(profile0_bookmark2 != NULL); - - const BookmarkNode* profile1_bookmark1 = profile1_bookmark_model->AddURL( - profile1_bookmark_bar, 0, ASCIIToUTF16("Bookmark2_name"), - GURL("http://www.bookmark2name.com")); - ASSERT_TRUE(profile1_bookmark1 != NULL); - const BookmarkNode* profile1_bookmark2 = profile1_bookmark_model->AddURL( - profile1_bookmark_bar, 1, ASCIIToUTF16("Bookmark1_name"), - GURL("http://www.bookmark1name.com")); - ASSERT_TRUE(profile1_bookmark2 != NULL); - } - ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); - BookmarkModelVerifier::ExpectModelsMatch(profile0_bookmark_model, - profile1_bookmark_model); - BookmarkModelVerifier::VerifyNoDuplicates(profile0_bookmark_model); + ASSERT_TRUE(AllModelsMatchVerifier()); + + // Note: When a racy commit is done with identical bookmarks, it is possible + // for duplicates to exist after sync completes. See http://crbug.com/19769. + DisableVerifier(); + for (int i = 0; i < 2; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, title, url) != NULL); + ASSERT_TRUE(AddURL(1, title, url) != NULL); + } + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllModelsMatch()); } // Test Scribe ID - 373506. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - MC_BootStrapEmptyStateEverywhere) { + MC_BootStrapEmptyStateEverywhere) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - BookmarkModelVerifier* v = verifier_helper(); - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); - v->ExpectMatch(bm0); - v->ExpectMatch(bm1); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllModelsMatchVerifier()); } // Test Scribe ID - 373505. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, MC_Merge_CaseInsensitivity_InNames) { ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; + DisableVerifier(); - BookmarkModel* profile0_bookmark_model = GetBookmarkModel(0); - BookmarkModel* profile1_bookmark_model = GetBookmarkModel(1); - - const BookmarkNode* profile0_bookmark_bar = - profile0_bookmark_model->GetBookmarkBarNode(); - - const BookmarkNode* profile1_bookmark_bar = - profile1_bookmark_model->GetBookmarkBarNode(); - - { - const BookmarkNode* profile0_folder = profile0_bookmark_model->AddGroup( - profile0_bookmark_bar, 0, ASCIIToUTF16("TeSt BMFolder")); - ASSERT_TRUE(profile0_folder != NULL); - const BookmarkNode* profile0_bookmark1 = profile0_bookmark_model->AddURL( - profile0_folder, 0, ASCIIToUTF16("bookmark1_name"), - GURL("http://www.bookmark1name.com")); - ASSERT_TRUE(profile0_bookmark1 != NULL); - const BookmarkNode* profile0_bookmark2 = profile0_bookmark_model->AddURL( - profile0_folder, 1, ASCIIToUTF16("bookmark2_name"), - GURL("http://www.bookmark2name.com")); - ASSERT_TRUE(profile0_bookmark2 != NULL); - const BookmarkNode* profile0_bookmark3 = profile0_bookmark_model->AddURL( - profile0_folder, 2, ASCIIToUTF16("BOOKMARK3_NAME"), - GURL("http://www.bookmark3name.com")); - ASSERT_TRUE(profile0_bookmark3 != NULL); - - const BookmarkNode* profile1_folder = profile1_bookmark_model->AddGroup( - profile1_bookmark_bar, 0, ASCIIToUTF16("test bMFolder")); - ASSERT_TRUE(profile1_folder != NULL); - const BookmarkNode* profile1_bookmark1 = profile1_bookmark_model->AddURL( - profile1_folder, 0, ASCIIToUTF16("bookmark3_name"), - GURL("http://www.bookmark3name.com")); - ASSERT_TRUE(profile1_bookmark1 != NULL); - const BookmarkNode* profile1_bookmark2 = profile1_bookmark_model->AddURL( - profile1_folder, 1, ASCIIToUTF16("bookMARK2_Name"), - GURL("http://www.bookmark2name.com")); - ASSERT_TRUE(profile1_bookmark2 != NULL); - } + const BookmarkNode* folder0 = AddGroup(0, L"Folder"); + ASSERT_TRUE(folder0 != NULL); + ASSERT_TRUE(AddURL(0, folder0, 0, L"Bookmark 0", GURL(kGenericURL)) != NULL); + ASSERT_TRUE(AddURL(0, folder0, 1, L"Bookmark 1", GURL(kGenericURL)) != NULL); + ASSERT_TRUE(AddURL(0, folder0, 2, L"Bookmark 2", GURL(kGenericURL)) != NULL); + + const BookmarkNode* folder1 = AddGroup(1, L"fOlDeR"); + ASSERT_TRUE(folder1 != NULL); + ASSERT_TRUE(AddURL(1, folder1, 0, L"bOoKmArK 0", GURL(kGenericURL)) != NULL); + ASSERT_TRUE(AddURL(1, folder1, 1, L"BooKMarK 1", GURL(kGenericURL)) != NULL); + ASSERT_TRUE(AddURL(1, folder1, 2, L"bOOKMARK 2", GURL(kGenericURL)) != NULL); ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); - BookmarkModelVerifier::ExpectModelsMatch(profile0_bookmark_model, - profile1_bookmark_model); - BookmarkModelVerifier::VerifyNoDuplicates(profile0_bookmark_model); - BookmarkModelVerifier::VerifyNoDuplicates(profile1_bookmark_model); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllModelsMatch()); + ASSERT_FALSE(ContainsDuplicateBookmarks(0)); } // Test Scribe ID - 373508. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - MC_SimpleMergeOfDifferentBMModels) { + MC_SimpleMergeOfDifferentBMModels) { ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - const BookmarkNode* bm_bar1 = bm1->GetBookmarkBarNode(); - - // Let's add same bookmarks (without favicon) to both clients. - for (int index = 0; index < 3; index++) { - string16 title(ASCIIToUTF16("TestBookmark")); - title.append(base::IntToString16(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm_client0 = - bm0->AddURL(bm_bar0, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm_client0 != NULL); - const BookmarkNode* nofavicon_bm_client1 = - bm1->AddURL(bm_bar1, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm_client1 != NULL); - } + DisableVerifier(); - // Let's add some different bookmarks (without favicon) to client1. - for (int index = 3; index < 11 ; index++) { - string16 title(ASCIIToUTF16("Client1-TestBookmark")); - title.append(base::IntToString16(index)); - string url("http://www.client1-nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm_client0 = - bm0->AddURL(bm_bar0, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm_client0 != NULL); + for (int i = 0; i < 3; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, i, title, url) != NULL); + ASSERT_TRUE(AddURL(1, i, title, url) != NULL); } - // Let's add some different bookmarks (without favicon) to client2. - for (int index = 3; index < 11 ; index++) { - string16 title(ASCIIToUTF16("Client2-TestBookmark")); - title.append(base::IntToString16(index)); - string url("http://www.Client2-nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm_client1 = - bm1->AddURL(bm_bar1, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm_client1 != NULL); + for (int i = 3; i < 10; ++i) { + std::wstring title0 = IndexedURLTitle(i); + GURL url0 = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, i, title0, url0) != NULL); + std::wstring title1 = IndexedURLTitle(i+7); + GURL url1 = GURL(IndexedURL(i+7)); + ASSERT_TRUE(AddURL(1, i, title1, url1) != NULL); } - // Set up sync on both clients. ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - - // Wait for changes to propagate. - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); - // Let's make sure there aren't any duplicates after sync. - BookmarkModelVerifier::VerifyNoDuplicates(bm0); - // Let's compare and make sure both bookmark models are same after sync. - BookmarkModelVerifier::ExpectModelsMatchIncludingFavicon( - bm0, bm1, false); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllModelsMatch()); + ASSERT_FALSE(ContainsDuplicateBookmarks(0)); } // Test Scribe ID - 386586. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - MC_MergeSimpleBMHierarchyUnderBMBar) { + MC_MergeSimpleBMHierarchyUnderBMBar) { ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - ui_test_utils::WaitForBookmarkModelToLoad(bm1); - - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - const BookmarkNode* bm_bar1 = bm1->GetBookmarkBarNode(); - - // Let's add same bookmarks (without favicon) to both clients. - for (int index = 0; index < 3 ; index++) { - string16 title(ASCIIToUTF16("TestBookmark")); - title.append(base::IntToString16(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm_client0 = - bm0->AddURL(bm_bar0, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm_client0 != NULL); - const BookmarkNode* nofavicon_bm_client1 = - bm1->AddURL(bm_bar1, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm_client1 != NULL); + DisableVerifier(); + + for (int i = 0; i < 3; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, i, title, url) != NULL); + ASSERT_TRUE(AddURL(1, i, title, url) != NULL); } - // Let's add some different bookmarks (without favicon) to client2. - for (int index = 3; index < 5 ; index++) { - string16 title(ASCIIToUTF16("Client2-TestBookmark")); - title.append(base::IntToString16(index)); - string url("http://www.client2-nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm_client1 = - bm1->AddURL(bm_bar1, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm_client1 != NULL); + for (int i = 3; i < 10; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(1, i, title, url) != NULL); } - // Set up sync on both clients. ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - - // Wait for changes to propagate. - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); - // Let's make sure there aren't any duplicates after sync. - BookmarkModelVerifier::VerifyNoDuplicates(bm0); - // Let's compare and make sure both bookmark models are same after sync. - BookmarkModelVerifier::ExpectModelsMatchIncludingFavicon( - bm0, bm1, false); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllModelsMatch()); + ASSERT_FALSE(ContainsDuplicateBookmarks(0)); } // Test Scribe ID - 386589. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - MC_MergeSimpleBMHierarchyEqualSetsUnderBMBar) { + MC_MergeSimpleBMHierarchyEqualSetsUnderBMBar) { ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; - BookmarkModel* bm0 = GetBookmarkModel(0); - BookmarkModel* bm1 = GetBookmarkModel(1); - ui_test_utils::WaitForBookmarkModelToLoad(bm1); - - const BookmarkNode* bm_bar0 = bm0->GetBookmarkBarNode(); - const BookmarkNode* bm_bar1 = bm1->GetBookmarkBarNode(); - - // Let's add same bookmarks (without favicon) to both clients. - for (int index = 0; index < 3 ; index++) { - string16 title(ASCIIToUTF16("TestBookmark")); - title.append(base::IntToString16(index)); - string url("http://www.nofaviconurl"); - url.append(base::IntToString(index)); - url.append(".com"); - const BookmarkNode* nofavicon_bm_client0 = - bm0->AddURL(bm_bar0, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm_client0 != NULL); - const BookmarkNode* nofavicon_bm_client1 = - bm1->AddURL(bm_bar1, index, title, GURL(url)); - ASSERT_TRUE(nofavicon_bm_client1 != NULL); + DisableVerifier(); + + for (int i = 0; i < 3; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, i, title, url) != NULL); + ASSERT_TRUE(AddURL(1, i, title, url) != NULL); } - // Set up sync on both clients. ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - // Wait for changes to propagate. - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); - // Let's make sure there aren't any duplicates after sync. - BookmarkModelVerifier::VerifyNoDuplicates(bm0); - // Let's compare and make sure both bookmark models are same after sync. - BookmarkModelVerifier::ExpectModelsMatchIncludingFavicon( - bm0, bm1, false); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllModelsMatch()); + ASSERT_FALSE(ContainsDuplicateBookmarks(0)); } // Test Scribe ID - 373504 - Merge bookmark folders with different bookmarks. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - MC_MergeBMFoldersWithDifferentBMs) { + MC_MergeBMFoldersWithDifferentBMs) { ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; - BookmarkModel* profile0_bookmark_model = GetBookmarkModel(0); - BookmarkModel* profile1_bookmark_model = GetBookmarkModel(1); - - const BookmarkNode* profile0_bookmark_bar = - profile0_bookmark_model->GetBookmarkBarNode(); - const BookmarkNode* profile1_bookmark_bar = - profile1_bookmark_model->GetBookmarkBarNode(); - - // Let's add first bookmark folder and 2 bookmarks in profile0. - const BookmarkNode* profile0_folder = profile0_bookmark_model->AddGroup( - profile0_bookmark_bar, 0, ASCIIToUTF16("Folder_name")); - ASSERT_TRUE(profile0_folder != NULL); - const BookmarkNode* profile0_bookmark1 = profile0_bookmark_model->AddURL( - profile0_folder, 0, ASCIIToUTF16("bookmark1_name"), - GURL("http://www.bookmark1-url.com")); - ASSERT_TRUE(profile0_bookmark1 != NULL); - const BookmarkNode* profile0_bookmark3 = profile0_bookmark_model->AddURL( - profile0_folder, 1, ASCIIToUTF16("bookmark3_name"), - GURL("http://www.bookmark3-url.com")); - ASSERT_TRUE(profile0_bookmark3 != NULL); - - // Let's add first bookmark folder and 2 bookmarks in profile1. - const BookmarkNode* profile1_folder = profile1_bookmark_model->AddGroup( - profile1_bookmark_bar, 0, ASCIIToUTF16("Folder_name")); - ASSERT_TRUE(profile1_folder != NULL); - const BookmarkNode* profile1_bookmark2 = profile1_bookmark_model->AddURL( - profile1_folder, 0, ASCIIToUTF16("bookmark2_name"), - GURL("http://www.bookmark2-url.com")); - ASSERT_TRUE(profile1_bookmark2 != NULL); - const BookmarkNode* profile1_bookmark4 = profile1_bookmark_model->AddURL( - profile1_folder, 1, ASCIIToUTF16("bookmark4_name"), - GURL("http://www.bookmark4-url.com")); - ASSERT_TRUE(profile1_bookmark4 != NULL); - + DisableVerifier(); + + const BookmarkNode* folder0 = AddGroup(0, kGenericFolderName); + ASSERT_TRUE(folder0 != NULL); + const BookmarkNode* folder1 = AddGroup(1, kGenericFolderName); + ASSERT_TRUE(folder1 != NULL); + for (int i = 0; i < 2; ++i) { + std::wstring title0 = IndexedURLTitle(2*i); + GURL url0 = GURL(IndexedURL(2*i)); + ASSERT_TRUE(AddURL(0, folder0, i, title0, url0) != NULL); + std::wstring title1 = IndexedURLTitle(2*i+1); + GURL url1 = GURL(IndexedURL(2*i+1)); + ASSERT_TRUE(AddURL(1, folder1, i, title1, url1) != NULL); + } ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); - BookmarkModelVerifier::VerifyNoDuplicates(profile0_bookmark_model); - BookmarkModelVerifier::ExpectModelsMatch(profile0_bookmark_model, - profile1_bookmark_model); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllModelsMatch()); + ASSERT_FALSE(ContainsDuplicateBookmarks(0)); } // Test Scribe ID - 373509 - Merge moderately complex bookmark models. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - MC_MergeDifferentBMModelsModeratelyComplex) { + MC_MergeDifferentBMModelsModeratelyComplex) { ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; - BookmarkModel* profile0_bookmark_model = GetBookmarkModel(0); - BookmarkModel* profile1_bookmark_model = GetBookmarkModel(1); - - const BookmarkNode* profile0_bookmark_bar = - profile0_bookmark_model->GetBookmarkBarNode(); - const BookmarkNode* profile1_bookmark_bar = - profile1_bookmark_model->GetBookmarkBarNode(); - - // Let's add some bookmarks in profile0. - for (int index = 0; index < 20; index++) { - string16 title = ASCIIToUTF16(StringPrintf("profile0_bookmark%d-name", - index)); - string url = StringPrintf("http://www.profile0-bookmark%d-url.com", index); - const BookmarkNode* profile0_bookmark0 = profile0_bookmark_model->AddURL( - profile0_bookmark_bar, index, title, GURL(url)); - ASSERT_TRUE(profile0_bookmark0 != NULL); - } - - // Let's add some bookmarks within the folders in profile0. - for (int index = 20; index < 25; index++) { - string16 title = ASCIIToUTF16(StringPrintf("Profile0-Folder%d_name", - index)); - const BookmarkNode* profile0_folder0 = profile0_bookmark_model->AddGroup( - profile0_bookmark_bar, index, title); - ASSERT_TRUE(profile0_folder0 != NULL); - for (int index = 0; index < 5; index++) { - string16 child_title = title + - ASCIIToUTF16(StringPrintf("-bookmark%d_name", index)); - string url = StringPrintf( - "http://www.profile0-folder0-bookmark%d-url.com", index); - const BookmarkNode* profile0_bookmark1 = profile0_bookmark_model->AddURL( - profile0_folder0, index, child_title, GURL(url)); - ASSERT_TRUE(profile0_bookmark1 != NULL); + DisableVerifier(); + + for (int i = 0; i < 25; ++i) { + std::wstring title0 = IndexedURLTitle(i); + GURL url0 = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, i, title0, url0) != NULL); + std::wstring title1 = IndexedURLTitle(i+50); + GURL url1 = GURL(IndexedURL(i+50)); + ASSERT_TRUE(AddURL(1, i, title1, url1) != NULL); + } + for (int i = 25; i < 30; ++i) { + std::wstring title0 = IndexedFolderName(i); + const BookmarkNode* folder0 = AddGroup(0, i, title0); + ASSERT_TRUE(folder0 != NULL); + std::wstring title1 = IndexedFolderName(i+50); + const BookmarkNode* folder1 = AddGroup(1, i, title1); + ASSERT_TRUE(folder1 != NULL); + for (int j = 0; j < 5; ++j) { + std::wstring title0 = IndexedURLTitle(i+5*j); + GURL url0 = GURL(IndexedURL(i+5*j)); + ASSERT_TRUE(AddURL(0, folder0, j, title0, url0) != NULL); + std::wstring title1 = IndexedURLTitle(i+5*j+50); + GURL url1 = GURL(IndexedURL(i+5*j+50)); + ASSERT_TRUE(AddURL(1, folder1, j, title1, url1) != NULL); } } - - // Let's add some bookmarks in profile1. - for (int index = 0; index < 20; index++) { - string16 title = ASCIIToUTF16(StringPrintf("profile1_bookmark%d_name", - index)); - string url = StringPrintf("http://www.profile1-bookmark%d-ulr.com", index); - const BookmarkNode* profile1_bookmark0 = profile1_bookmark_model->AddURL( - profile1_bookmark_bar, index, title, GURL(url)); - ASSERT_TRUE(profile1_bookmark0 != NULL); - } - - // Let's add some bookmarks within the folders in profile1. - for (int index = 20; index < 25; index++) { - string16 title = ASCIIToUTF16(StringPrintf("Profile1-Folder%d_name", - index)); - const BookmarkNode* profile1_folder0 = profile1_bookmark_model->AddGroup( - profile1_bookmark_bar, index, title); - ASSERT_TRUE(profile1_folder0 != NULL); - for (int index = 0; index < 5; index++) { - string16 child_title = title + - ASCIIToUTF16(StringPrintf("-bookmark%d_name", index)); - string url = StringPrintf( - "http://www.profile1-folder0-bookmark%d-url.com", index); - const BookmarkNode* profile1_bookmark1 = profile1_bookmark_model->AddURL( - profile1_folder0, index, child_title, GURL(url)); - ASSERT_TRUE(profile1_bookmark1 != NULL); - } - } - - // Let's add same bookmarks in both the profiles. - for (int index = 25; index < 45; index++) { - string16 title = ASCIIToUTF16(StringPrintf("bookmark%d_name", index)); - string url = StringPrintf("http://www.bookmark%d-url.com", index); - const BookmarkNode* profile0_bookmark = profile0_bookmark_model->AddURL( - profile0_bookmark_bar, index, title, GURL(url)); - ASSERT_TRUE(profile0_bookmark != NULL); - const BookmarkNode* profile1_bookmark = profile1_bookmark_model->AddURL( - profile1_bookmark_bar, index, title, GURL(url)); - ASSERT_TRUE(profile1_bookmark != NULL); - } - - // Let's add same bookmark folders and bookmarks in those on both clients. - for (int index = 45; index < 50; index++) { - string16 title = ASCIIToUTF16(StringPrintf("Folder%d_name", index)); - const BookmarkNode* profile0_folder = profile0_bookmark_model->AddGroup( - profile0_bookmark_bar, index, title); - ASSERT_TRUE(profile0_folder != NULL); - const BookmarkNode* profile1_folder = profile1_bookmark_model->AddGroup( - profile1_bookmark_bar, index, title); - ASSERT_TRUE(profile1_folder != NULL); - // Let's add same bookmarks in the folders created above. - for (int index = 0; index < 5; index++) { - string16 child_title = title + - ASCIIToUTF16(StringPrintf("-bookmark%d_name", index)); - string url = StringPrintf("http://www.folder-bookmark%d-url.com", index); - const BookmarkNode* profile0_bookmark2 = profile0_bookmark_model->AddURL( - profile0_folder, index, child_title, GURL(url)); - ASSERT_TRUE(profile0_bookmark2 != NULL); - const BookmarkNode* profile1_bookmark2 = profile1_bookmark_model->AddURL( - profile1_folder, index, child_title, GURL(url)); - ASSERT_TRUE(profile1_bookmark2 != NULL); - } + for (int i = 100; i < 125; ++i) { + std::wstring title = IndexedURLTitle(i); + GURL url = GURL(IndexedURL(i)); + ASSERT_TRUE(AddURL(0, title, url) != NULL); + ASSERT_TRUE(AddURL(1, title, url) != NULL); } - ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); - BookmarkModelVerifier::VerifyNoDuplicates(profile0_bookmark_model); - BookmarkModelVerifier::ExpectModelsMatch(profile0_bookmark_model, - profile1_bookmark_model); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllModelsMatch()); + ASSERT_FALSE(ContainsDuplicateBookmarks(0)); } // Test Scribe ID - 386591 - Merge simple bookmark subset under bookmark folder. IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - MC_MergeSimpleBMHierarchySubsetUnderBMFolder) { + MC_MergeSimpleBMHierarchySubsetUnderBMFolder) { ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; - - BookmarkModel* profile0_bookmark_model = GetBookmarkModel(0); - BookmarkModel* profile1_bookmark_model = GetBookmarkModel(1); - - const BookmarkNode* profile0_bookmark_bar = - profile0_bookmark_model->GetBookmarkBarNode(); - const BookmarkNode* profile1_bookmark_bar = - profile1_bookmark_model->GetBookmarkBarNode(); - - { - // Let's create the hierarchy in profile0. - const BookmarkNode* profile0_folder = profile0_bookmark_model->AddGroup( - profile0_bookmark_bar, 0, ASCIIToUTF16("Folder_name")); - ASSERT_TRUE(profile0_folder != NULL); - const BookmarkNode* profile0_folder0 = profile0_bookmark_model->AddGroup( - profile0_folder, 0, ASCIIToUTF16("Folder0_name")); - ASSERT_TRUE(profile0_folder0 != NULL); - const BookmarkNode* profile0_bookmark1 = profile0_bookmark_model->AddURL( - profile0_folder0, 0, ASCIIToUTF16("bookmark1_name"), - GURL("http://www.bookmark1-url.com")); - ASSERT_TRUE(profile0_bookmark1 != NULL); - const BookmarkNode* profile0_folder2 = profile0_bookmark_model->AddGroup( - profile0_folder, 1, ASCIIToUTF16("Folder2_name")); - ASSERT_TRUE(profile0_folder2 != NULL); - const BookmarkNode* profile0_bookmark3 = profile0_bookmark_model->AddURL( - profile0_folder2, 0, ASCIIToUTF16("bookmark3_name"), - GURL("http://www.bookmark3-url.com")); - ASSERT_TRUE(profile0_bookmark3 != NULL); - const BookmarkNode* profile0_folder4 = profile0_bookmark_model->AddGroup( - profile0_folder, 2, ASCIIToUTF16("Folder4_name")); - ASSERT_TRUE(profile0_folder4 != NULL); - const BookmarkNode* profile0_bookmark5 = profile0_bookmark_model->AddURL( - profile0_folder4, 0, ASCIIToUTF16("bookmark1_name"), - GURL("http://www.bookmark1-url.com")); - ASSERT_TRUE(profile0_bookmark5 != NULL); - - // Let's create the hierarchy for profile1. - const BookmarkNode* profile1_folder = profile1_bookmark_model->AddGroup( - profile1_bookmark_bar, 0, ASCIIToUTF16("Folder_name")); - ASSERT_TRUE(profile1_folder != NULL); - const BookmarkNode* profile1_folder0 = profile1_bookmark_model->AddGroup( - profile1_folder, 0, ASCIIToUTF16("Folder0_name")); - ASSERT_TRUE(profile1_folder0 != NULL); - const BookmarkNode* profile1_folder2 = profile1_bookmark_model->AddGroup( - profile1_folder, 1, ASCIIToUTF16("Folder2_name")); - ASSERT_TRUE(profile1_folder2 != NULL); - const BookmarkNode* profile1_bookmark3 = profile1_bookmark_model->AddURL( - profile1_folder2, 0, ASCIIToUTF16("bookmark3_name"), - GURL("http://www.bookmark3-url.com")); - ASSERT_TRUE(profile1_bookmark3 != NULL); - const BookmarkNode* profile1_folder4 = profile1_bookmark_model->AddGroup( - profile1_folder, 2, ASCIIToUTF16("Folder4_name")); - ASSERT_TRUE(profile1_folder4 != NULL); - const BookmarkNode* profile1_bookmark5 = profile1_bookmark_model->AddURL( - profile1_folder4, 0, ASCIIToUTF16("bookmark1_name"), - GURL("http://www.bookmark1-url.com")); - ASSERT_TRUE(profile1_bookmark5 != NULL); + DisableVerifier(); + + for (int i = 0; i < 2; ++i) { + const BookmarkNode* folder = AddGroup(i, kGenericFolderName); + ASSERT_TRUE(folder != NULL); + for (int j = 0; j < 4; ++j) { + if (base::RandDouble() < 0.5) { + std::wstring title = IndexedURLTitle(j); + GURL url = GURL(IndexedURL(j)); + ASSERT_TRUE(AddURL(i, folder, j, title, url) != NULL); + } else { + std::wstring title = IndexedFolderName(j); + ASSERT_TRUE(AddGroup(i, folder, j, title) != NULL); + } + } } - - ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); - BookmarkModelVerifier::ExpectModelsMatch(profile0_bookmark_model, - profile1_bookmark_model); -} - -// Test Scribe ID - 370639 - Add bookmarks with different name and same URL. -IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_DuplicateBookmarksWithSameURL) { - ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - - BookmarkModelVerifier* verifier = verifier_helper(); - BookmarkModel* profile0_bookmark_model = GetBookmarkModel(0); - BookmarkModel* profile1_bookmark_model = GetBookmarkModel(1); - - verifier->ExpectMatch(profile0_bookmark_model); - verifier->ExpectMatch(profile1_bookmark_model); - - const BookmarkNode* profile0_bookmark_bar = - profile0_bookmark_model->GetBookmarkBarNode(); - verifier->AddURL(profile0_bookmark_model, profile0_bookmark_bar, - 0, L"Bookmark0_name", GURL("http://www.bookmark-url.com")); - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - verifier->ExpectMatch(profile0_bookmark_model); - verifier->ExpectMatch(profile1_bookmark_model); - - verifier->AddURL(profile0_bookmark_model, profile0_bookmark_bar, - 1, L"Bookmark1_name", GURL("http://www.bookmark-url.com")); - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - verifier->ExpectMatch(profile0_bookmark_model); - verifier->ExpectMatch(profile1_bookmark_model); -} - -// Test Scribe ID - 371818 - Renaming the same bookmark name twice. -IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_TwiceRenamingBookmarkName) { - ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - - BookmarkModelVerifier* verifier = verifier_helper(); - BookmarkModel* profile0_bookmark_model = GetBookmarkModel(0); - BookmarkModel* profile1_bookmark_model = GetBookmarkModel(1); - - verifier->ExpectMatch(profile0_bookmark_model); - verifier->ExpectMatch(profile1_bookmark_model); - - const BookmarkNode* profile0_bookmark_bar = - profile0_bookmark_model->GetBookmarkBarNode(); - const BookmarkNode* profile0_bookmark = verifier->AddURL( - profile0_bookmark_model, profile0_bookmark_bar, - 0, L"bookmark_name", GURL("http://www.bookmark-url.com")); - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - verifier->ExpectMatch(profile0_bookmark_model); - verifier->ExpectMatch(profile1_bookmark_model); - - verifier->SetTitle(profile0_bookmark_model, - profile0_bookmark, L"bookmark_renamed"); - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - verifier->ExpectMatch(profile0_bookmark_model); - verifier->ExpectMatch(profile1_bookmark_model); - - verifier->SetTitle(profile0_bookmark_model, - profile0_bookmark, L"bookmark_name"); - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - BookmarkModelVerifier::VerifyNoDuplicates(profile0_bookmark_model); - verifier->ExpectMatch(profile0_bookmark_model); - verifier->ExpectMatch(profile1_bookmark_model); -} - -// Test Scribe ID - 371823 - Renaming the same bookmark URL twice. -IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, - SC_TwiceRenamingBookmarkURL) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - - BookmarkModelVerifier* verifier = verifier_helper(); - BookmarkModel* profile0_bookmark_model = GetBookmarkModel(0); - BookmarkModel* profile1_bookmark_model = GetBookmarkModel(1); - - verifier->ExpectMatch(profile0_bookmark_model); - verifier->ExpectMatch(profile1_bookmark_model); - - const BookmarkNode* profile0_bookmark_bar = - profile0_bookmark_model->GetBookmarkBarNode(); - const BookmarkNode* profile0_bookmark = verifier->AddURL( - profile0_bookmark_model, profile0_bookmark_bar, - 0, L"bookmark_name", GURL("http://www.bookmark-url.com")); - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - verifier->ExpectMatch(profile0_bookmark_model); - verifier->ExpectMatch(profile1_bookmark_model); - - verifier->SetURL(profile0_bookmark_model, - profile0_bookmark, - GURL("http://www.bookmark-renamed-url.com")); - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - verifier->ExpectMatch(profile0_bookmark_model); - verifier->ExpectMatch(profile1_bookmark_model); - - verifier->SetURL(profile0_bookmark_model, - profile0_bookmark, - GURL("http://www.bookmark-url.com")); - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - BookmarkModelVerifier::VerifyNoDuplicates(profile0_bookmark_model); - verifier->ExpectMatch(profile0_bookmark_model); - verifier->ExpectMatch(profile1_bookmark_model); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllModelsMatch()); + ASSERT_FALSE(ContainsDuplicateBookmarks(0)); } - diff --git a/chrome/test/live_sync/two_client_live_passwords_sync_test.cc b/chrome/test/live_sync/two_client_live_passwords_sync_test.cc index 6114bdd..c20907f 100644 --- a/chrome/test/live_sync/two_client_live_passwords_sync_test.cc +++ b/chrome/test/live_sync/two_client_live_passwords_sync_test.cc @@ -18,19 +18,19 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePasswordsSyncTest, Add) { AddLogin(GetVerififerPasswordStore(), form); AddLogin(GetPasswordStore(0), form); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); std::vector<PasswordForm> expected; GetLogins(GetVerififerPasswordStore(), form, expected); - EXPECT_EQ(1U, expected.size()); + ASSERT_EQ(1U, expected.size()); std::vector<PasswordForm> actual_zero; GetLogins(GetPasswordStore(0), form, actual_zero); - EXPECT_TRUE(ContainsSamePasswordForms(expected, actual_zero)); + ASSERT_TRUE(ContainsSamePasswordForms(expected, actual_zero)); std::vector<PasswordForm> actual_one; GetLogins(GetPasswordStore(1), form, actual_one); - EXPECT_TRUE(ContainsSamePasswordForms(expected, actual_one)); + ASSERT_TRUE(ContainsSamePasswordForms(expected, actual_one)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePasswordsSyncTest, Race) { @@ -51,15 +51,51 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePasswordsSyncTest, Race) { form_one.password_value = ASCIIToUTF16("one"); AddLogin(GetPasswordStore(1), form_one); - EXPECT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); + ASSERT_TRUE(AwaitQuiescence()); std::vector<PasswordForm> actual_zero; GetLogins(GetPasswordStore(0), form, actual_zero); - EXPECT_EQ(1U, actual_zero.size()); + ASSERT_EQ(1U, actual_zero.size()); std::vector<PasswordForm> actual_one; GetLogins(GetPasswordStore(1), form, actual_one); - EXPECT_EQ(1U, actual_one.size()); + ASSERT_EQ(1U, actual_one.size()); - EXPECT_TRUE(ContainsSamePasswordForms(actual_zero, actual_one)); + ASSERT_TRUE(ContainsSamePasswordForms(actual_zero, actual_one)); +} + +// Marked as FAILS -- see http://crbug.com/59867. +IN_PROC_BROWSER_TEST_F(TwoClientLivePasswordsSyncTest, FAILS_SetPassphrase) { + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; + GetClient(0)->service()->SetPassphrase(kValidPassphrase); + GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)); + ASSERT_TRUE(GetClient(1)->service()->observed_passphrase_required()); + GetClient(1)->service()->SetPassphrase(kValidPassphrase); + GetClient(1)->AwaitPassphraseAccepted(); + ASSERT_FALSE(GetClient(1)->service()->observed_passphrase_required()); +} + +IN_PROC_BROWSER_TEST_F(TwoClientLivePasswordsSyncTest, + SetPassphraseAndAddPassword) { + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; + GetClient(0)->service()->SetPassphrase(kValidPassphrase); + + PasswordForm form; + form.origin = GURL("http://www.google.com/"); + form.username_value = ASCIIToUTF16("username"); + form.password_value = ASCIIToUTF16("password"); + + AddLogin(GetPasswordStore(0), form); + + GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)); + ASSERT_TRUE(GetClient(1)->service()->observed_passphrase_required()); + ASSERT_EQ(1, GetClient(1)->GetLastSessionSnapshot()-> + num_conflicting_updates); + + GetClient(1)->service()->SetPassphrase(kValidPassphrase); + GetClient(1)->AwaitSyncCycleCompletion("Accept passphrase and decrypt."); + GetClient(1)->AwaitPassphraseAccepted(); + ASSERT_FALSE(GetClient(1)->service()->observed_passphrase_required()); + ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> + num_conflicting_updates); } diff --git a/chrome/test/live_sync/two_client_live_preferences_sync_test.cc b/chrome/test/live_sync/two_client_live_preferences_sync_test.cc index 2d9f936..b4ca4bb 100644 --- a/chrome/test/live_sync/two_client_live_preferences_sync_test.cc +++ b/chrome/test/live_sync/two_client_live_preferences_sync_test.cc @@ -8,7 +8,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kHomePageIsNewTabPage) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kHomePageIsNewTabPage), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kHomePageIsNewTabPage), GetPrefs(1)->GetBoolean(prefs::kHomePageIsNewTabPage)); bool new_kHomePageIsNewTabPage = !GetVerifierPrefs()->GetBoolean( @@ -17,11 +17,11 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, new_kHomePageIsNewTabPage); GetPrefs(0)->SetBoolean(prefs::kHomePageIsNewTabPage, new_kHomePageIsNewTabPage); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage), GetPrefs(0)->GetBoolean(prefs::kHomePageIsNewTabPage)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage), GetPrefs(1)->GetBoolean(prefs::kHomePageIsNewTabPage)); } @@ -30,16 +30,16 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, Race) { GetPrefs(0)->SetString(prefs::kHomePage, "http://www.google.com/1"); GetPrefs(1)->SetString(prefs::kHomePage, "http://www.google.com/2"); - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); + ASSERT_TRUE(AwaitQuiescence()); - EXPECT_EQ(GetPrefs(0)->GetString(prefs::kHomePage), + ASSERT_EQ(GetPrefs(0)->GetString(prefs::kHomePage), GetPrefs(1)->GetString(prefs::kHomePage)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kPasswordManagerEnabled) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kPasswordManagerEnabled), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kPasswordManagerEnabled), GetPrefs(1)->GetBoolean(prefs::kPasswordManagerEnabled)); bool new_kPasswordManagerEnabled = !GetVerifierPrefs()->GetBoolean( @@ -48,58 +48,58 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, new_kPasswordManagerEnabled); GetPrefs(0)->SetBoolean(prefs::kPasswordManagerEnabled, new_kPasswordManagerEnabled); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kPasswordManagerEnabled), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kPasswordManagerEnabled), GetPrefs(0)->GetBoolean(prefs::kPasswordManagerEnabled)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kPasswordManagerEnabled), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kPasswordManagerEnabled), GetPrefs(1)->GetBoolean(prefs::kPasswordManagerEnabled)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kKeepEverythingSynced) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kKeepEverythingSynced), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kKeepEverythingSynced), GetPrefs(1)->GetBoolean(prefs::kKeepEverythingSynced)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kSyncThemes), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kSyncThemes), GetPrefs(1)->GetBoolean(prefs::kSyncThemes)); GetClient(0)->DisableSyncForDatatype(syncable::THEMES); - EXPECT_NE(GetPrefs(0)->GetBoolean(prefs::kKeepEverythingSynced), + ASSERT_NE(GetPrefs(0)->GetBoolean(prefs::kKeepEverythingSynced), GetPrefs(1)->GetBoolean(prefs::kKeepEverythingSynced)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kSyncPreferences) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kSyncPreferences), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kSyncPreferences), GetPrefs(1)->GetBoolean(prefs::kSyncPreferences)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kPasswordManagerEnabled), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kPasswordManagerEnabled), GetPrefs(1)->GetBoolean(prefs::kPasswordManagerEnabled)); GetClient(0)->DisableSyncForDatatype(syncable::PREFERENCES); GetPrefs(0)->SetBoolean(prefs::kPasswordManagerEnabled, 1); GetPrefs(1)->SetBoolean(prefs::kPasswordManagerEnabled, 0); - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); + ASSERT_TRUE(AwaitQuiescence()); - EXPECT_NE(GetPrefs(0)->GetBoolean(prefs::kPasswordManagerEnabled), + ASSERT_NE(GetPrefs(0)->GetBoolean(prefs::kPasswordManagerEnabled), GetPrefs(1)->GetBoolean(prefs::kPasswordManagerEnabled)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, SignInDialog) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kSyncPreferences), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kSyncPreferences), GetPrefs(1)->GetBoolean(prefs::kSyncPreferences)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kSyncBookmarks), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kSyncBookmarks), GetPrefs(1)->GetBoolean(prefs::kSyncBookmarks)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kSyncThemes), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kSyncThemes), GetPrefs(1)->GetBoolean(prefs::kSyncThemes)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kSyncExtensions), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kSyncExtensions), GetPrefs(1)->GetBoolean(prefs::kSyncExtensions)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kSyncAutofill), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kSyncAutofill), GetPrefs(1)->GetBoolean(prefs::kSyncAutofill)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kKeepEverythingSynced), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kKeepEverythingSynced), GetPrefs(1)->GetBoolean(prefs::kKeepEverythingSynced)); GetClient(0)->DisableSyncForDatatype(syncable::PREFERENCES); @@ -113,40 +113,40 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, SignInDialog) { GetClient(0)->DisableSyncForDatatype(syncable::THEMES); GetClient(1)->EnableSyncForDatatype(syncable::THEMES); - ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients())); + ASSERT_TRUE(AwaitQuiescence()); - EXPECT_NE(GetPrefs(0)->GetBoolean(prefs::kSyncPreferences), + ASSERT_NE(GetPrefs(0)->GetBoolean(prefs::kSyncPreferences), GetPrefs(1)->GetBoolean(prefs::kSyncPreferences)); - EXPECT_NE(GetPrefs(0)->GetBoolean(prefs::kSyncAutofill), + ASSERT_NE(GetPrefs(0)->GetBoolean(prefs::kSyncAutofill), GetPrefs(1)->GetBoolean(prefs::kSyncAutofill)); - EXPECT_NE(GetPrefs(0)->GetBoolean(prefs::kSyncBookmarks), + ASSERT_NE(GetPrefs(0)->GetBoolean(prefs::kSyncBookmarks), GetPrefs(1)->GetBoolean(prefs::kSyncBookmarks)); - EXPECT_NE(GetPrefs(0)->GetBoolean(prefs::kSyncExtensions), + ASSERT_NE(GetPrefs(0)->GetBoolean(prefs::kSyncExtensions), GetPrefs(1)->GetBoolean(prefs::kSyncExtensions)); - EXPECT_NE(GetPrefs(0)->GetBoolean(prefs::kSyncThemes), + ASSERT_NE(GetPrefs(0)->GetBoolean(prefs::kSyncThemes), GetPrefs(1)->GetBoolean(prefs::kSyncThemes)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kShowBookmarkBar) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kShowBookmarkBar), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kShowBookmarkBar), GetPrefs(1)->GetBoolean(prefs::kShowBookmarkBar)); bool new_kShowBookmarkBar = !GetVerifierPrefs()->GetBoolean( prefs::kShowBookmarkBar); GetVerifierPrefs()->SetBoolean(prefs::kShowBookmarkBar, new_kShowBookmarkBar); GetPrefs(0)->SetBoolean(prefs::kShowBookmarkBar, new_kShowBookmarkBar); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kShowBookmarkBar), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kShowBookmarkBar), GetPrefs(0)->GetBoolean(prefs::kShowBookmarkBar)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kShowBookmarkBar), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kShowBookmarkBar), GetPrefs(1)->GetBoolean(prefs::kShowBookmarkBar)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kCheckDefaultBrowser) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kCheckDefaultBrowser), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kCheckDefaultBrowser), GetPrefs(1)->GetBoolean(prefs::kCheckDefaultBrowser)); bool new_kCheckDefaultBrowser = !GetVerifierPrefs()->GetBoolean( @@ -155,96 +155,96 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kCheckDefaultBrowser) { new_kCheckDefaultBrowser); GetPrefs(0)->SetBoolean(prefs::kCheckDefaultBrowser, new_kCheckDefaultBrowser); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kShowBookmarkBar), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kShowBookmarkBar), GetPrefs(0)->GetBoolean(prefs::kCheckDefaultBrowser)); - EXPECT_NE(GetVerifierPrefs()->GetBoolean(prefs::kShowBookmarkBar), + ASSERT_NE(GetVerifierPrefs()->GetBoolean(prefs::kShowBookmarkBar), GetPrefs(1)->GetBoolean(prefs::kCheckDefaultBrowser)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kHomePage) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetString(prefs::kHomePage), + ASSERT_EQ(GetPrefs(0)->GetString(prefs::kHomePage), GetPrefs(1)->GetString(prefs::kHomePage)); GetVerifierPrefs()->SetString(prefs::kHomePage, "http://news.google.com"); GetPrefs(0)->SetString(prefs::kHomePage, "http://news.google.com"); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetString(prefs::kHomePage), + ASSERT_EQ(GetVerifierPrefs()->GetString(prefs::kHomePage), GetPrefs(0)->GetString(prefs::kHomePage)); - EXPECT_EQ(GetVerifierPrefs()->GetString(prefs::kHomePage), + ASSERT_EQ(GetVerifierPrefs()->GetString(prefs::kHomePage), GetPrefs(1)->GetString(prefs::kHomePage)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kShowHomeButton) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kShowHomeButton), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kShowHomeButton), GetPrefs(1)->GetBoolean(prefs::kShowHomeButton)); bool new_kShowHomeButton = !GetVerifierPrefs()->GetBoolean( prefs::kShowHomeButton); GetVerifierPrefs()->SetBoolean(prefs::kShowHomeButton, new_kShowHomeButton); GetPrefs(0)->SetBoolean(prefs::kShowHomeButton, new_kShowHomeButton); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kShowHomeButton), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kShowHomeButton), GetPrefs(0)->GetBoolean(prefs::kShowHomeButton)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kShowHomeButton), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kShowHomeButton), GetPrefs(1)->GetBoolean(prefs::kShowHomeButton)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kEnableTranslate) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kEnableTranslate), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kEnableTranslate), GetPrefs(1)->GetBoolean(prefs::kEnableTranslate)); bool new_kEnableTranslate = !GetVerifierPrefs()->GetBoolean( prefs::kEnableTranslate); GetVerifierPrefs()->SetBoolean(prefs::kEnableTranslate, new_kEnableTranslate); GetPrefs(0)->SetBoolean(prefs::kEnableTranslate, new_kEnableTranslate); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kEnableTranslate), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kEnableTranslate), GetPrefs(0)->GetBoolean(prefs::kEnableTranslate)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kEnableTranslate), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kEnableTranslate), GetPrefs(1)->GetBoolean(prefs::kEnableTranslate)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kAutoFillEnabled) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kAutoFillEnabled), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kAutoFillEnabled), GetPrefs(1)->GetBoolean(prefs::kAutoFillEnabled)); bool new_kAutoFillEnabled = !GetVerifierPrefs()->GetBoolean( prefs::kAutoFillEnabled); GetVerifierPrefs()->SetBoolean(prefs::kAutoFillEnabled, new_kAutoFillEnabled); GetPrefs(0)->SetBoolean(prefs::kAutoFillEnabled, new_kAutoFillEnabled); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kAutoFillEnabled), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kAutoFillEnabled), GetPrefs(0)->GetBoolean(prefs::kAutoFillEnabled)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kAutoFillEnabled), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kAutoFillEnabled), GetPrefs(1)->GetBoolean(prefs::kAutoFillEnabled)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kURLsToRestoreOnStartup) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetInteger(prefs::kRestoreOnStartup), + ASSERT_EQ(GetPrefs(0)->GetInteger(prefs::kRestoreOnStartup), GetPrefs(1)->GetInteger(prefs::kRestoreOnStartup)); - EXPECT_TRUE(GetPrefs(0)->GetMutableList(prefs::kURLsToRestoreOnStartup)-> + ASSERT_TRUE(GetPrefs(0)->GetMutableList(prefs::kURLsToRestoreOnStartup)-> Equals(GetPrefs(1)->GetMutableList(prefs::kURLsToRestoreOnStartup))); GetVerifierPrefs()->SetInteger(prefs::kRestoreOnStartup, 0); GetPrefs(0)->SetInteger(prefs::kRestoreOnStartup, 0); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetInteger(prefs::kRestoreOnStartup), + ASSERT_EQ(GetVerifierPrefs()->GetInteger(prefs::kRestoreOnStartup), GetPrefs(0)->GetInteger(prefs::kRestoreOnStartup)); - EXPECT_EQ(GetVerifierPrefs()->GetInteger(prefs::kRestoreOnStartup), + ASSERT_EQ(GetVerifierPrefs()->GetInteger(prefs::kRestoreOnStartup), GetPrefs(1)->GetInteger(prefs::kRestoreOnStartup)); GetVerifierPrefs()->SetInteger(prefs::kRestoreOnStartup, 4); @@ -265,47 +265,47 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, ScopedPrefUpdate update(GetPrefs(0), prefs::kURLsToRestoreOnStartup); } - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetInteger(prefs::kRestoreOnStartup), + ASSERT_EQ(GetVerifierPrefs()->GetInteger(prefs::kRestoreOnStartup), GetPrefs(0)->GetInteger(prefs::kRestoreOnStartup)); - EXPECT_EQ(GetVerifierPrefs()->GetInteger(prefs::kRestoreOnStartup), + ASSERT_EQ(GetVerifierPrefs()->GetInteger(prefs::kRestoreOnStartup), GetPrefs(1)->GetInteger(prefs::kRestoreOnStartup)); - EXPECT_TRUE(GetVerifierPrefs()-> + ASSERT_TRUE(GetVerifierPrefs()-> GetMutableList(prefs::kURLsToRestoreOnStartup)-> Equals(GetPrefs(0)->GetMutableList(prefs::kURLsToRestoreOnStartup))); - EXPECT_TRUE(GetVerifierPrefs()-> + ASSERT_TRUE(GetVerifierPrefs()-> GetMutableList(prefs::kURLsToRestoreOnStartup)-> Equals(GetPrefs(1)->GetMutableList(prefs::kURLsToRestoreOnStartup))); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kRestoreOnStartup) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetInteger(prefs::kRestoreOnStartup), + ASSERT_EQ(GetPrefs(0)->GetInteger(prefs::kRestoreOnStartup), GetPrefs(1)->GetInteger(prefs::kRestoreOnStartup)); GetVerifierPrefs()->SetInteger(prefs::kRestoreOnStartup, 1); GetPrefs(0)->SetInteger(prefs::kRestoreOnStartup, 1); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetInteger(prefs::kRestoreOnStartup), + ASSERT_EQ(GetVerifierPrefs()->GetInteger(prefs::kRestoreOnStartup), GetPrefs(0)->GetInteger(prefs::kRestoreOnStartup)); - EXPECT_EQ(GetVerifierPrefs()->GetInteger(prefs::kRestoreOnStartup), + ASSERT_EQ(GetVerifierPrefs()->GetInteger(prefs::kRestoreOnStartup), GetPrefs(1)->GetInteger(prefs::kRestoreOnStartup)); } #if defined(USE_NSS) IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, Security) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kCertRevocationCheckingEnabled), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kCertRevocationCheckingEnabled), GetPrefs(1)->GetBoolean(prefs::kCertRevocationCheckingEnabled)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kSSL2Enabled), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kSSL2Enabled), GetPrefs(1)->GetBoolean(prefs::kSSL2Enabled)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kSSL3Enabled), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kSSL3Enabled), GetPrefs(1)->GetBoolean(prefs::kSSL3Enabled)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kTLS1Enabled), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kTLS1Enabled), GetPrefs(1)->GetBoolean(prefs::kTLS1Enabled)); bool new_kCertRevocationCheckingEnabled = !GetVerifierPrefs()->GetBoolean( @@ -327,38 +327,38 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, Security) { GetPrefs(0)->SetBoolean(prefs::kSSL3Enabled, new_kSSL3Enabled); GetVerifierPrefs()->SetBoolean(prefs::kTLS1Enabled, new_kTLS1Enabled); GetPrefs(0)->SetBoolean(prefs::kTLS1Enabled, new_kTLS1Enabled); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()-> + ASSERT_EQ(GetVerifierPrefs()-> GetBoolean(prefs::kCertRevocationCheckingEnabled), GetPrefs(0)->GetBoolean(prefs::kCertRevocationCheckingEnabled)); - EXPECT_NE(GetVerifierPrefs()-> + ASSERT_NE(GetVerifierPrefs()-> GetBoolean(prefs::kCertRevocationCheckingEnabled), GetPrefs(1)->GetBoolean(prefs::kCertRevocationCheckingEnabled)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kSSL2Enabled), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kSSL2Enabled), GetPrefs(0)->GetBoolean(prefs::kSSL2Enabled)); - EXPECT_NE(GetVerifierPrefs()->GetBoolean(prefs::kSSL2Enabled), + ASSERT_NE(GetVerifierPrefs()->GetBoolean(prefs::kSSL2Enabled), GetPrefs(1)->GetBoolean(prefs::kSSL2Enabled)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kSSL3Enabled), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kSSL3Enabled), GetPrefs(0)->GetBoolean(prefs::kSSL3Enabled)); - EXPECT_NE(GetVerifierPrefs()->GetBoolean(prefs::kSSL3Enabled), + ASSERT_NE(GetVerifierPrefs()->GetBoolean(prefs::kSSL3Enabled), GetPrefs(1)->GetBoolean(prefs::kSSL3Enabled)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kTLS1Enabled), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kTLS1Enabled), GetPrefs(0)->GetBoolean(prefs::kTLS1Enabled)); - EXPECT_NE(GetVerifierPrefs()->GetBoolean(prefs::kTLS1Enabled), + ASSERT_NE(GetVerifierPrefs()->GetBoolean(prefs::kTLS1Enabled), GetPrefs(1)->GetBoolean(prefs::kTLS1Enabled)); } #endif // USE_NSS IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, Privacy) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kAlternateErrorPagesEnabled), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kAlternateErrorPagesEnabled), GetPrefs(1)->GetBoolean(prefs::kAlternateErrorPagesEnabled)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kSearchSuggestEnabled), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kSearchSuggestEnabled), GetPrefs(1)->GetBoolean(prefs::kSearchSuggestEnabled)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kDnsPrefetchingEnabled), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kDnsPrefetchingEnabled), GetPrefs(1)->GetBoolean(prefs::kDnsPrefetchingEnabled)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kSafeBrowsingEnabled), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kSafeBrowsingEnabled), GetPrefs(1)->GetBoolean(prefs::kSafeBrowsingEnabled)); bool new_kAlternateErrorPagesEnabled = !GetVerifierPrefs()->GetBoolean( @@ -386,39 +386,39 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, Privacy) { new_kSafeBrowsingEnabled); GetPrefs(0)->SetBoolean(prefs::kSafeBrowsingEnabled, new_kSafeBrowsingEnabled); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kAlternateErrorPagesEnabled), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kAlternateErrorPagesEnabled), GetPrefs(0)->GetBoolean(prefs::kAlternateErrorPagesEnabled)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kAlternateErrorPagesEnabled), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kAlternateErrorPagesEnabled), GetPrefs(1)->GetBoolean(prefs::kAlternateErrorPagesEnabled)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kSearchSuggestEnabled), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kSearchSuggestEnabled), GetPrefs(0)->GetBoolean(prefs::kSearchSuggestEnabled)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kSearchSuggestEnabled), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kSearchSuggestEnabled), GetPrefs(1)->GetBoolean(prefs::kSearchSuggestEnabled)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDnsPrefetchingEnabled), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDnsPrefetchingEnabled), GetPrefs(0)->GetBoolean(prefs::kDnsPrefetchingEnabled)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDnsPrefetchingEnabled), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDnsPrefetchingEnabled), GetPrefs(1)->GetBoolean(prefs::kDnsPrefetchingEnabled)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled), GetPrefs(0)->GetBoolean(prefs::kSafeBrowsingEnabled)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled), GetPrefs(1)->GetBoolean(prefs::kSafeBrowsingEnabled)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, ClearData) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kDeleteBrowsingHistory), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kDeleteBrowsingHistory), GetPrefs(1)->GetBoolean(prefs::kDeleteBrowsingHistory)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kDeleteDownloadHistory), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kDeleteDownloadHistory), GetPrefs(1)->GetBoolean(prefs::kDeleteDownloadHistory)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kDeleteCache), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kDeleteCache), GetPrefs(1)->GetBoolean(prefs::kDeleteCache)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kDeleteCookies), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kDeleteCookies), GetPrefs(1)->GetBoolean(prefs::kDeleteCookies)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kDeletePasswords), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kDeletePasswords), GetPrefs(1)->GetBoolean(prefs::kDeletePasswords)); - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kDeleteFormData), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kDeleteFormData), GetPrefs(1)->GetBoolean(prefs::kDeleteFormData)); bool new_kDeleteBrowsingHistory = !GetVerifierPrefs()->GetBoolean( @@ -450,38 +450,38 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, ClearData) { GetPrefs(0)->SetBoolean(prefs::kDeletePasswords, new_kDeletePasswords); GetVerifierPrefs()->SetBoolean(prefs::kDeleteFormData, new_kDeleteFormData); GetPrefs(0)->SetBoolean(prefs::kDeleteFormData, new_kDeleteFormData); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteBrowsingHistory), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteBrowsingHistory), GetPrefs(0)->GetBoolean(prefs::kDeleteBrowsingHistory)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteBrowsingHistory), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteBrowsingHistory), GetPrefs(1)->GetBoolean(prefs::kDeleteBrowsingHistory)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteDownloadHistory), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteDownloadHistory), GetPrefs(0)->GetBoolean(prefs::kDeleteDownloadHistory)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteDownloadHistory), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteDownloadHistory), GetPrefs(1)->GetBoolean(prefs::kDeleteDownloadHistory)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteCache), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteCache), GetPrefs(0)->GetBoolean(prefs::kDeleteCache)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteCache), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteCache), GetPrefs(1)->GetBoolean(prefs::kDeleteCache)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteCookies), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteCookies), GetPrefs(0)->GetBoolean(prefs::kDeleteCookies)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteCookies), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteCookies), GetPrefs(1)->GetBoolean(prefs::kDeleteCookies)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeletePasswords), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeletePasswords), GetPrefs(0)->GetBoolean(prefs::kDeletePasswords)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeletePasswords), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeletePasswords), GetPrefs(1)->GetBoolean(prefs::kDeletePasswords)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteFormData), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteFormData), GetPrefs(0)->GetBoolean(prefs::kDeleteFormData)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteFormData), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kDeleteFormData), GetPrefs(1)->GetBoolean(prefs::kDeleteFormData)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kWebKitUsesUniversalDetector) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kWebKitUsesUniversalDetector), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kWebKitUsesUniversalDetector), GetPrefs(1)->GetBoolean(prefs::kWebKitUsesUniversalDetector)); bool new_kWebKitUsesUniversalDetector = !GetVerifierPrefs()->GetBoolean( @@ -490,33 +490,33 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, new_kWebKitUsesUniversalDetector); GetPrefs(0)->SetBoolean(prefs::kWebKitUsesUniversalDetector, new_kWebKitUsesUniversalDetector); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kWebKitUsesUniversalDetector), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kWebKitUsesUniversalDetector), GetPrefs(0)->GetBoolean(prefs::kWebKitUsesUniversalDetector)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kWebKitUsesUniversalDetector), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kWebKitUsesUniversalDetector), GetPrefs(1)->GetBoolean(prefs::kWebKitUsesUniversalDetector)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kDefaultCharset) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetString(prefs::kDefaultCharset), + ASSERT_EQ(GetPrefs(0)->GetString(prefs::kDefaultCharset), GetPrefs(1)->GetString(prefs::kDefaultCharset)); GetVerifierPrefs()->SetString(prefs::kDefaultCharset, "Thai"); GetPrefs(0)->SetString(prefs::kDefaultCharset, "Thai"); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetString(prefs::kDefaultCharset), + ASSERT_EQ(GetVerifierPrefs()->GetString(prefs::kDefaultCharset), GetPrefs(0)->GetString(prefs::kDefaultCharset)); - EXPECT_EQ(GetVerifierPrefs()->GetString(prefs::kDefaultCharset), + ASSERT_EQ(GetVerifierPrefs()->GetString(prefs::kDefaultCharset), GetPrefs(1)->GetString(prefs::kDefaultCharset)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kBlockThirdPartyCookies) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kBlockThirdPartyCookies), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kBlockThirdPartyCookies), GetPrefs(1)->GetBoolean(prefs::kBlockThirdPartyCookies)); bool new_kBlockThirdPartyCookies = !GetVerifierPrefs()->GetBoolean( @@ -525,18 +525,18 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, new_kBlockThirdPartyCookies); GetPrefs(0)->SetBoolean(prefs::kBlockThirdPartyCookies, new_kBlockThirdPartyCookies); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kBlockThirdPartyCookies), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kBlockThirdPartyCookies), GetPrefs(0)->GetBoolean(prefs::kBlockThirdPartyCookies)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kBlockThirdPartyCookies), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kBlockThirdPartyCookies), GetPrefs(1)->GetBoolean(prefs::kBlockThirdPartyCookies)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kClearSiteDataOnExit) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kClearSiteDataOnExit), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kClearSiteDataOnExit), GetPrefs(1)->GetBoolean(prefs::kClearSiteDataOnExit)); bool new_kClearSiteDataOnExit = !GetVerifierPrefs()->GetBoolean( @@ -545,18 +545,18 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, new_kClearSiteDataOnExit); GetPrefs(0)->SetBoolean(prefs::kClearSiteDataOnExit, new_kClearSiteDataOnExit); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kClearSiteDataOnExit), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kClearSiteDataOnExit), GetPrefs(0)->GetBoolean(prefs::kClearSiteDataOnExit)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kClearSiteDataOnExit), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kClearSiteDataOnExit), GetPrefs(1)->GetBoolean(prefs::kClearSiteDataOnExit)); } IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kSafeBrowsingEnabled) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kSafeBrowsingEnabled), + ASSERT_EQ(GetPrefs(0)->GetBoolean(prefs::kSafeBrowsingEnabled), GetPrefs(1)->GetBoolean(prefs::kSafeBrowsingEnabled)); bool new_kSafeBrowsingEnabled = !GetVerifierPrefs()->GetBoolean( @@ -565,10 +565,10 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, new_kSafeBrowsingEnabled); GetPrefs(0)->SetBoolean(prefs::kSafeBrowsingEnabled, new_kSafeBrowsingEnabled); - EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled), GetPrefs(0)->GetBoolean(prefs::kSafeBrowsingEnabled)); - EXPECT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled), + ASSERT_EQ(GetVerifierPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled), GetPrefs(1)->GetBoolean(prefs::kSafeBrowsingEnabled)); } |