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..888de01f25ae61106697eba7cff7591d1d09bea7 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 WaitForTabsToLoad(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(); |
Raghu Simha
2011/08/05 21:26:07
How about: "Opening tab: " << it->spec() << " usin
braffert
2011/08/05 21:37:21
Done.
|
+ browser->ShowSingletonTab(*it); |
+ } |
+ return WaitForTabsToLoad(index, urls); |
+} |
+ |
+bool LiveSessionsSyncTest::WaitForTabsToLoad( |
+ 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; |
+ while (!found) { |
+ found = ModelAssociatorHasTabWithUrl(index, *it); |
Raghu Simha
2011/08/05 21:26:07
Curious: What if found becomes true at the last po
braffert
2011/08/05 21:37:21
I don't think it's anything to be concerned with.
Nicolas Zea
2011/08/05 21:40:41
There's nothing we can do about it turning true af
|
+ if (base::TimeTicks::Now() >= end_time) { |
+ LOG(ERROR) << "Failed to find all tabs after " << timeout_milli/1000.0 |
+ << " seconds."; |
+ return false; |
+ } |
+ if (!found) { |
+ GetProfile(index)->GetProfileSyncService()-> |
+ GetSessionModelAssociator()-> |
+ BlockUntilLocalChangeForTest(timeout_milli); |
+ ui_test_utils::RunMessageLoop(); |
+ } |
+ } |
+ } |
+ return true; |
} |
std::vector<SessionWindow*>* LiveSessionsSyncTest::GetLocalWindows(int index) { |