BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / sync / test / integration / performance / bookmarks_sync_perf_test.cc
bloba6bf1b1707873dc0a9b6f1f5a8ad80ab3cf518ef
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.
5 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
6 #include "chrome/browser/sync/test/integration/performance/sync_timing_helper.h"
7 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
8 #include "chrome/browser/sync/test/integration/sync_test.h"
9 #include "components/bookmarks/browser/bookmark_node.h"
11 using bookmarks_helper::AddURL;
12 using bookmarks_helper::AllModelsMatch;
13 using bookmarks_helper::GetBookmarkBarNode;
14 using bookmarks_helper::IndexedURL;
15 using bookmarks_helper::IndexedURLTitle;
16 using bookmarks_helper::Remove;
17 using bookmarks_helper::SetURL;
19 static const int kNumBookmarks = 150;
21 class BookmarksSyncPerfTest : public SyncTest {
22 public:
23 BookmarksSyncPerfTest()
24 : SyncTest(TWO_CLIENT),
25 url_number_(0),
26 url_title_number_(0) {}
28 // Adds |num_urls| new unique bookmarks to the bookmark bar for |profile|.
29 void AddURLs(int profile, int num_urls);
31 // Updates the URL for all bookmarks in the bookmark bar for |profile|.
32 void UpdateURLs(int profile);
34 // Removes all bookmarks in the bookmark bar for |profile|.
35 void RemoveURLs(int profile);
37 // Returns the number of bookmarks stored in the bookmark bar for |profile|.
38 int GetURLCount(int profile);
40 private:
41 // Returns a new unique bookmark URL.
42 std::string NextIndexedURL();
44 // Returns a new unique bookmark title.
45 std::string NextIndexedURLTitle();
47 int url_number_;
48 int url_title_number_;
49 DISALLOW_COPY_AND_ASSIGN(BookmarksSyncPerfTest);
52 void BookmarksSyncPerfTest::AddURLs(int profile, int num_urls) {
53 for (int i = 0; i < num_urls; ++i) {
54 ASSERT_TRUE(AddURL(
55 profile, 0, NextIndexedURLTitle(), GURL(NextIndexedURL())) != NULL);
59 void BookmarksSyncPerfTest::UpdateURLs(int profile) {
60 for (int i = 0;
61 i < GetBookmarkBarNode(profile)->child_count();
62 ++i) {
63 ASSERT_TRUE(SetURL(profile,
64 GetBookmarkBarNode(profile)->GetChild(i),
65 GURL(NextIndexedURL())));
69 void BookmarksSyncPerfTest::RemoveURLs(int profile) {
70 while (!GetBookmarkBarNode(profile)->empty()) {
71 Remove(profile, GetBookmarkBarNode(profile), 0);
75 int BookmarksSyncPerfTest::GetURLCount(int profile) {
76 return GetBookmarkBarNode(profile)->child_count();
79 std::string BookmarksSyncPerfTest::NextIndexedURL() {
80 return IndexedURL(url_number_++);
83 std::string BookmarksSyncPerfTest::NextIndexedURLTitle() {
84 return IndexedURLTitle(url_title_number_++);
87 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, P0) {
88 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
90 // TCM ID - 7556828.
91 AddURLs(0, kNumBookmarks);
92 base::TimeDelta dt =
93 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
94 ASSERT_EQ(kNumBookmarks, GetURLCount(1));
95 SyncTimingHelper::PrintResult("bookmarks", "add_bookmarks", dt);
97 // TCM ID - 7564762.
98 UpdateURLs(0);
99 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
100 ASSERT_EQ(kNumBookmarks, GetURLCount(1));
101 SyncTimingHelper::PrintResult("bookmarks", "update_bookmarks", dt);
103 // TCM ID - 7566626.
104 RemoveURLs(0);
105 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
106 ASSERT_EQ(0, GetURLCount(1));
107 SyncTimingHelper::PrintResult("bookmarks", "delete_bookmarks", dt);