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

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: 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 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..f86165a93bea80dc28a26e261e68f593c054f669 100644
--- a/chrome/test/live_sync/live_sessions_sync_test.cc
+++ b/chrome/test/live_sync/live_sessions_sync_test.cc
@@ -89,27 +89,50 @@ 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();
+ VLOG(1) << "Opening tab: " << url.spec() << " using profile " << index << ".";
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() << " using profile " << index
+ << ".";
+ 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);
+ 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) {
« 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