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

Side by Side Diff: chrome/test/live_sync/performance_bookmarks_sync_test.cc

Issue 7259005: Allow sync integration tests to operate on multiple datatypes: Preferences + Bookmarks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add BookmarksHelper class. (TODO: Trim lines to 80 chars) Created 9 years, 5 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync/profile_sync_service_harness.h" 5 #include "chrome/browser/sync/profile_sync_service_harness.h"
6 #include "chrome/test/live_sync/live_bookmarks_sync_test.h" 6 #include "chrome/test/live_sync/bookmarks_helper.h"
7 #include "chrome/test/live_sync/live_sync_test.h"
7 #include "chrome/test/live_sync/live_sync_timing_helper.h" 8 #include "chrome/test/live_sync/live_sync_timing_helper.h"
8 9
9 static const int kNumBookmarks = 150; 10 static const int kNumBookmarks = 150;
10 11
11 // TODO(braffert): Consider the range / resolution of these test points. 12 // TODO(braffert): Consider the range / resolution of these test points.
12 static const int kNumBenchmarkPoints = 18; 13 static const int kNumBenchmarkPoints = 18;
13 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125, 14 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125,
14 150, 175, 200, 225, 250, 300, 350, 400, 15 150, 175, 200, 225, 250, 300, 350, 400,
15 500}; 16 500};
16 17
17 // TODO(braffert): Move this class into its own .h/.cc files. What should the 18 // TODO(braffert): Move this class into its own .h/.cc files. What should the
18 // class files be named as opposed to the file containing the tests themselves? 19 // class files be named as opposed to the file containing the tests themselves?
19 class PerformanceLiveBookmarksSyncTest 20 class PerformanceLiveBookmarksSyncTest : public LiveSyncTest {
20 : public TwoClientLiveBookmarksSyncTest {
21 public: 21 public:
22 PerformanceLiveBookmarksSyncTest() : url_number(0), url_title_number(0) {} 22 PerformanceLiveBookmarksSyncTest()
23 : LiveSyncTest(TWO_CLIENT),
24 url_number(0),
25 url_title_number(0) {}
23 26
24 // Adds |num_urls| new unique bookmarks to the bookmark bar for |profile|. 27 // Adds |num_urls| new unique bookmarks to the bookmark bar for |profile|.
25 void AddURLs(int profile, int num_urls); 28 void AddURLs(int profile, int num_urls);
26 29
27 // Updates the URL for all bookmarks in the bookmark bar for |profile|. 30 // Updates the URL for all bookmarks in the bookmark bar for |profile|.
28 void UpdateURLs(int profile); 31 void UpdateURLs(int profile);
29 32
30 // Removes all bookmarks in the bookmark bar for |profile|. 33 // Removes all bookmarks in the bookmark bar for |profile|.
31 void RemoveURLs(int profile); 34 void RemoveURLs(int profile);
32 35
33 // Remvoes all bookmarks in the bookmark bars for all profiles. Called 36 // Remvoes all bookmarks in the bookmark bars for all profiles. Called
34 // between benchmark iterations. 37 // between benchmark iterations.
35 void Cleanup(); 38 void Cleanup();
36 39
37 private: 40 private:
38 // Returns a new unique bookmark URL. 41 // Returns a new unique bookmark URL.
39 std::string NextIndexedURL(); 42 std::string NextIndexedURL();
40 43
41 // Returns a new unique bookmark title. 44 // Returns a new unique bookmark title.
42 std::wstring NextIndexedURLTitle(); 45 std::wstring NextIndexedURLTitle();
43 46
44 int url_number; 47 int url_number;
45 int url_title_number; 48 int url_title_number;
46 DISALLOW_COPY_AND_ASSIGN(PerformanceLiveBookmarksSyncTest); 49 DISALLOW_COPY_AND_ASSIGN(PerformanceLiveBookmarksSyncTest);
47 }; 50 };
48 51
49 void PerformanceLiveBookmarksSyncTest::AddURLs(int profile, int num_urls) { 52 void PerformanceLiveBookmarksSyncTest::AddURLs(int profile, int num_urls) {
50 for (int i = 0; i < num_urls; ++i) { 53 for (int i = 0; i < num_urls; ++i) {
51 ASSERT_TRUE(AddURL( 54 ASSERT_TRUE(BookmarksHelper::AddURL(
52 profile, 0, NextIndexedURLTitle(), GURL(NextIndexedURL())) != NULL); 55 profile, 0, NextIndexedURLTitle(), GURL(NextIndexedURL())) != NULL);
53 } 56 }
54 } 57 }
55 58
56 void PerformanceLiveBookmarksSyncTest::UpdateURLs(int profile) { 59 void PerformanceLiveBookmarksSyncTest::UpdateURLs(int profile) {
57 for (int i = 0; i < GetBookmarkBarNode(profile)->child_count(); ++i) { 60 for (int i = 0; i < BookmarksHelper::GetBookmarkBarNode(profile)->child_count( ); ++i) {
58 ASSERT_TRUE(SetURL(profile, GetBookmarkBarNode(profile)->GetChild(i), 61 ASSERT_TRUE(BookmarksHelper::SetURL(profile, BookmarksHelper::GetBookmarkBar Node(profile)->GetChild(i),
59 GURL(NextIndexedURL()))); 62 GURL(NextIndexedURL())));
60 } 63 }
61 } 64 }
62 65
63 void PerformanceLiveBookmarksSyncTest::RemoveURLs(int profile) { 66 void PerformanceLiveBookmarksSyncTest::RemoveURLs(int profile) {
64 while (GetBookmarkBarNode(profile)->child_count()) { 67 while (BookmarksHelper::GetBookmarkBarNode(profile)->child_count()) {
65 Remove(profile, GetBookmarkBarNode(profile), 0); 68 BookmarksHelper::Remove(profile, BookmarksHelper::GetBookmarkBarNode(profile ), 0);
66 } 69 }
67 } 70 }
68 71
69 void PerformanceLiveBookmarksSyncTest::Cleanup() { 72 void PerformanceLiveBookmarksSyncTest::Cleanup() {
70 for (int i = 0; i < num_clients(); ++i) { 73 for (int i = 0; i < num_clients(); ++i) {
71 RemoveURLs(i); 74 RemoveURLs(i);
72 } 75 }
73 ASSERT_TRUE(AwaitQuiescence()); 76 ASSERT_TRUE(AwaitQuiescence());
74 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count()); 77 ASSERT_EQ(0, BookmarksHelper::GetBookmarkBarNode(0)->child_count());
75 ASSERT_TRUE(AllModelsMatch()); 78 ASSERT_TRUE(BookmarksHelper::AllModelsMatch());
76 } 79 }
77 80
78 std::string PerformanceLiveBookmarksSyncTest::NextIndexedURL() { 81 std::string PerformanceLiveBookmarksSyncTest::NextIndexedURL() {
79 return IndexedURL(url_number++); 82 return BookmarksHelper::IndexedURL(url_number++);
80 } 83 }
81 84
82 std::wstring PerformanceLiveBookmarksSyncTest::NextIndexedURLTitle() { 85 std::wstring PerformanceLiveBookmarksSyncTest::NextIndexedURLTitle() {
83 return IndexedURLTitle(url_title_number++); 86 return BookmarksHelper::IndexedURLTitle(url_title_number++);
84 } 87 }
85 88
86 // TODO(braffert): Possibly split each of these into separate up / down test 89 // TODO(braffert): Possibly split each of these into separate up / down test
87 // cases? 90 // cases?
88 // TCM ID - 7556828. 91 // TCM ID - 7556828.
89 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Add) { 92 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Add) {
90 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 93 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
91 DisableVerifier(); 94 DisableVerifier();
92 95
93 DisableNetwork(GetProfile(1)); 96 DisableNetwork(GetProfile(1));
94 AddURLs(0, kNumBookmarks); 97 AddURLs(0, kNumBookmarks);
95 base::TimeDelta dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0)); 98 base::TimeDelta dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0));
96 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count()); 99 ASSERT_EQ(kNumBookmarks, BookmarksHelper::GetBookmarkBarNode(0)->child_count() );
97 ASSERT_EQ(0, GetBookmarkBarNode(1)->child_count()); 100 ASSERT_EQ(0, BookmarksHelper::GetBookmarkBarNode(1)->child_count());
98 101
99 EnableNetwork(GetProfile(1)); 102 EnableNetwork(GetProfile(1));
100 base::TimeDelta dt_down = 103 base::TimeDelta dt_down =
101 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 104 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
102 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count()); 105 ASSERT_EQ(kNumBookmarks, BookmarksHelper::GetBookmarkBarNode(0)->child_count() );
103 ASSERT_TRUE(AllModelsMatch()); 106 ASSERT_TRUE(BookmarksHelper::AllModelsMatch());
104 107
105 // TODO(braffert): Compare timings against some target value. 108 // TODO(braffert): Compare timings against some target value.
106 } 109 }
107 110
108 // TCM ID - 7564762. 111 // TCM ID - 7564762.
109 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Update) { 112 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Update) {
110 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 113 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
111 DisableVerifier(); 114 DisableVerifier();
112 115
113 AddURLs(0, kNumBookmarks); 116 AddURLs(0, kNumBookmarks);
114 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 117 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
115 ASSERT_TRUE(AllModelsMatch()); 118 ASSERT_TRUE(BookmarksHelper::AllModelsMatch());
116 119
117 DisableNetwork(GetProfile(1)); 120 DisableNetwork(GetProfile(1));
118 UpdateURLs(0); 121 UpdateURLs(0);
119 base::TimeDelta dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0)); 122 base::TimeDelta dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0));
120 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count()); 123 ASSERT_EQ(kNumBookmarks, BookmarksHelper::GetBookmarkBarNode(0)->child_count() );
121 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(1)->child_count()); 124 ASSERT_EQ(kNumBookmarks, BookmarksHelper::GetBookmarkBarNode(1)->child_count() );
122 ASSERT_FALSE(AllModelsMatch()); 125 ASSERT_FALSE(BookmarksHelper::AllModelsMatch());
123 126
124 EnableNetwork(GetProfile(1)); 127 EnableNetwork(GetProfile(1));
125 base::TimeDelta dt_down = 128 base::TimeDelta dt_down =
126 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 129 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
127 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count()); 130 ASSERT_EQ(kNumBookmarks, BookmarksHelper::GetBookmarkBarNode(0)->child_count() );
128 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(1)->child_count()); 131 ASSERT_EQ(kNumBookmarks, BookmarksHelper::GetBookmarkBarNode(1)->child_count() );
129 132
130 // TODO(braffert): Compare timings against some target value. 133 // TODO(braffert): Compare timings against some target value.
131 } 134 }
132 135
133 // TCM ID - 7566626. 136 // TCM ID - 7566626.
134 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Delete) { 137 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Delete) {
135 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 138 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
136 DisableVerifier(); 139 DisableVerifier();
137 140
138 AddURLs(0, kNumBookmarks); 141 AddURLs(0, kNumBookmarks);
139 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 142 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
140 ASSERT_TRUE(AllModelsMatch()); 143 ASSERT_TRUE(BookmarksHelper::AllModelsMatch());
141 144
142 DisableNetwork(GetProfile(1)); 145 DisableNetwork(GetProfile(1));
143 RemoveURLs(0); 146 RemoveURLs(0);
144 base::TimeDelta dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0)); 147 base::TimeDelta dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0));
145 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count()); 148 ASSERT_EQ(0, BookmarksHelper::GetBookmarkBarNode(0)->child_count());
146 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(1)->child_count()); 149 ASSERT_EQ(kNumBookmarks, BookmarksHelper::GetBookmarkBarNode(1)->child_count() );
147 150
148 EnableNetwork(GetProfile(1)); 151 EnableNetwork(GetProfile(1));
149 base::TimeDelta dt_down = 152 base::TimeDelta dt_down =
150 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 153 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
151 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count()); 154 ASSERT_EQ(0, BookmarksHelper::GetBookmarkBarNode(0)->child_count());
152 ASSERT_EQ(0, GetBookmarkBarNode(1)->child_count()); 155 ASSERT_EQ(0, BookmarksHelper::GetBookmarkBarNode(1)->child_count());
153 156
154 // TODO(braffert): Compare timings against some target value. 157 // TODO(braffert): Compare timings against some target value.
155 } 158 }
156 159
157 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, DISABLED_Benchmark) { 160 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, DISABLED_Benchmark) {
158 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 161 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
159 DisableVerifier(); 162 DisableVerifier();
160 163
161 for (int i = 0; i < kNumBenchmarkPoints; ++i) { 164 for (int i = 0; i < kNumBenchmarkPoints; ++i) {
162 int num_bookmarks = kBenchmarkPoints[i]; 165 int num_bookmarks = kBenchmarkPoints[i];
163 166
164 // Disable client 1. Add bookmarks and time commit by client 0. 167 // Disable client 1. Add bookmarks and time commit by client 0.
165 DisableNetwork(GetProfile(1)); 168 DisableNetwork(GetProfile(1));
166 AddURLs(0, num_bookmarks); 169 AddURLs(0, num_bookmarks);
167 base::TimeDelta dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0)); 170 base::TimeDelta dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0));
168 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(0)->child_count()); 171 ASSERT_EQ(num_bookmarks, BookmarksHelper::GetBookmarkBarNode(0)->child_count ());
169 ASSERT_EQ(0, GetBookmarkBarNode(1)->child_count()); 172 ASSERT_EQ(0, BookmarksHelper::GetBookmarkBarNode(1)->child_count());
170 173
171 // Enable client 1 and time update (new bookmarks). 174 // Enable client 1 and time update (new bookmarks).
172 EnableNetwork(GetProfile(1)); 175 EnableNetwork(GetProfile(1));
173 base::TimeDelta dt_down = 176 base::TimeDelta dt_down =
174 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 177 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
175 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(0)->child_count()); 178 ASSERT_EQ(num_bookmarks, BookmarksHelper::GetBookmarkBarNode(0)->child_count ());
176 ASSERT_TRUE(AllModelsMatch()); 179 ASSERT_TRUE(BookmarksHelper::AllModelsMatch());
177 180
178 VLOG(0) << std::endl << "Add: " << num_bookmarks << " " 181 VLOG(0) << std::endl << "Add: " << num_bookmarks << " "
179 << dt_up.InSecondsF() << " " << dt_down.InSecondsF(); 182 << dt_up.InSecondsF() << " " << dt_down.InSecondsF();
180 183
181 // Disable client 1. Modify bookmarks and time commit by client 0. 184 // Disable client 1. Modify bookmarks and time commit by client 0.
182 DisableNetwork(GetProfile(1)); 185 DisableNetwork(GetProfile(1));
183 UpdateURLs(0); 186 UpdateURLs(0);
184 dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0)); 187 dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0));
185 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(0)->child_count()); 188 ASSERT_EQ(num_bookmarks, BookmarksHelper::GetBookmarkBarNode(0)->child_count ());
186 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(1)->child_count()); 189 ASSERT_EQ(num_bookmarks, BookmarksHelper::GetBookmarkBarNode(1)->child_count ());
187 ASSERT_FALSE(AllModelsMatch()); 190 ASSERT_FALSE(BookmarksHelper::AllModelsMatch());
188 191
189 // Enable client 1 and time update (changed bookmarks). 192 // Enable client 1 and time update (changed bookmarks).
190 EnableNetwork(GetProfile(1)); 193 EnableNetwork(GetProfile(1));
191 dt_down = 194 dt_down =
192 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 195 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
193 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(0)->child_count()); 196 ASSERT_EQ(num_bookmarks, BookmarksHelper::GetBookmarkBarNode(0)->child_count ());
194 ASSERT_TRUE(AllModelsMatch()); 197 ASSERT_TRUE(BookmarksHelper::AllModelsMatch());
195 198
196 VLOG(0) << std::endl << "Update: " << num_bookmarks << " " 199 VLOG(0) << std::endl << "Update: " << num_bookmarks << " "
197 << dt_up.InSecondsF() << " " << dt_down.InSecondsF(); 200 << dt_up.InSecondsF() << " " << dt_down.InSecondsF();
198 201
199 // Disable client 1. Delete bookmarks and time commit by client 0. 202 // Disable client 1. Delete bookmarks and time commit by client 0.
200 DisableNetwork(GetProfile(1)); 203 DisableNetwork(GetProfile(1));
201 RemoveURLs(0); 204 RemoveURLs(0);
202 dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0)); 205 dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0));
203 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count()); 206 ASSERT_EQ(0, BookmarksHelper::GetBookmarkBarNode(0)->child_count());
204 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(1)->child_count()); 207 ASSERT_EQ(num_bookmarks, BookmarksHelper::GetBookmarkBarNode(1)->child_count ());
205 208
206 // Enable client 1 and time update (deleted bookmarks). 209 // Enable client 1 and time update (deleted bookmarks).
207 EnableNetwork(GetProfile(1)); 210 EnableNetwork(GetProfile(1));
208 dt_down = 211 dt_down =
209 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 212 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
210 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count()); 213 ASSERT_EQ(0, BookmarksHelper::GetBookmarkBarNode(0)->child_count());
211 ASSERT_EQ(0, GetBookmarkBarNode(1)->child_count()); 214 ASSERT_EQ(0, BookmarksHelper::GetBookmarkBarNode(1)->child_count());
212 215
213 VLOG(0) << std::endl << "Delete: " << num_bookmarks << " " 216 VLOG(0) << std::endl << "Delete: " << num_bookmarks << " "
214 << dt_up.InSecondsF() << " " << dt_down.InSecondsF(); 217 << dt_up.InSecondsF() << " " << dt_down.InSecondsF();
215 218
216 Cleanup(); 219 Cleanup();
217 } 220 }
218 } 221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698