OLD | NEW |
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/test/integration/bookmarks_helper.h" | 5 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
6 #include "chrome/browser/sync/test/integration/performance/sync_timing_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" | 7 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
8 #include "chrome/browser/sync/test/integration/sync_test.h" | 8 #include "chrome/browser/sync/test/integration/sync_test.h" |
9 | 9 |
10 using bookmarks_helper::AddURL; | 10 using bookmarks_helper::AddURL; |
(...skipping 23 matching lines...) Expand all Loading... |
34 void RemoveURLs(int profile); | 34 void RemoveURLs(int profile); |
35 | 35 |
36 // Returns the number of bookmarks stored in the bookmark bar for |profile|. | 36 // Returns the number of bookmarks stored in the bookmark bar for |profile|. |
37 int GetURLCount(int profile); | 37 int GetURLCount(int profile); |
38 | 38 |
39 private: | 39 private: |
40 // Returns a new unique bookmark URL. | 40 // Returns a new unique bookmark URL. |
41 std::string NextIndexedURL(); | 41 std::string NextIndexedURL(); |
42 | 42 |
43 // Returns a new unique bookmark title. | 43 // Returns a new unique bookmark title. |
44 std::wstring NextIndexedURLTitle(); | 44 std::string NextIndexedURLTitle(); |
45 | 45 |
46 int url_number_; | 46 int url_number_; |
47 int url_title_number_; | 47 int url_title_number_; |
48 DISALLOW_COPY_AND_ASSIGN(BookmarksSyncPerfTest); | 48 DISALLOW_COPY_AND_ASSIGN(BookmarksSyncPerfTest); |
49 }; | 49 }; |
50 | 50 |
51 void BookmarksSyncPerfTest::AddURLs(int profile, int num_urls) { | 51 void BookmarksSyncPerfTest::AddURLs(int profile, int num_urls) { |
52 for (int i = 0; i < num_urls; ++i) { | 52 for (int i = 0; i < num_urls; ++i) { |
53 ASSERT_TRUE(AddURL( | 53 ASSERT_TRUE(AddURL( |
54 profile, 0, NextIndexedURLTitle(), GURL(NextIndexedURL())) != NULL); | 54 profile, 0, NextIndexedURLTitle(), GURL(NextIndexedURL())) != NULL); |
(...skipping 17 matching lines...) Expand all Loading... |
72 } | 72 } |
73 | 73 |
74 int BookmarksSyncPerfTest::GetURLCount(int profile) { | 74 int BookmarksSyncPerfTest::GetURLCount(int profile) { |
75 return GetBookmarkBarNode(profile)->child_count(); | 75 return GetBookmarkBarNode(profile)->child_count(); |
76 } | 76 } |
77 | 77 |
78 std::string BookmarksSyncPerfTest::NextIndexedURL() { | 78 std::string BookmarksSyncPerfTest::NextIndexedURL() { |
79 return IndexedURL(url_number_++); | 79 return IndexedURL(url_number_++); |
80 } | 80 } |
81 | 81 |
82 std::wstring BookmarksSyncPerfTest::NextIndexedURLTitle() { | 82 std::string BookmarksSyncPerfTest::NextIndexedURLTitle() { |
83 return IndexedURLTitle(url_title_number_++); | 83 return IndexedURLTitle(url_title_number_++); |
84 } | 84 } |
85 | 85 |
86 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, P0) { | 86 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, P0) { |
87 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 87 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
88 | 88 |
89 // TCM ID - 7556828. | 89 // TCM ID - 7556828. |
90 AddURLs(0, kNumBookmarks); | 90 AddURLs(0, kNumBookmarks); |
91 base::TimeDelta dt = | 91 base::TimeDelta dt = |
92 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 92 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
93 ASSERT_EQ(kNumBookmarks, GetURLCount(1)); | 93 ASSERT_EQ(kNumBookmarks, GetURLCount(1)); |
94 SyncTimingHelper::PrintResult("bookmarks", "add_bookmarks", dt); | 94 SyncTimingHelper::PrintResult("bookmarks", "add_bookmarks", dt); |
95 | 95 |
96 // TCM ID - 7564762. | 96 // TCM ID - 7564762. |
97 UpdateURLs(0); | 97 UpdateURLs(0); |
98 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 98 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
99 ASSERT_EQ(kNumBookmarks, GetURLCount(1)); | 99 ASSERT_EQ(kNumBookmarks, GetURLCount(1)); |
100 SyncTimingHelper::PrintResult("bookmarks", "update_bookmarks", dt); | 100 SyncTimingHelper::PrintResult("bookmarks", "update_bookmarks", dt); |
101 | 101 |
102 // TCM ID - 7566626. | 102 // TCM ID - 7566626. |
103 RemoveURLs(0); | 103 RemoveURLs(0); |
104 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 104 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
105 ASSERT_EQ(0, GetURLCount(1)); | 105 ASSERT_EQ(0, GetURLCount(1)); |
106 SyncTimingHelper::PrintResult("bookmarks", "delete_bookmarks", dt); | 106 SyncTimingHelper::PrintResult("bookmarks", "delete_bookmarks", dt); |
107 } | 107 } |
OLD | NEW |