OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 "chrome/browser/profiles/profile.h" | |
6 #include "chrome/browser/sync/profile_sync_service_harness.h" | |
7 #include "chrome/test/live_sync/live_bookmarks_sync_test.h" | |
8 | |
9 IN_PROC_BROWSER_TEST_F(SingleClientLiveBookmarksSyncTest, OfflineToOnline) { | |
10 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
11 | |
12 DisableNetwork(GetProfile(0)); | |
13 const BookmarkNode* node = AddFolder(0, L"title"); | |
14 SetTitle(0, node, L"new_title"); | |
15 ASSERT_FALSE(GetClient(0)->AwaitSyncCycleCompletion("Offline state change.")); | |
16 ASSERT_EQ(ProfileSyncService::Status::OFFLINE_UNSYNCED, | |
17 GetClient(0)->GetStatus().summary); | |
18 | |
19 EnableNetwork(GetProfile(0)); | |
20 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Commit changes.")); | |
21 ASSERT_EQ(ProfileSyncService::Status::READY, | |
22 GetClient(0)->GetStatus().summary); | |
23 ASSERT_TRUE(ModelMatchesVerifier(0)); | |
24 } | |
25 | |
26 IN_PROC_BROWSER_TEST_F(SingleClientLiveBookmarksSyncTest, Sanity) { | |
27 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | |
28 | |
29 // Starting state: | |
30 // other_node | |
31 // -> top | |
32 // -> tier1_a | |
33 // -> http://mail.google.com "tier1_a_url0" | |
34 // -> http://www.pandora.com "tier1_a_url1" | |
35 // -> http://www.facebook.com "tier1_a_url2" | |
36 // -> tier1_b | |
37 // -> http://www.nhl.com "tier1_b_url0" | |
38 const BookmarkNode* top = AddFolder(0, GetOtherNode(0), 0, L"top"); | |
39 const BookmarkNode* tier1_a = AddFolder(0, top, 0, L"tier1_a"); | |
40 const BookmarkNode* tier1_b = AddFolder(0, top, 1, L"tier1_b"); | |
41 const BookmarkNode* tier1_a_url0 = AddURL(0, tier1_a, 0, L"tier1_a_url0", | |
42 GURL("http://mail.google.com")); | |
43 const BookmarkNode* tier1_a_url1 = AddURL(0, tier1_a, 1, L"tier1_a_url1", | |
44 GURL("http://www.pandora.com")); | |
45 const BookmarkNode* tier1_a_url2 = AddURL(0, tier1_a, 2, L"tier1_a_url2", | |
46 GURL("http://www.facebook.com")); | |
47 const BookmarkNode* tier1_b_url0 = AddURL(0, tier1_b, 0, L"tier1_b_url0", | |
48 GURL("http://www.nhl.com")); | |
49 | |
50 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
51 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( | |
52 "Waiting for initial sync completed.")); | |
53 ASSERT_TRUE(ModelMatchesVerifier(0)); | |
54 | |
55 // Ultimately we want to end up with the following model; but this test is | |
56 // more about the journey than the destination. | |
57 // | |
58 // bookmark_bar | |
59 // -> CNN (www.cnn.com) | |
60 // -> tier1_a | |
61 // -> tier1_a_url2 (www.facebook.com) | |
62 // -> tier1_a_url1 (www.pandora.com) | |
63 // -> Porsche (www.porsche.com) | |
64 // -> Bank of America (www.bankofamerica.com) | |
65 // -> Seattle Bubble | |
66 // other_node | |
67 // -> top | |
68 // -> tier1_b | |
69 // -> Wired News (www.wired.com) | |
70 // -> tier2_b | |
71 // -> tier1_b_url0 | |
72 // -> tier3_b | |
73 // -> Toronto Maple Leafs (mapleleafs.nhl.com) | |
74 // -> Wynn (www.wynnlasvegas.com) | |
75 // -> tier1_a_url0 | |
76 const BookmarkNode* bar = GetBookmarkBarNode(0); | |
77 const BookmarkNode* cnn = AddURL(0, bar, 0, L"CNN", | |
78 GURL("http://www.cnn.com")); | |
79 ASSERT_TRUE(cnn != NULL); | |
80 Move(0, tier1_a, bar, 1); // 1 should be the end at this point. | |
81 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Bookmark moved.")); | |
82 ASSERT_TRUE(ModelMatchesVerifier(0)); | |
83 | |
84 const BookmarkNode* porsche = AddURL(0, bar, 2, L"Porsche", | |
85 GURL("http://www.porsche.com")); | |
86 // Rearrange stuff in tier1_a. | |
87 ASSERT_EQ(tier1_a, tier1_a_url2->parent()); | |
88 ASSERT_EQ(tier1_a, tier1_a_url1->parent()); | |
89 Move(0, tier1_a_url2, tier1_a, 0); | |
90 Move(0, tier1_a_url1, tier1_a, 2); | |
91 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( | |
92 "Rearrange stuff in tier1_a")); | |
93 ASSERT_TRUE(ModelMatchesVerifier(0)); | |
94 | |
95 ASSERT_EQ(1, tier1_a_url0->parent()->GetIndexOf(tier1_a_url0)); | |
96 Move(0, tier1_a_url0, bar, bar->child_count()); | |
97 const BookmarkNode* boa = AddURL(0, bar, bar->child_count(), | |
98 L"Bank of America", GURL("https://www.bankofamerica.com")); | |
99 ASSERT_TRUE(boa != NULL); | |
100 Move(0, tier1_a_url0, top, top->child_count()); | |
101 const BookmarkNode* bubble = AddURL(0, bar, bar->child_count(), | |
102 L"Seattle Bubble", GURL("http://seattlebubble.com")); | |
103 ASSERT_TRUE(bubble != NULL); | |
104 const BookmarkNode* wired = AddURL(0, bar, 2, L"Wired News", | |
105 GURL("http://www.wired.com")); | |
106 const BookmarkNode* tier2_b = AddFolder(0, tier1_b, 0, L"tier2_b"); | |
107 Move(0, tier1_b_url0, tier2_b, 0); | |
108 Move(0, porsche, bar, 0); | |
109 SetTitle(0, wired, L"News Wired"); | |
110 SetTitle(0, porsche, L"ICanHazPorsche?"); | |
111 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Change title.")); | |
112 ASSERT_TRUE(ModelMatchesVerifier(0)); | |
113 | |
114 ASSERT_EQ(tier1_a_url0->id(), top->GetChild(top->child_count() - 1)->id()); | |
115 Remove(0, top, top->child_count() - 1); | |
116 Move(0, wired, tier1_b, 0); | |
117 Move(0, porsche, bar, 3); | |
118 const BookmarkNode* tier3_b = AddFolder(0, tier2_b, 1, L"tier3_b"); | |
119 const BookmarkNode* leafs = AddURL(0, tier1_a, 0, L"Toronto Maple Leafs", | |
120 GURL("http://mapleleafs.nhl.com")); | |
121 const BookmarkNode* wynn = AddURL(0, bar, 1, L"Wynn", | |
122 GURL("http://www.wynnlasvegas.com")); | |
123 | |
124 Move(0, wynn, tier3_b, 0); | |
125 Move(0, leafs, tier3_b, 0); | |
126 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( | |
127 "Move after addition of bookmarks.")); | |
128 ASSERT_TRUE(ModelMatchesVerifier(0)); | |
129 } | |
OLD | NEW |