OLD | NEW |
---|---|
(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 using bookmarks_helper::AddURL; | |
10 using bookmarks_helper::AwaitAllModelsMatch; | |
11 using bookmarks_helper::CountAllBookmarks; | |
12 | |
13 class TwoClientE2ETest : public SyncTest { | |
14 public: | |
15 TwoClientE2ETest() : SyncTest(TWO_CLIENT) {} | |
16 ~TwoClientE2ETest() override {} | |
17 virtual bool TestUsesSelfNotifications() override { return false; } | |
18 | |
19 private: | |
20 DISALLOW_COPY_AND_ASSIGN(TwoClientE2ETest); | |
21 }; | |
22 | |
23 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
| |
24 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
25 } | |
26 | |
27 IN_PROC_BROWSER_TEST_F(TwoClientE2ETest, DISABLED_OneClientAddsBookmark) { | |
28 DisableVerifier(); | |
29 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
30 // 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.
| |
31 ASSERT_TRUE(AwaitAllModelsMatch()) << | |
32 "Initial bookmark models did not match for all profiles"; | |
33 // For clean profiles, the bookmarks count should be zero. We are not | |
34 // enforcing this, we only check that the final count is equal to initial | |
35 // count plus new bookmarks count. | |
36 int init_bookmarks_count = CountAllBookmarks(0); | |
37 | |
38 // Add one new bookmark to the first profile. | |
39 ASSERT_TRUE( | |
40 AddURL(0, "Google URL 0", GURL("http://www.google.com/0")) != NULL); | |
41 | |
42 // Since the second profile is done running the sync cycle, we need to | |
43 // manually notify it to sync its bookmarks again. | |
44 // Wait few seconds for the first to have completed its commit. | |
45 base::OneShotTimer<TwoClientE2ETest> timer; | |
46 timer.Start(FROM_HERE, | |
47 base::TimeDelta::FromSeconds(5), | |
48 base::Bind(&bookmarks_helper::NotifyBookmarksSync, 1)); | |
49 | |
50 // Blocks and waits for bookmarks models in all profiles to match. | |
51 ASSERT_TRUE(AwaitAllModelsMatch()); | |
52 // Check that total number of bookmarks is as expected. | |
53 for (int i = 0; i < num_clients(); ++i) { | |
54 ASSERT_EQ(CountAllBookmarks(i), init_bookmarks_count + 1) << | |
55 "Total bookmark count is wrong."; | |
56 } | |
57 } | |
58 | |
59 IN_PROC_BROWSER_TEST_F(TwoClientE2ETest, DISABLED_TwoClientsAddBookmarks) { | |
60 DisableVerifier(); | |
61 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
62 // ALl profiles should sync same bookmarks. | |
63 ASSERT_TRUE(AwaitAllModelsMatch()) << | |
64 "Initial bookmark models did not match for all profiles"; | |
65 // For clean profiles, the bookmarks count should be zero. We are not | |
66 // enforcing this, we only check that the final count is equal to initial | |
67 // count plus new bookmarks count. | |
68 int init_bookmarks_count = CountAllBookmarks(0); | |
69 | |
70 // Add one new bookmark per profile. | |
71 for (int i = 0; i < num_clients(); ++i) { | |
72 ASSERT_TRUE(AddURL(i, base::StringPrintf("Google URL %d", i), | |
73 GURL(base::StringPrintf("http://www.google.com/%d", i))) != NULL); | |
74 } | |
75 | |
76 // In some runs the profiles just sync bookmarks automatically after commit. | |
77 // The test would pass quickly. However, for most cases a sync cycle should be | |
78 // enforced to let the profile sync new bookmarks. | |
79 // Wait 5 seconds and notify profiles to sync bookmarks. | |
80 base::OneShotTimer<TwoClientE2ETest> timer; | |
81 timer.Start(FROM_HERE, | |
82 base::TimeDelta::FromSeconds(5), | |
83 base::Bind(&bookmarks_helper::NotifyBookmarksSyncToAllProfiles)); | |
84 | |
85 // Blocks and waits for bookmarks models in all profiles to match. | |
86 ASSERT_TRUE(AwaitAllModelsMatch()); | |
87 // Check that total number of bookmarks is as expected. | |
88 for (int i = 0; i < num_clients(); ++i) { | |
89 ASSERT_EQ(CountAllBookmarks(i), init_bookmarks_count + num_clients()) << | |
90 "Total bookmark count is wrong."; | |
91 } | |
92 } | |
OLD | NEW |