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

Unified Diff: chrome/test/live_sync/live_sessions_sync_test.cc

Issue 7562020: Sessions sync integration tests: check all windows and tabs when searching for a URL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: typos Created 9 years, 5 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
« no previous file with comments | « chrome/test/live_sync/live_sessions_sync_test.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 abc8f1682290123b576a7dcaf6b1f822f77c6a6b..b72363fc41434a4403b8d16bce1713673e917782 100644
--- a/chrome/test/live_sync/live_sessions_sync_test.cc
+++ b/chrome/test/live_sync/live_sessions_sync_test.cc
@@ -38,35 +38,54 @@ bool LiveSessionsSyncTest::SetupClients() {
return true;
}
+bool LiveSessionsSyncTest::GetLocalSession(int index,
+ const SyncedSession** session) {
+ return GetProfile(index)->GetProfileSyncService()->
+ GetSessionModelAssociator()->GetLocalSession(session);
+}
+
bool LiveSessionsSyncTest::ModelAssociatorHasTabWithUrl(int index,
const GURL& url) {
ui_test_utils::RunAllPendingInMessageLoop();
const SyncedSession* local_session;
- if (!GetProfile(index)->GetProfileSyncService()->
- GetSessionModelAssociator()->GetLocalSession(&local_session)) {
- return false;
- }
- if (local_session->windows.size() == 0 ||
- local_session->windows[0]->tabs.size() == 0 ||
- local_session->windows[0]->tabs[0]->navigations.size() == 0) {
- VLOG(1) << "Bad vectors!";
+ if (!GetLocalSession(index, &local_session)) {
return false;
}
- int nav_index =
- local_session->windows[0]->tabs[0]->current_navigation_index;
- TabNavigation nav =
- local_session->windows[0]->tabs[0]->navigations[nav_index];
- if (nav.virtual_url() != url) {
- VLOG(1) << "Bad url!";
+ if (local_session->windows.size() == 0) {
+ VLOG(1) << "Empty windows vector";
return false;
}
- if (nav.title().empty()) {
- VLOG(1) << "No title!";
- return false;
+
+ int nav_index;
+ TabNavigation nav;
+ for (std::vector<SessionWindow*>::const_iterator it =
+ local_session->windows.begin(); it != local_session->windows.end();
+ ++it) {
+ if ((*it)->tabs.size() == 0) {
+ VLOG(1) << "Empty tabs vector";
+ continue;
+ }
+ for (std::vector<SessionTab*>::const_iterator tab_it =
+ (*it)->tabs.begin(); tab_it != (*it)->tabs.end(); ++tab_it) {
+ if ((*tab_it)->navigations.size() == 0) {
+ VLOG(1) << "Empty navigations vector";
+ continue;
+ }
+ nav_index = (*tab_it)->current_navigation_index;
+ nav = (*tab_it)->navigations[nav_index];
+ if (nav.virtual_url() == url) {
+ VLOG(1) << "Found tab with url " << url.spec();
+ if (nav.title().empty()) {
+ VLOG(1) << "No title!";
+ continue;
+ }
+ return true;
+ }
+ }
}
- VLOG(1) << "Found tab with url " << url.spec();
- return true;
+ VLOG(1) << "Could not find tab with url " << url.spec();
+ return false;
}
bool LiveSessionsSyncTest::OpenTab(int index, const GURL& url) {
@@ -97,8 +116,7 @@ std::vector<SessionWindow*>* LiveSessionsSyncTest::GetLocalWindows(int index) {
// The local session provided by GetLocalSession is owned, and has lifetime
// controlled, by the model associator, so we must make our own copy.
const SyncedSession* local_session;
- if (!GetProfile(index)->GetProfileSyncService()->GetSessionModelAssociator()->
- GetLocalSession(&local_session)) {
+ if (!GetLocalSession(index, &local_session)) {
return NULL;
}
scoped_ptr<SyncedSession> session_copy(new SyncedSession());
@@ -142,8 +160,7 @@ bool LiveSessionsSyncTest::CheckInitialState(int index) {
int LiveSessionsSyncTest::GetNumWindows(int index) {
const SyncedSession* local_session;
- if (!GetProfile(index)->GetProfileSyncService()->GetSessionModelAssociator()->
- GetLocalSession(&local_session)) {
+ if (!GetLocalSession(index, &local_session)) {
return 0;
}
return local_session->windows.size();
« no previous file with comments | « chrome/test/live_sync/live_sessions_sync_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698