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

Side by Side Diff: chrome/browser/sync/test/integration/sessions_helper.cc

Issue 14497003: Moves TabNavigation into components/sessions and renames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Really remove webkit_support Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/sessions/session_types_test_helper.h"
14 #include "chrome/browser/sync/glue/session_model_associator.h" 13 #include "chrome/browser/sync/glue/session_model_associator.h"
15 #include "chrome/browser/sync/profile_sync_service.h" 14 #include "chrome/browser/sync/profile_sync_service.h"
16 #include "chrome/browser/sync/profile_sync_service_factory.h" 15 #include "chrome/browser/sync/profile_sync_service_factory.h"
17 #include "chrome/browser/sync/profile_sync_service_harness.h" 16 #include "chrome/browser/sync/profile_sync_service_harness.h"
18 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 17 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
19 #include "chrome/browser/sync/test/integration/sync_test.h" 18 #include "chrome/browser/sync/test/integration/sync_test.h"
20 #include "chrome/browser/ui/singleton_tabs.h" 19 #include "chrome/browser/ui/singleton_tabs.h"
21 #include "chrome/test/base/ui_test_utils.h" 20 #include "chrome/test/base/ui_test_utils.h"
22 #include "googleurl/src/gurl.h" 21 #include "googleurl/src/gurl.h"
23 22
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 if (!GetLocalSession(index, &local_session)) { 61 if (!GetLocalSession(index, &local_session)) {
63 return false; 62 return false;
64 } 63 }
65 64
66 if (local_session->windows.size() == 0) { 65 if (local_session->windows.size() == 0) {
67 DVLOG(1) << "Empty windows vector"; 66 DVLOG(1) << "Empty windows vector";
68 return false; 67 return false;
69 } 68 }
70 69
71 int nav_index; 70 int nav_index;
72 TabNavigation nav; 71 sessions::SerializedNavigationEntry nav;
73 for (SessionWindowMap::const_iterator it = 72 for (SessionWindowMap::const_iterator it =
74 local_session->windows.begin(); 73 local_session->windows.begin();
75 it != local_session->windows.end(); ++it) { 74 it != local_session->windows.end(); ++it) {
76 if (it->second->tabs.size() == 0) { 75 if (it->second->tabs.size() == 0) {
77 DVLOG(1) << "Empty tabs vector"; 76 DVLOG(1) << "Empty tabs vector";
78 continue; 77 continue;
79 } 78 }
80 for (std::vector<SessionTab*>::const_iterator tab_it = 79 for (std::vector<SessionTab*>::const_iterator tab_it =
81 it->second->tabs.begin(); 80 it->second->tabs.begin();
82 tab_it != it->second->tabs.end(); ++tab_it) { 81 tab_it != it->second->tabs.end(); ++tab_it) {
83 if ((*tab_it)->navigations.size() == 0) { 82 if ((*tab_it)->navigations.size() == 0) {
84 DVLOG(1) << "Empty navigations vector"; 83 DVLOG(1) << "Empty navigations vector";
85 continue; 84 continue;
86 } 85 }
87 nav_index = (*tab_it)->current_navigation_index; 86 nav_index = (*tab_it)->current_navigation_index;
88 nav = (*tab_it)->navigations[nav_index]; 87 nav = (*tab_it)->navigations[nav_index];
89 if (nav.virtual_url() == url) { 88 if (nav.virtual_url() == url) {
90 DVLOG(1) << "Found tab with url " << url.spec(); 89 DVLOG(1) << "Found tab with url " << url.spec();
91 DVLOG(1) << "Timestamp is " 90 DVLOG(1) << "Timestamp is " << nav.timestamp().ToInternalValue();
92 << SessionTypesTestHelper::GetTimestamp(nav).ToInternalValue();
93 if (nav.title().empty()) { 91 if (nav.title().empty()) {
94 DVLOG(1) << "Title empty -- tab hasn't finished loading yet"; 92 DVLOG(1) << "Title empty -- tab hasn't finished loading yet";
95 continue; 93 continue;
96 } 94 }
97 return true; 95 return true;
98 } 96 }
99 } 97 }
100 } 98 }
101 DVLOG(1) << "Could not find tab with url " << url.spec(); 99 DVLOG(1) << "Could not find tab with url " << url.spec();
102 return false; 100 return false;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 225 }
228 226
229 return lhs->windows < rhs->windows; 227 return lhs->windows < rhs->windows;
230 } 228 }
231 229
232 void SortSyncedSessions(SyncedSessionVector* sessions) { 230 void SortSyncedSessions(SyncedSessionVector* sessions) {
233 std::sort(sessions->begin(), sessions->end(), 231 std::sort(sessions->begin(), sessions->end(),
234 CompareSyncedSessions); 232 CompareSyncedSessions);
235 } 233 }
236 234
237 bool NavigationEquals(const TabNavigation& expected, 235 bool NavigationEquals(const sessions::SerializedNavigationEntry& expected,
238 const TabNavigation& actual) { 236 const sessions::SerializedNavigationEntry& actual) {
239 if (expected.virtual_url() != actual.virtual_url()) { 237 if (expected.virtual_url() != actual.virtual_url()) {
240 LOG(ERROR) << "Expected url " << expected.virtual_url() 238 LOG(ERROR) << "Expected url " << expected.virtual_url()
241 << ", actual " << actual.virtual_url(); 239 << ", actual " << actual.virtual_url();
242 return false; 240 return false;
243 } 241 }
244 if (SessionTypesTestHelper::GetReferrer(expected).url != 242 if (expected.referrer().url != actual.referrer().url) {
245 SessionTypesTestHelper::GetReferrer(actual).url) {
246 LOG(ERROR) << "Expected referrer " 243 LOG(ERROR) << "Expected referrer "
247 << SessionTypesTestHelper::GetReferrer(expected).url 244 << expected.referrer().url
248 << ", actual " 245 << ", actual "
249 << SessionTypesTestHelper::GetReferrer(actual).url; 246 << actual.referrer().url;
250 return false; 247 return false;
251 } 248 }
252 if (expected.title() != actual.title()) { 249 if (expected.title() != actual.title()) {
253 LOG(ERROR) << "Expected title " << expected.title() 250 LOG(ERROR) << "Expected title " << expected.title()
254 << ", actual " << actual.title(); 251 << ", actual " << actual.title();
255 return false; 252 return false;
256 } 253 }
257 if (SessionTypesTestHelper::GetTransitionType(expected) != 254 if (expected.transition_type() != actual.transition_type()) {
258 SessionTypesTestHelper::GetTransitionType(actual)) {
259 LOG(ERROR) << "Expected transition " 255 LOG(ERROR) << "Expected transition "
260 << SessionTypesTestHelper::GetTransitionType(expected) 256 << expected.transition_type()
261 << ", actual " 257 << ", actual "
262 << SessionTypesTestHelper::GetTransitionType(actual); 258 << actual.transition_type();
263 return false; 259 return false;
264 } 260 }
265 return true; 261 return true;
266 } 262 }
267 263
268 bool WindowsMatch(const SessionWindowMap& win1, 264 bool WindowsMatch(const SessionWindowMap& win1,
269 const SessionWindowMap& win2) { 265 const SessionWindowMap& win2) {
270 SessionTab* client0_tab; 266 SessionTab* client0_tab;
271 SessionTab* client1_tab; 267 SessionTab* client1_tab;
272 if (win1.size() != win2.size()) 268 if (win1.size() != win2.size())
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 return true; 310 return true;
315 } 311 }
316 312
317 void DeleteForeignSession(int index, std::string session_tag) { 313 void DeleteForeignSession(int index, std::string session_tag) {
318 ProfileSyncServiceFactory::GetInstance()->GetForProfile( 314 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
319 test()->GetProfile(index))-> 315 test()->GetProfile(index))->
320 GetSessionModelAssociator()->DeleteForeignSession(session_tag); 316 GetSessionModelAssociator()->DeleteForeignSession(session_tag);
321 } 317 }
322 318
323 } // namespace sessions_helper 319 } // namespace sessions_helper
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698