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.
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"
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
13 using bookmarks_helper::AddURL
;
14 using bookmarks_helper::AwaitAllModelsMatch
;
15 using bookmarks_helper::CountAllBookmarks
;
17 class TwoClientE2ETest
: public SyncTest
{
19 TwoClientE2ETest() : SyncTest(TWO_CLIENT
) {}
20 ~TwoClientE2ETest() override
{}
21 bool TestUsesSelfNotifications() override
{ return false; }
24 DISALLOW_COPY_AND_ASSIGN(TwoClientE2ETest
);
27 IN_PROC_BROWSER_TEST_F(TwoClientE2ETest
, E2E_ONLY(SanitySetup
)) {
28 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
31 IN_PROC_BROWSER_TEST_F(TwoClientE2ETest
, E2E_ONLY(OneClientAddsBookmark
)) {
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);
42 // Add one new bookmark to the first profile.
44 AddURL(0, "Google URL 0", GURL("http://www.google.com/0")) != NULL
);
46 // Blocks and waits for bookmarks models in all profiles to match.
47 ASSERT_TRUE(AwaitAllModelsMatch());
48 // Check that total number of bookmarks is as expected.
49 for (int i
= 0; i
< num_clients(); ++i
) {
50 ASSERT_EQ(CountAllBookmarks(i
), init_bookmarks_count
+ 1) <<
51 "Total bookmark count is wrong.";
55 IN_PROC_BROWSER_TEST_F(TwoClientE2ETest
, E2E_ONLY(TwoClientsAddBookmarks
)) {
57 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
58 // ALl profiles should sync same bookmarks.
59 ASSERT_TRUE(AwaitAllModelsMatch()) <<
60 "Initial bookmark models did not match for all profiles";
61 // For clean profiles, the bookmarks count should be zero. We are not
62 // enforcing this, we only check that the final count is equal to initial
63 // count plus new bookmarks count.
64 int init_bookmarks_count
= CountAllBookmarks(0);
66 // Add one new bookmark per profile.
67 for (int i
= 0; i
< num_clients(); ++i
) {
68 ASSERT_TRUE(AddURL(i
, base::StringPrintf("Google URL %d", i
),
69 GURL(base::StringPrintf("http://www.google.com/%d", i
))) != NULL
);
72 // Blocks and waits for bookmarks models in all profiles to match.
73 ASSERT_TRUE(AwaitAllModelsMatch());
75 // Check that total number of bookmarks is as expected.
76 for (int i
= 0; i
< num_clients(); ++i
) {
77 ASSERT_EQ(CountAllBookmarks(i
), init_bookmarks_count
+ num_clients()) <<
78 "Total bookmark count is wrong.";