OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/sync/test/integration/sessions_helper.h" | 5 #include "chrome/browser/sync/test/integration/sessions_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 if (local_session->windows.size() == 0) { | 62 if (local_session->windows.size() == 0) { |
63 DVLOG(1) << "Empty windows vector"; | 63 DVLOG(1) << "Empty windows vector"; |
64 return false; | 64 return false; |
65 } | 65 } |
66 | 66 |
67 int nav_index; | 67 int nav_index; |
68 sessions::SerializedNavigationEntry nav; | 68 sessions::SerializedNavigationEntry nav; |
69 for (auto it = local_session->windows.begin(); | 69 for (auto it = local_session->windows.begin(); |
70 it != local_session->windows.end(); ++it) { | 70 it != local_session->windows.end(); ++it) { |
71 if (it->second->tabs.size() == 0) { | 71 if (it->second->wrapped_window.tabs.size() == 0) { |
72 DVLOG(1) << "Empty tabs vector"; | 72 DVLOG(1) << "Empty tabs vector"; |
73 continue; | 73 continue; |
74 } | 74 } |
75 for (auto tab_it = it->second->tabs.begin(); | 75 for (auto tab_it = it->second->wrapped_window.tabs.begin(); |
76 tab_it != it->second->tabs.end(); ++tab_it) { | 76 tab_it != it->second->wrapped_window.tabs.end(); ++tab_it) { |
77 if ((*tab_it)->navigations.size() == 0) { | 77 if ((*tab_it)->navigations.size() == 0) { |
78 DVLOG(1) << "Empty navigations vector"; | 78 DVLOG(1) << "Empty navigations vector"; |
79 continue; | 79 continue; |
80 } | 80 } |
81 nav_index = (*tab_it)->current_navigation_index; | 81 nav_index = (*tab_it)->current_navigation_index; |
82 nav = (*tab_it)->navigations[nav_index]; | 82 nav = (*tab_it)->navigations[nav_index]; |
83 if (nav.virtual_url() == url) { | 83 if (nav.virtual_url() == url) { |
84 DVLOG(1) << "Found tab with url " << url.spec(); | 84 DVLOG(1) << "Found tab with url " << url.spec(); |
85 DVLOG(1) << "Timestamp is " << nav.timestamp().ToInternalValue(); | 85 DVLOG(1) << "Timestamp is " << nav.timestamp().ToInternalValue(); |
86 if (nav.title().empty()) { | 86 if (nav.title().empty()) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 bool GetLocalWindows(int index, ScopedWindowMap* local_windows) { | 224 bool GetLocalWindows(int index, ScopedWindowMap* local_windows) { |
225 // The local session provided by GetLocalSession is owned, and has lifetime | 225 // The local session provided by GetLocalSession is owned, and has lifetime |
226 // controlled, by the sessions sync manager, so we must make our own copy. | 226 // controlled, by the sessions sync manager, so we must make our own copy. |
227 const sync_sessions::SyncedSession* local_session; | 227 const sync_sessions::SyncedSession* local_session; |
228 if (!GetLocalSession(index, &local_session)) { | 228 if (!GetLocalSession(index, &local_session)) { |
229 return false; | 229 return false; |
230 } | 230 } |
231 for (auto w = local_session->windows.begin(); | 231 for (auto w = local_session->windows.begin(); |
232 w != local_session->windows.end(); ++w) { | 232 w != local_session->windows.end(); ++w) { |
233 const sessions::SessionWindow& window = *(w->second); | 233 const sessions::SessionWindow& window = w->second->wrapped_window; |
234 std::unique_ptr<sessions::SessionWindow> new_window = | 234 std::unique_ptr<sync_sessions::SyncedSessionWindow> new_window = |
235 base::MakeUnique<sessions::SessionWindow>(); | 235 base::MakeUnique<sync_sessions::SyncedSessionWindow>(); |
236 new_window->window_id.set_id(window.window_id.id()); | 236 new_window->wrapped_window.window_id.set_id(window.window_id.id()); |
237 for (size_t t = 0; t < window.tabs.size(); ++t) { | 237 for (size_t t = 0; t < window.tabs.size(); ++t) { |
238 const sessions::SessionTab& tab = *window.tabs.at(t); | 238 const sessions::SessionTab& tab = *window.tabs.at(t); |
239 std::unique_ptr<sessions::SessionTab> new_tab = | 239 std::unique_ptr<sessions::SessionTab> new_tab = |
240 base::MakeUnique<sessions::SessionTab>(); | 240 base::MakeUnique<sessions::SessionTab>(); |
241 new_tab->navigations.resize(tab.navigations.size()); | 241 new_tab->navigations.resize(tab.navigations.size()); |
242 std::copy(tab.navigations.begin(), tab.navigations.end(), | 242 std::copy(tab.navigations.begin(), tab.navigations.end(), |
243 new_tab->navigations.begin()); | 243 new_tab->navigations.begin()); |
244 new_window->tabs.push_back(std::move(new_tab)); | 244 new_window->wrapped_window.tabs.push_back(std::move(new_tab)); |
245 } | 245 } |
246 auto id = new_window->window_id.id(); | 246 auto id = new_window->wrapped_window.window_id.id(); |
247 (*local_windows)[id] = std::move(new_window); | 247 (*local_windows)[id] = std::move(new_window); |
248 } | 248 } |
249 | 249 |
250 return true; | 250 return true; |
251 } | 251 } |
252 | 252 |
253 bool CheckInitialState(int index) { | 253 bool CheckInitialState(int index) { |
254 if (0 != GetNumWindows(index)) | 254 if (0 != GetNumWindows(index)) |
255 return false; | 255 return false; |
256 if (0 != GetNumForeignSessions(index)) | 256 if (0 != GetNumForeignSessions(index)) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 << ", win2 size: " | 348 << ", win2 size: " |
349 << win2.size(); | 349 << win2.size(); |
350 return false; | 350 return false; |
351 } | 351 } |
352 for (auto i = win1.begin(); i != win1.end(); ++i) { | 352 for (auto i = win1.begin(); i != win1.end(); ++i) { |
353 auto j = win2.find(i->first); | 353 auto j = win2.find(i->first); |
354 if (j == win2.end()) { | 354 if (j == win2.end()) { |
355 LOG(ERROR) << "Session doesn't match"; | 355 LOG(ERROR) << "Session doesn't match"; |
356 return false; | 356 return false; |
357 } | 357 } |
358 if (i->second->tabs.size() != j->second->tabs.size()) { | 358 if (i->second->wrapped_window.tabs.size() != |
| 359 j->second->wrapped_window.tabs.size()) { |
359 LOG(ERROR) << "Tab size doesn't match, tab1 size: " | 360 LOG(ERROR) << "Tab size doesn't match, tab1 size: " |
360 << i->second->tabs.size() | 361 << i->second->wrapped_window.tabs.size() |
361 << ", tab2 size: " | 362 << ", tab2 size: " << j->second->wrapped_window.tabs.size(); |
362 << j->second->tabs.size(); | |
363 return false; | 363 return false; |
364 } | 364 } |
365 for (size_t t = 0; t < i->second->tabs.size(); ++t) { | 365 for (size_t t = 0; t < i->second->wrapped_window.tabs.size(); ++t) { |
366 client0_tab = i->second->tabs[t].get(); | 366 client0_tab = i->second->wrapped_window.tabs[t].get(); |
367 client1_tab = j->second->tabs[t].get(); | 367 client1_tab = j->second->wrapped_window.tabs[t].get(); |
368 for (size_t n = 0; n < client0_tab->navigations.size(); ++n) { | 368 for (size_t n = 0; n < client0_tab->navigations.size(); ++n) { |
369 if (!NavigationEquals(client0_tab->navigations[n], | 369 if (!NavigationEquals(client0_tab->navigations[n], |
370 client1_tab->navigations[n])) { | 370 client1_tab->navigations[n])) { |
371 return false; | 371 return false; |
372 } | 372 } |
373 } | 373 } |
374 } | 374 } |
375 } | 375 } |
376 | 376 |
377 return true; | 377 return true; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 index_(index), | 435 index_(index), |
436 windows_(windows) {} | 436 windows_(windows) {} |
437 | 437 |
438 bool ForeignSessionsMatchChecker::IsExitConditionSatisfied() { | 438 bool ForeignSessionsMatchChecker::IsExitConditionSatisfied() { |
439 return sessions_helper::CheckForeignSessionsAgainst(index_, windows_); | 439 return sessions_helper::CheckForeignSessionsAgainst(index_, windows_); |
440 } | 440 } |
441 | 441 |
442 std::string ForeignSessionsMatchChecker::GetDebugMessage() const { | 442 std::string ForeignSessionsMatchChecker::GetDebugMessage() const { |
443 return "Waiting for matching foreign sessions"; | 443 return "Waiting for matching foreign sessions"; |
444 } | 444 } |
OLD | NEW |