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

Unified 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: comment typos 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/live_sync/live_sessions_sync_test.cc
diff --git a/chrome/test/live_sync/live_sessions_sync_test.cc b/chrome/test/live_sync/live_sessions_sync_test.cc
index b72363fc41434a4403b8d16bce1713673e917782..e239d8e6c637d0b36b2592a40cd4ff31102d938a 100644
--- a/chrome/test/live_sync/live_sessions_sync_test.cc
+++ b/chrome/test/live_sync/live_sessions_sync_test.cc
@@ -89,27 +89,49 @@ bool LiveSessionsSyncTest::ModelAssociatorHasTabWithUrl(int index,
}
bool LiveSessionsSyncTest::OpenTab(int index, const GURL& url) {
- static const int timeout_milli = TestTimeouts::action_max_timeout_ms();
VLOG(1) << "Opening tab: " << url.spec();
GetBrowser(index)->ShowSingletonTab(url);
+ return AwaitSessionPropagation(index, std::vector<GURL>(1, url));
+}
+
+bool LiveSessionsSyncTest::OpenMultipleTabs(int index,
+ const std::vector<GURL>& urls) {
+ Browser* browser = GetBrowser(index);
+ for (std::vector<GURL>::const_iterator it = urls.begin();
+ it != urls.end(); ++it) {
+ VLOG(1) << "Opening tab: " << it->spec();
+ browser->ShowSingletonTab(*it);
+ }
+ return AwaitSessionPropagation(index, urls);
+}
+
+bool LiveSessionsSyncTest::AwaitSessionPropagation(
+ int index, const std::vector<GURL>& urls) {
VLOG(1) << "Waiting for session to propagate to associator.";
+ static const int timeout_milli = TestTimeouts::action_max_timeout_ms();
base::TimeTicks start_time = base::TimeTicks::Now();
base::TimeTicks end_time = start_time +
base::TimeDelta::FromMilliseconds(timeout_milli);
- do {
- if (ModelAssociatorHasTabWithUrl(index, url))
- return true;
- GetProfile(index)->GetProfileSyncService()->GetSessionModelAssociator()->
- BlockUntilLocalChangeForTest(timeout_milli);
- ui_test_utils::RunMessageLoop();
- } while (base::TimeTicks::Now() < end_time);
-
- if (ModelAssociatorHasTabWithUrl(index, url))
- return true;
-
- LOG(ERROR) << "Failed to find tab after " << timeout_milli/1000.0
- << " seconds.";
- return false;
+ bool found;
+ for (std::vector<GURL>::const_iterator it = urls.begin();
+ it != urls.end(); ++it) {
+ found = false;
braffert 2011/08/04 23:47:34 Using a flag here to avoid calling ModelAssociator
+ do {
+ if (base::TimeTicks::Now() >= end_time) {
+ LOG(ERROR) << "Failed to find all tabs after " << timeout_milli/1000.0
+ << " seconds.";
+ return false;
+ }
+ found = ModelAssociatorHasTabWithUrl(index, *it);
Nicolas Zea 2011/08/05 00:40:02 May as well put this before the timeout check.
braffert 2011/08/05 00:47:38 I'm not seeing why one way is better than the othe
+ if (!found) {
+ GetProfile(index)->GetProfileSyncService()->
+ GetSessionModelAssociator()->
+ BlockUntilLocalChangeForTest(timeout_milli);
+ ui_test_utils::RunMessageLoop();
+ }
+ } while (!found);
+ }
+ return true;
}
std::vector<SessionWindow*>* LiveSessionsSyncTest::GetLocalWindows(int index) {

Powered by Google App Engine
This is Rietveld 408576698