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

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

Issue 7575026: Session/tab sync performance tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more review suggestions Created 9 years, 4 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/test/live_sync/live_sessions_sync_test.h" 5 #include "chrome/test/live_sync/live_sessions_sync_test.h"
6 6
7 #include "base/test/test_timeouts.h" 7 #include "base/test/test_timeouts.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sync/profile_sync_service.h" 10 #include "chrome/browser/sync/profile_sync_service.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 return true; 83 return true;
84 } 84 }
85 } 85 }
86 } 86 }
87 VLOG(1) << "Could not find tab with url " << url.spec(); 87 VLOG(1) << "Could not find tab with url " << url.spec();
88 return false; 88 return false;
89 } 89 }
90 90
91 bool LiveSessionsSyncTest::OpenTab(int index, const GURL& url) { 91 bool LiveSessionsSyncTest::OpenTab(int index, const GURL& url) {
92 VLOG(1) << "Opening tab: " << url.spec() << " using profile " << index << ".";
93 GetBrowser(index)->ShowSingletonTab(url);
94 return WaitForTabsToLoad(index, std::vector<GURL>(1, url));
95 }
96
97 bool LiveSessionsSyncTest::OpenMultipleTabs(int index,
98 const std::vector<GURL>& urls) {
99 Browser* browser = GetBrowser(index);
100 for (std::vector<GURL>::const_iterator it = urls.begin();
101 it != urls.end(); ++it) {
102 VLOG(1) << "Opening tab: " << it->spec() << " using profile " << index
103 << ".";
104 browser->ShowSingletonTab(*it);
105 }
106 return WaitForTabsToLoad(index, urls);
107 }
108
109 bool LiveSessionsSyncTest::WaitForTabsToLoad(
110 int index, const std::vector<GURL>& urls) {
111 VLOG(1) << "Waiting for session to propagate to associator.";
92 static const int timeout_milli = TestTimeouts::action_max_timeout_ms(); 112 static const int timeout_milli = TestTimeouts::action_max_timeout_ms();
93 VLOG(1) << "Opening tab: " << url.spec();
94 GetBrowser(index)->ShowSingletonTab(url);
95 VLOG(1) << "Waiting for session to propagate to associator.";
96 base::TimeTicks start_time = base::TimeTicks::Now(); 113 base::TimeTicks start_time = base::TimeTicks::Now();
97 base::TimeTicks end_time = start_time + 114 base::TimeTicks end_time = start_time +
98 base::TimeDelta::FromMilliseconds(timeout_milli); 115 base::TimeDelta::FromMilliseconds(timeout_milli);
99 do { 116 bool found;
100 if (ModelAssociatorHasTabWithUrl(index, url)) 117 for (std::vector<GURL>::const_iterator it = urls.begin();
101 return true; 118 it != urls.end(); ++it) {
102 GetProfile(index)->GetProfileSyncService()->GetSessionModelAssociator()-> 119 found = false;
103 BlockUntilLocalChangeForTest(timeout_milli); 120 while (!found) {
104 ui_test_utils::RunMessageLoop(); 121 found = ModelAssociatorHasTabWithUrl(index, *it);
105 } while (base::TimeTicks::Now() < end_time); 122 if (base::TimeTicks::Now() >= end_time) {
106 123 LOG(ERROR) << "Failed to find all tabs after " << timeout_milli/1000.0
107 if (ModelAssociatorHasTabWithUrl(index, url)) 124 << " seconds.";
108 return true; 125 return false;
109 126 }
110 LOG(ERROR) << "Failed to find tab after " << timeout_milli/1000.0 127 if (!found) {
111 << " seconds."; 128 GetProfile(index)->GetProfileSyncService()->
112 return false; 129 GetSessionModelAssociator()->
130 BlockUntilLocalChangeForTest(timeout_milli);
131 ui_test_utils::RunMessageLoop();
132 }
133 }
134 }
135 return true;
113 } 136 }
114 137
115 std::vector<SessionWindow*>* LiveSessionsSyncTest::GetLocalWindows(int index) { 138 std::vector<SessionWindow*>* LiveSessionsSyncTest::GetLocalWindows(int index) {
116 // The local session provided by GetLocalSession is owned, and has lifetime 139 // The local session provided by GetLocalSession is owned, and has lifetime
117 // controlled, by the model associator, so we must make our own copy. 140 // controlled, by the model associator, so we must make our own copy.
118 const SyncedSession* local_session; 141 const SyncedSession* local_session;
119 if (!GetLocalSession(index, &local_session)) { 142 if (!GetLocalSession(index, &local_session)) {
120 return NULL; 143 return NULL;
121 } 144 }
122 scoped_ptr<SyncedSession> session_copy(new SyncedSession()); 145 scoped_ptr<SyncedSession> session_copy(new SyncedSession());
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // sync profile. 327 // sync profile.
305 BrowserList::CloseAllBrowsers(); 328 BrowserList::CloseAllBrowsers();
306 ui_test_utils::RunAllPendingInMessageLoop(); 329 ui_test_utils::RunAllPendingInMessageLoop();
307 330
308 // All browsers should be closed at this point, else when the framework 331 // All browsers should be closed at this point, else when the framework
309 // calls QuitBrowsers() we could see memory corruption. 332 // calls QuitBrowsers() we could see memory corruption.
310 ASSERT_EQ(0U, BrowserList::size()); 333 ASSERT_EQ(0U, BrowserList::size());
311 334
312 LiveSyncTest::CleanUpOnMainThread(); 335 LiveSyncTest::CleanUpOnMainThread();
313 } 336 }
OLDNEW
« no previous file with comments | « chrome/test/live_sync/live_sessions_sync_test.h ('k') | chrome/test/live_sync/performance/sessions_sync_perf_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698