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/ui/toolbar/recent_tabs_builder_test_helper.h" | 5 #include "chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 if (title.empty()) { | 176 if (title.empty()) { |
177 title = base::UTF8ToUTF16(ToTabTitle( | 177 title = base::UTF8ToUTF16(ToTabTitle( |
178 GetSessionID(session_index), | 178 GetSessionID(session_index), |
179 GetWindowID(session_index, window_index), | 179 GetWindowID(session_index, window_index), |
180 GetTabID(session_index, window_index, tab_index))); | 180 GetTabID(session_index, window_index, tab_index))); |
181 } | 181 } |
182 return title; | 182 return title; |
183 } | 183 } |
184 | 184 |
185 void RecentTabsBuilderTestHelper::ExportToSessionsSyncManager( | 185 void RecentTabsBuilderTestHelper::ExportToSessionsSyncManager( |
186 browser_sync::SessionsSyncManager* manager) { | 186 sync_sessions::SessionsSyncManager* manager) { |
187 syncer::SyncChangeList changes; | 187 syncer::SyncChangeList changes; |
188 for (int s = 0; s < GetSessionCount(); ++s) { | 188 for (int s = 0; s < GetSessionCount(); ++s) { |
189 sync_pb::EntitySpecifics session_entity; | 189 sync_pb::EntitySpecifics session_entity; |
190 sync_pb::SessionSpecifics* meta = session_entity.mutable_session(); | 190 sync_pb::SessionSpecifics* meta = session_entity.mutable_session(); |
191 BuildSessionSpecifics(s, meta); | 191 BuildSessionSpecifics(s, meta); |
192 for (int w = 0; w < GetWindowCount(s); ++w) { | 192 for (int w = 0; w < GetWindowCount(s); ++w) { |
193 BuildWindowSpecifics(s, w, meta); | 193 BuildWindowSpecifics(s, w, meta); |
194 for (int t = 0; t < GetTabCount(s, w); ++t) { | 194 for (int t = 0; t < GetTabCount(s, w); ++t) { |
195 sync_pb::EntitySpecifics entity; | 195 sync_pb::EntitySpecifics entity; |
196 sync_pb::SessionSpecifics* tab_base = entity.mutable_session(); | 196 sync_pb::SessionSpecifics* tab_base = entity.mutable_session(); |
(...skipping 17 matching lines...) Expand all Loading... |
214 session_entity, | 214 session_entity, |
215 GetSessionTimestamp(s), | 215 GetSessionTimestamp(s), |
216 syncer::AttachmentIdList(), | 216 syncer::AttachmentIdList(), |
217 syncer::AttachmentServiceProxyForTest::Create()))); | 217 syncer::AttachmentServiceProxyForTest::Create()))); |
218 } | 218 } |
219 manager->ProcessSyncChanges(FROM_HERE, changes); | 219 manager->ProcessSyncChanges(FROM_HERE, changes); |
220 VerifyExport(manager); | 220 VerifyExport(manager); |
221 } | 221 } |
222 | 222 |
223 void RecentTabsBuilderTestHelper::VerifyExport( | 223 void RecentTabsBuilderTestHelper::VerifyExport( |
224 sync_driver::OpenTabsUIDelegate* delegate) { | 224 sync_sessions::OpenTabsUIDelegate* delegate) { |
225 // Make sure data is populated correctly in SessionModelAssociator. | 225 // Make sure data is populated correctly in SessionModelAssociator. |
226 std::vector<const sync_driver::SyncedSession*> sessions; | 226 std::vector<const sync_sessions::SyncedSession*> sessions; |
227 ASSERT_TRUE(delegate->GetAllForeignSessions(&sessions)); | 227 ASSERT_TRUE(delegate->GetAllForeignSessions(&sessions)); |
228 ASSERT_EQ(GetSessionCount(), static_cast<int>(sessions.size())); | 228 ASSERT_EQ(GetSessionCount(), static_cast<int>(sessions.size())); |
229 for (int s = 0; s < GetSessionCount(); ++s) { | 229 for (int s = 0; s < GetSessionCount(); ++s) { |
230 std::vector<const sessions::SessionWindow*> windows; | 230 std::vector<const sessions::SessionWindow*> windows; |
231 ASSERT_TRUE(delegate->GetForeignSession(ToSessionTag(GetSessionID(s)), | 231 ASSERT_TRUE(delegate->GetForeignSession(ToSessionTag(GetSessionID(s)), |
232 &windows)); | 232 &windows)); |
233 ASSERT_EQ(GetWindowCount(s), static_cast<int>(windows.size())); | 233 ASSERT_EQ(GetWindowCount(s), static_cast<int>(windows.size())); |
234 for (int w = 0; w < GetWindowCount(s); ++w) | 234 for (int w = 0; w < GetWindowCount(s); ++w) |
235 ASSERT_EQ(GetTabCount(s, w), static_cast<int>(windows[w]->tabs.size())); | 235 ASSERT_EQ(GetTabCount(s, w), static_cast<int>(windows[w]->tabs.size())); |
236 } | 236 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 tab->set_current_navigation_index(0); | 299 tab->set_current_navigation_index(0); |
300 tab->set_pinned(true); | 300 tab->set_pinned(true); |
301 tab->set_extension_app_id("app_id"); | 301 tab->set_extension_app_id("app_id"); |
302 sync_pb::TabNavigation* navigation = tab->add_navigation(); | 302 sync_pb::TabNavigation* navigation = tab->add_navigation(); |
303 navigation->set_virtual_url(ToTabUrl(session_id, window_id, tab_id)); | 303 navigation->set_virtual_url(ToTabUrl(session_id, window_id, tab_id)); |
304 navigation->set_referrer("referrer"); | 304 navigation->set_referrer("referrer"); |
305 navigation->set_title(base::UTF16ToUTF8(GetTabTitle( | 305 navigation->set_title(base::UTF16ToUTF8(GetTabTitle( |
306 session_index, window_index, tab_index))); | 306 session_index, window_index, tab_index))); |
307 navigation->set_page_transition(sync_pb::SyncEnums_PageTransition_TYPED); | 307 navigation->set_page_transition(sync_pb::SyncEnums_PageTransition_TYPED); |
308 } | 308 } |
OLD | NEW |