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 "base/stringprintf.h" | 5 #include "base/stringprintf.h" |
6 #include "chrome/browser/ui/browser.h" | 6 #include "chrome/browser/ui/browser.h" |
7 #include "chrome/browser/sync/profile_sync_service_harness.h" | 7 #include "chrome/browser/sync/profile_sync_service_harness.h" |
8 #include "chrome/browser/sync/test/integration/performance/sync_timing_helper.h" | 8 #include "chrome/browser/sync/test/integration/performance/sync_timing_helper.h" |
9 #include "chrome/browser/sync/test/integration/sessions_helper.h" | 9 #include "chrome/browser/sync/test/integration/sessions_helper.h" |
10 #include "chrome/browser/sync/test/integration/sync_test.h" | 10 #include "chrome/browser/sync/test/integration/sync_test.h" |
11 | 11 |
12 using sessions_helper::GetLocalSession; | 12 using sessions_helper::GetLocalSession; |
13 using sessions_helper::GetSessionData; | 13 using sessions_helper::GetSessionData; |
14 using sessions_helper::OpenMultipleTabs; | 14 using sessions_helper::OpenMultipleTabs; |
| 15 using sessions_helper::SyncedSessionVector; |
| 16 using sessions_helper::SessionWindowMap; |
15 using sessions_helper::WaitForTabsToLoad; | 17 using sessions_helper::WaitForTabsToLoad; |
16 | 18 |
17 static const int kNumTabs = 150; | 19 static const int kNumTabs = 150; |
18 | 20 |
19 class SessionsSyncPerfTest: public SyncTest { | 21 class SessionsSyncPerfTest: public SyncTest { |
20 public: | 22 public: |
21 SessionsSyncPerfTest() : SyncTest(TWO_CLIENT), url_number_(0) {} | 23 SessionsSyncPerfTest() : SyncTest(TWO_CLIENT), url_number_(0) {} |
22 | 24 |
23 // Opens |num_tabs| new tabs on |profile|. | 25 // Opens |num_tabs| new tabs on |profile|. |
24 void AddTabs(int profile, int num_tabs); | 26 void AddTabs(int profile, int num_tabs); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 84 |
83 if (!GetSessionData(profile, &sessions)) { | 85 if (!GetSessionData(profile, &sessions)) { |
84 // Foreign session data may be empty. In this case we only count tabs in | 86 // Foreign session data may be empty. In this case we only count tabs in |
85 // the local session. | 87 // the local session. |
86 VLOG(1) << "GetSessionData returned false"; | 88 VLOG(1) << "GetSessionData returned false"; |
87 } | 89 } |
88 | 90 |
89 sessions.push_back(local_session); | 91 sessions.push_back(local_session); |
90 for (SyncedSessionVector::const_iterator it = sessions.begin(); | 92 for (SyncedSessionVector::const_iterator it = sessions.begin(); |
91 it != sessions.end(); ++it) { | 93 it != sessions.end(); ++it) { |
92 for (SessionWindowVector::const_iterator win_it = (*it)->windows.begin(); | 94 for (SessionWindowMap::const_iterator win_it = (*it)->windows.begin(); |
93 win_it != (*it)->windows.end(); | 95 win_it != (*it)->windows.end(); |
94 ++win_it) { | 96 ++win_it) { |
95 tab_count += (*win_it)->tabs.size(); | 97 tab_count += win_it->second->tabs.size(); |
96 } | 98 } |
97 } | 99 } |
98 return tab_count; | 100 return tab_count; |
99 } | 101 } |
100 | 102 |
101 GURL SessionsSyncPerfTest::NextURL() { | 103 GURL SessionsSyncPerfTest::NextURL() { |
102 return IntToURL(url_number_++); | 104 return IntToURL(url_number_++); |
103 } | 105 } |
104 | 106 |
105 GURL SessionsSyncPerfTest::IntToURL(int n) { | 107 GURL SessionsSyncPerfTest::IntToURL(int n) { |
(...skipping 17 matching lines...) Expand all Loading... |
123 ASSERT_EQ(kNumTabs, GetTabCount(1)); | 125 ASSERT_EQ(kNumTabs, GetTabCount(1)); |
124 SyncTimingHelper::PrintResult("tabs", "update_tabs", dt); | 126 SyncTimingHelper::PrintResult("tabs", "update_tabs", dt); |
125 | 127 |
126 RemoveTabs(0); | 128 RemoveTabs(0); |
127 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 129 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
128 // New tab page remains open on profile 0 after closing all tabs. | 130 // New tab page remains open on profile 0 after closing all tabs. |
129 ASSERT_EQ(1, GetTabCount(0)); | 131 ASSERT_EQ(1, GetTabCount(0)); |
130 ASSERT_EQ(0, GetTabCount(1)); | 132 ASSERT_EQ(0, GetTabCount(1)); |
131 SyncTimingHelper::PrintResult("tabs", "delete_tabs", dt); | 133 SyncTimingHelper::PrintResult("tabs", "delete_tabs", dt); |
132 } | 134 } |
OLD | NEW |