Chromium Code Reviews| Index: chrome/browser/sync/test/integration/two_client_e2e_test.cc |
| diff --git a/chrome/browser/sync/test/integration/two_client_e2e_test.cc b/chrome/browser/sync/test/integration/two_client_e2e_test.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..aa8878c9357a285b6922d35d27ea1d2cfdf9f3f0 |
| --- /dev/null |
| +++ b/chrome/browser/sync/test/integration/two_client_e2e_test.cc |
| @@ -0,0 +1,92 @@ |
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/strings/stringprintf.h" |
| +#include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
| +#include "chrome/browser/sync/test/integration/sync_test.h" |
| + |
| +using bookmarks_helper::AddURL; |
| +using bookmarks_helper::AwaitAllModelsMatch; |
| +using bookmarks_helper::CountAllBookmarks; |
| + |
| +class TwoClientE2ETest : public SyncTest { |
| + public: |
| + TwoClientE2ETest() : SyncTest(TWO_CLIENT) {} |
| + ~TwoClientE2ETest() override {} |
| + virtual bool TestUsesSelfNotifications() override { return false; } |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(TwoClientE2ETest); |
| +}; |
| + |
| +IN_PROC_BROWSER_TEST_F(TwoClientE2ETest, DISABLED_SanitySetup) { |
|
pval...(no longer on Chromium)
2014/12/09 18:44:08
I'm not sure if we did this in the other test, but
shadi
2014/12/10 18:10:10
I added a #define E2E_ONLY() above to include add
pval...(no longer on Chromium)
2014/12/11 19:24:52
cool; I think this may be how we end up designatin
|
| + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(TwoClientE2ETest, DISABLED_OneClientAddsBookmark) { |
| + DisableVerifier(); |
| + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| + // ALl profiles should sync same bookmarks. |
|
pval...(no longer on Chromium)
2014/12/09 18:44:08
nit: ALl -> All
shadi
2014/12/10 18:10:10
Done.
|
| + ASSERT_TRUE(AwaitAllModelsMatch()) << |
| + "Initial bookmark models did not match for all profiles"; |
| + // For clean profiles, the bookmarks count should be zero. We are not |
| + // enforcing this, we only check that the final count is equal to initial |
| + // count plus new bookmarks count. |
| + int init_bookmarks_count = CountAllBookmarks(0); |
| + |
| + // Add one new bookmark to the first profile. |
| + ASSERT_TRUE( |
| + AddURL(0, "Google URL 0", GURL("http://www.google.com/0")) != NULL); |
| + |
| + // Since the second profile is done running the sync cycle, we need to |
| + // manually notify it to sync its bookmarks again. |
| + // Wait few seconds for the first to have completed its commit. |
| + base::OneShotTimer<TwoClientE2ETest> timer; |
| + timer.Start(FROM_HERE, |
| + base::TimeDelta::FromSeconds(5), |
| + base::Bind(&bookmarks_helper::NotifyBookmarksSync, 1)); |
| + |
| + // Blocks and waits for bookmarks models in all profiles to match. |
| + ASSERT_TRUE(AwaitAllModelsMatch()); |
| + // Check that total number of bookmarks is as expected. |
| + for (int i = 0; i < num_clients(); ++i) { |
| + ASSERT_EQ(CountAllBookmarks(i), init_bookmarks_count + 1) << |
| + "Total bookmark count is wrong."; |
| + } |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(TwoClientE2ETest, DISABLED_TwoClientsAddBookmarks) { |
| + DisableVerifier(); |
| + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| + // ALl profiles should sync same bookmarks. |
| + ASSERT_TRUE(AwaitAllModelsMatch()) << |
| + "Initial bookmark models did not match for all profiles"; |
| + // For clean profiles, the bookmarks count should be zero. We are not |
| + // enforcing this, we only check that the final count is equal to initial |
| + // count plus new bookmarks count. |
| + int init_bookmarks_count = CountAllBookmarks(0); |
| + |
| + // Add one new bookmark per profile. |
| + for (int i = 0; i < num_clients(); ++i) { |
| + ASSERT_TRUE(AddURL(i, base::StringPrintf("Google URL %d", i), |
| + GURL(base::StringPrintf("http://www.google.com/%d", i))) != NULL); |
| + } |
| + |
| + // In some runs the profiles just sync bookmarks automatically after commit. |
| + // The test would pass quickly. However, for most cases a sync cycle should be |
| + // enforced to let the profile sync new bookmarks. |
| + // Wait 5 seconds and notify profiles to sync bookmarks. |
| + base::OneShotTimer<TwoClientE2ETest> timer; |
| + timer.Start(FROM_HERE, |
| + base::TimeDelta::FromSeconds(5), |
| + base::Bind(&bookmarks_helper::NotifyBookmarksSyncToAllProfiles)); |
| + |
| + // Blocks and waits for bookmarks models in all profiles to match. |
| + ASSERT_TRUE(AwaitAllModelsMatch()); |
| + // Check that total number of bookmarks is as expected. |
| + for (int i = 0; i < num_clients(); ++i) { |
| + ASSERT_EQ(CountAllBookmarks(i), init_bookmarks_count + num_clients()) << |
| + "Total bookmark count is wrong."; |
| + } |
| +} |