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

Side by Side Diff: chrome/browser/sync/test/integration/two_client_e2e_test.cc

Issue 772513004: Add new E2E sync multi profiles tests. This should not affect any existing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/strings/stringprintf.h"
6 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
7 #include "chrome/browser/sync/test/integration/sync_test.h"
8
9 // The E2E tests are designed to run only against real backend servers. They are
10 // disabled on regular bots. http://crbug.com/431366
11 #define E2E_ONLY(x) DISABLED_##x
12
13 using bookmarks_helper::AddURL;
14 using bookmarks_helper::AwaitAllModelsMatch;
15 using bookmarks_helper::CountAllBookmarks;
16
17 class TwoClientE2ETest : public SyncTest {
18 public:
19 TwoClientE2ETest() : SyncTest(TWO_CLIENT) {}
20 ~TwoClientE2ETest() override {}
21 virtual bool TestUsesSelfNotifications() override { return false; }
22
23 private:
24 DISALLOW_COPY_AND_ASSIGN(TwoClientE2ETest);
25 };
26
27 IN_PROC_BROWSER_TEST_F(TwoClientE2ETest, E2E_ONLY(SanitySetup)) {
28 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
29 }
30
31 IN_PROC_BROWSER_TEST_F(TwoClientE2ETest, E2E_ONLY(OneClientAddsBookmark)) {
32 DisableVerifier();
Nicolas Zea 2014/12/11 19:45:34 Are we ever expecting to use the verifier in E2E t
shadi 2014/12/17 22:50:16 So far I think a verifier is useless in the E2E se
33 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
34 // All profiles should sync same bookmarks.
35 ASSERT_TRUE(AwaitAllModelsMatch()) <<
36 "Initial bookmark models did not match for all profiles";
37 // For clean profiles, the bookmarks count should be zero. We are not
38 // enforcing this, we only check that the final count is equal to initial
39 // count plus new bookmarks count.
40 int init_bookmarks_count = CountAllBookmarks(0);
41
42 // Add one new bookmark to the first profile.
43 ASSERT_TRUE(
44 AddURL(0, "Google URL 0", GURL("http://www.google.com/0")) != NULL);
45
46 // Since the second profile is done running the sync cycle, we need to
47 // manually notify it to sync its bookmarks again.
48 // Wait few seconds for the first to have completed its commit.
49 base::OneShotTimer<TwoClientE2ETest> timer;
50 timer.Start(FROM_HERE,
51 base::TimeDelta::FromSeconds(5),
Nicolas Zea 2014/12/11 19:45:34 Were you planning to try to add some logic to wait
shadi 2014/12/17 22:50:16 Yes. I ended up creating SyncRefresher. PTAL.
52 base::Bind(&bookmarks_helper::NotifyBookmarksSync, 1));
53
54 // Blocks and waits for bookmarks models in all profiles to match.
55 ASSERT_TRUE(AwaitAllModelsMatch());
56 // Check that total number of bookmarks is as expected.
57 for (int i = 0; i < num_clients(); ++i) {
58 ASSERT_EQ(CountAllBookmarks(i), init_bookmarks_count + 1) <<
59 "Total bookmark count is wrong.";
60 }
61 }
62
63 IN_PROC_BROWSER_TEST_F(TwoClientE2ETest, E2E_ONLY(TwoClientsAddBookmarks)) {
64 DisableVerifier();
65 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
66 // ALl profiles should sync same bookmarks.
67 ASSERT_TRUE(AwaitAllModelsMatch()) <<
68 "Initial bookmark models did not match for all profiles";
69 // For clean profiles, the bookmarks count should be zero. We are not
70 // enforcing this, we only check that the final count is equal to initial
71 // count plus new bookmarks count.
72 int init_bookmarks_count = CountAllBookmarks(0);
73
74 // Add one new bookmark per profile.
75 for (int i = 0; i < num_clients(); ++i) {
76 ASSERT_TRUE(AddURL(i, base::StringPrintf("Google URL %d", i),
77 GURL(base::StringPrintf("http://www.google.com/%d", i))) != NULL);
78 }
79
80 // In some runs the profiles just sync bookmarks automatically after commit.
81 // The test would pass quickly. However, for most cases a sync cycle should be
82 // enforced to let the profile sync new bookmarks.
83 // Wait 5 seconds and notify profiles to sync bookmarks.
84 base::OneShotTimer<TwoClientE2ETest> timer;
85 timer.Start(FROM_HERE,
86 base::TimeDelta::FromSeconds(5),
87 base::Bind(&bookmarks_helper::NotifyBookmarksSyncToAllProfiles));
88
89 // Blocks and waits for bookmarks models in all profiles to match.
90 ASSERT_TRUE(AwaitAllModelsMatch());
91 // Check that total number of bookmarks is as expected.
92 for (int i = 0; i < num_clients(); ++i) {
93 ASSERT_EQ(CountAllBookmarks(i), init_bookmarks_count + num_clients()) <<
94 "Total bookmark count is wrong.";
95 }
96 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698